Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proto/torchft.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ message ManagerQuorumResponse {
int64 replica_world_size = 10;
bool heal = 11;
int64 commit_failures = 12;
repeated string replica_ids = 13;
}

message CheckpointMetadataRequest {
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl ManagerClient {
max_replica_rank: resp.max_replica_rank,
max_world_size: resp.max_world_size,
heal: resp.heal,
replica_ids: resp.replica_ids,
})
})
}
Expand Down Expand Up @@ -293,6 +294,7 @@ struct QuorumResult {
max_replica_rank: Option<i64>,
max_world_size: i64,
heal: bool,
replica_ids: Vec<String>,
}

#[pymethods]
Expand All @@ -311,6 +313,7 @@ impl QuorumResult {
max_replica_rank: None,
max_world_size: 1,
heal: false,
replica_ids: Vec::new(),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ fn compute_quorum_results(
.map(|p| p.commit_failures)
.max()
.unwrap_or(0),
replica_ids: participants.iter().map(|p| p.replica_id.clone()).collect(),
})
}

Expand Down
19 changes: 7 additions & 12 deletions torchft/_test/diloco_trainer.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import copy
import logging
import os
from contextlib import ExitStack
from datetime import timedelta
from typing import Any, cast, Dict, List
from typing import Any, Dict

import torch
from torch import nn
from torch.distributed.tensor import DTensor
from torch.distributed.tensor import DeviceMesh, DTensor

from torchft.device_mesh import ft_init_device_mesh, ManagedDeviceMesh
from torchft.local_sgd import DiLoCo
from torchft.manager import Manager
from torchft.manager_integ_test import MyModel, Runner
Expand Down Expand Up @@ -113,7 +111,7 @@ def __init__(

self.manager: Manager = self.setup_manager()

self.ft_device_mesh: None | ManagedDeviceMesh = None
self.device_mesh: None | DeviceMesh = None
self.setup_distributed()

self.criterion: nn.CrossEntropyLoss = nn.CrossEntropyLoss()
Expand Down Expand Up @@ -197,12 +195,9 @@ def setup_distributed(self) -> None:
os.environ["WORLD_SIZE"] = str(self.runner.world_size)
os.environ["RANK"] = str(self.rank)

self.ft_device_mesh = ft_init_device_mesh(
device_type=self.device.type,
mesh_shape=(self.runner.world_size, 1),
mesh_dim_names=("replicate", "none"),
replicate_dim=0,
manager=self.manager,
self.device_mesh = DeviceMesh(
self.device.type,
torch.arange(self.runner.world_size),
)

# Convert model parameters to DTensor
Expand All @@ -211,7 +206,7 @@ def setup_distributed(self) -> None:
for param in layer.parameters():
param = DTensor.from_local(
param,
device_mesh=self.ft_device_mesh,
device_mesh=self.device_mesh,
)

def load_state_dict(self, state_dict: Dict[str, Dict[str, object]]) -> None:
Expand Down
1 change: 1 addition & 0 deletions torchft/_torchft.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class QuorumResult:
max_world_size: int
heal: bool
commit_failures: int
replica_ids: list[str]

class ManagerServer:
def __init__(
Expand Down
Loading
Loading