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

remove old-style fsdp/ddp #1640

Merged
merged 7 commits into from
Jan 14, 2025
Merged

remove old-style fsdp/ddp #1640

merged 7 commits into from
Jan 14, 2025

Conversation

t-vi
Copy link
Collaborator

@t-vi t-vi commented Jan 13, 2025

cc: @crcrpar

Plan:

Replace with transform-aware module functions:

  • thunder/tests/distributed/test_checkpoint.py::DistributedCheckpointTest::test_get_model_state_dict
  • thunder/tests/distributed/test_checkpoint.py::DistributedCheckpointTest::test_load_model_state_dict

Removed as not (currently) applicable

  • FAILED thunder/tests/distributed/test_ddp.py::DDPTest::test_ddp_model_as_argument
    --> We are not re-entrant.

Fixed

  • thunder/tests/distributed/test_ddp.py::DDPTest::test_ddp_grad_parity_with_without_bucketing * 2
  • thunder/tests/distributed/test_ddp.py::test_native_ddp * 4
  • test_fsdp.py::FSDPTest::test_fsdp_with_no_sync_grad_accumulation * 4 - Thank you @crcrpar

@t-vi t-vi requested review from mruberry and lantiga as code owners January 13, 2025 11:52
@t-vi t-vi marked this pull request as draft January 13, 2025 12:29
@t-vi t-vi force-pushed the tom/drop-old-style-distributed branch from d19a76d to a477a7c Compare January 13, 2025 12:57
Copy link
Collaborator

@crcrpar crcrpar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm speculating that the failure of fsdp no_sync parity tests is caused by the mismatch between the parameters that _sync_grads collects and ones that _stash_grad_for_fsdp_prim_impl attaches the unsharded grads.

  • params_with_grad = tuple(filter(lambda p: hasattr(p, "_thunder_fsdp_unsharded_grad"), module.parameters()))
    if not params_with_grad:
    return
    .
  • def _stash_grad_for_fsdp_prim_impl(
    grad: torch.Tensor,
    param_fqn: str,
    compile_data: CompileData,
    ) -> None:
    grad_name = "_thunder_fsdp_unsharded_grad"
    param = compile_data.fn.get_parameter(param_fqn)
    if torch.is_tensor(unsharded_grad := getattr(param, grad_name, None)):
    unsharded_grad += grad
    else:
    setattr(param, grad_name, grad)
    return grad

@t-vi t-vi marked this pull request as ready for review January 14, 2025 09:54
@t-vi t-vi enabled auto-merge (squash) January 14, 2025 09:54
Copy link
Collaborator

@lantiga lantiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stamped!

@t-vi t-vi merged commit bcf4fe4 into main Jan 14, 2025
45 checks passed
@t-vi t-vi deleted the tom/drop-old-style-distributed branch January 14, 2025 16:15
riccardofelluga pushed a commit that referenced this pull request Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants