feat: implement native FSDP full-graph caputre Phase 1 (inference) + …#44
Open
Amertos wants to merge 1 commit into
Open
feat: implement native FSDP full-graph caputre Phase 1 (inference) + …#44Amertos wants to merge 1 commit into
Amertos wants to merge 1 commit into
Conversation
…Phase 2 (training)
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 FSDP Full-Graph Capture – Initial Implementation Complete (Phase 1 + Phase 2)
Hey team! I've been working on the FSDP full-graph capture feature and have an alpha implementation ready. Here's what's been built:
✅ What's Implemented
Phase 1 – Inference Full-Graph Capture
FSDPInferenceCapturewith:torch._dynamo.export-based tracing (with manual fallback)torch.distributedcollectives for transparent capturePhase 2 – Training Full-Graph Capture
FSDPTrainingCapturewith:Graph Optimizer (6 passes)
dead_code_elimination– removes unreachable nodescomm_fusion– fuses consecutive same-kind communication collectivescompute_comm_fusion– marks adjacent compute+comm nodes for fused kernelscomm_computation_overlap– schedules all-gather on separate CUDA streamsauto_recompute– marks large activations for recomputationdeterministic_align– marks all nodes for reproducible executionCore Infrastructure
FXGraph– unified graph IR with topological sort, DOT exportFSDPHookContext– context manager for patching/unpatchingtorch.distributedcollectivespatches.py– monkey-patching forall_gather,reduce_scatter,all_reducewith recording buffermagicompile()– convenience API as main entry point📊 Test Results
59/59 tests passing ✅ (14.09s execution time)
test_core_graph.pytest_fsdp_inference.pytest_fsdp_training.pytest_optimizations.pytest_utils_patches.py📦 Project Structure
🔜 Known Gaps / Next Steps
torch._dynamo.exportis deprecated in PyTorch 2.13 – needs migration totorch.export.export(18 FutureWarnings currently)torchrun-based tests with multiple GPUs to verify real FSDP collective capture💡 How to Test It
I can open a PR with this if folks want to review the code. Happy to iterate on feedback! 🚀