Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] fail when diloco is used with global pg size of 1 #21

Closed
wants to merge 1 commit into from
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
3 changes: 3 additions & 0 deletions src/zeroband/diloco.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def __init__(
if self.fsdp_sharding_strategy not in [ShardingStrategy.FULL_SHARD, ShardingStrategy.SHARD_GRAD_OP]:
raise ValueError("Diloco only support FULL_SHARD and SHARD_GRAD_OP")

if self.world_info.global_world_size < 1:
raise ValueError("Diloco requires a global world size of at least 1")

self._init_offloaded_optimizer(model=model)

def _init_offloaded_optimizer(self, model):
Expand Down
2 changes: 1 addition & 1 deletion src/zeroband/utils/world_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self):
self.global_unique_id = os.environ.get("GLOBAL_UNIQUE_ID", None)
self.global_addr = os.environ.get("GLOBAL_ADDR", None)
self.global_port = int(os.environ.get("GLOBAL_PORT")) if "GLOBAL_PORT" in os.environ else None
self.global_world_size = int(os.environ.get("GLOBAL_WORLD_SIZE", 1))
self.global_world_size = int(os.environ.get("GLOBAL_WORLD_SIZE", 0))
self.global_rank = int(os.environ.get("GLOBAL_RANK", 0))

def __repr__(self):
Expand Down