Skip to content

Conversation

anshul-si
Copy link
Contributor

@anshul-si anshul-si commented Oct 7, 2025

Summary: Created a test so that we can verify that a model that has been pipelined + replicated has the same gradients as a reference model. To do this, I mapped the layers and their parameters in each partial model to the original full model and then compared the gradients.
Test Case

  1. pytest test/distributed/_composable/test_composability/test_pp_composability.py -k test_replicate_pp_grads

Stack from ghstack (oldest at bottom):

cc @H-Huang @awgu @wanchaol @fegin @fduwjj @wz337 @wconstab @d4l3k @pragupta @msaroufim @dcci

Copy link

pytorch-bot bot commented Oct 7, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/164890

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 47cac6d with merge base f63d16c (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added oncall: distributed Add this issue/PR to distributed oncall triage queue topic: not user facing topic category labels Oct 7, 2025
anshul-si added a commit that referenced this pull request Oct 7, 2025
…vice model grads

ghstack-source-id: ac3f1c3
Pull Request resolved: #164890
@anshul-si anshul-si added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 7, 2025
@anshul-si anshul-si requested a review from H-Huang October 8, 2025 00:03
Copy link
Member

@H-Huang H-Huang left a comment

Choose a reason for hiding this comment

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

LGTM, just some small comments / questions. Feel free to land it when you are ready!

],
)
def test_replicate_pp_grads(self, ScheduleClass):
_device_raii = torch.device(device_type, self.device)
Copy link
Member

Choose a reason for hiding this comment

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

confused how this is used? My guess based on the variable name is keep a reference to the device to keep it alive, but not sure why it is needed. If you can find out, i am curious!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe its intended purpose was to do what you're saying. Turns out that its not needed in this instance so I will get rid of them.

pipeline_model_parameter_dict = {}

# Attach to a schedule
if issubclass(ScheduleClass, PipelineScheduleSingle):
Copy link
Member

Choose a reason for hiding this comment

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

dang, this if-else needed for single stage schedules vs multistage schedules is so ugly, i should fix it 😭

…s single-device model grads"

**Summary:** Created a test so that we can verify that a model that has been pipelined + replicated has the same gradients as a reference model. To do this, I mapped the layers and their parameters in each partial model to the original full model and then compared the gradients. 
**Test Case**
1. pytest test/distributed/_composable/test_composability/test_pp_composability.py -k test_replicate_pp_grads




cc H-Huang awgu wanchaol fegin fduwjj wz337 wconstab d4l3k pragupta msaroufim dcci

[ghstack-poisoned]
anshul-si added a commit that referenced this pull request Oct 8, 2025
…vice model grads

ghstack-source-id: 051cca5
Pull Request resolved: #164890
@anshul-si
Copy link
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ciflow/trunk Trigger trunk jobs on your pull request Merged oncall: distributed Add this issue/PR to distributed oncall triage queue topic: not user facing topic category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants