FabricModule: wrap forward methods instead of monkeypatch-based redirect#20711
FabricModule: wrap forward methods instead of monkeypatch-based redirect#20711tonyf wants to merge 5 commits intoLightning-AI:masterfrom
Conversation
for more information, see https://pre-commit.ci
|
seems the falling stand-alone test is a false alarm :) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20711 +/- ##
=========================================
- Coverage 87% 81% -6%
=========================================
Files 269 269
Lines 23688 23688
=========================================
- Hits 20666 19218 -1448
- Misses 3022 4470 +1448 |
|
Ah! looks like I need to update the redirection tests. Will try to get around to it soon. Currently using this fix in prod successfully |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If you need further help see our docs: https://lightning.ai/docs/pytorch/latest/generated/CONTRIBUTING.html#pull-request or ask the assistance of a core contributor here or on Discord. Thank you for your contributions. |
|
Hi @tonyf , |
What does this PR do?
When running with
torch.compileandModelParallelStrategythe monkeypatch method of redirecting forward methods through the FabricModule's custom forward method raises an exception if the marked method does not have the same signature as the original forward method.Instead of monkeypatching forward to the method being called, this PR wraps the function to ensure the right strategy contexts are provided.
This could be cleaned up further by just wrapping the functions in
mark_forward_methodbut that would require touching_LIGHTNING_MODULE_STEP_METHODS = ("training_step", "validation_step", "test_step", "predict_step").Fixes #20710
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing, make sure you have read the review guidelines. In short, see the following bullet-list:
Reviewer checklist
📚 Documentation preview 📚: https://pytorch-lightning--20711.org.readthedocs.build/en/20711/