Repository navigation
[graph_trainer] Add CooR precompile support for rank-agnostic compilation - #2713
Conversation
[ghstack-poisoned]
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: b6b4816
Pull-Request: #2713
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 1c7c950
Pull-Request: #2713
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 6100357
Pull-Request: #2713
| --training.seq_len 2048 | ||
|
|
||
| # Step 2: load and train with torchrun (uses all GPUs) | ||
| torchrun --nproc_per_node=8 --virtual-local-rank \ |
There was a problem hiding this comment.
I did consider deriving these flags from the precompiled artifact but decided against it for the following reasons:
- The additional fingerprint check seems useful in the case when the CLI args at runtime are different than the ones used at precompile time.
- Since some configs come from the artifact (model, parallelism, compile passes) but others come from the user (training steps, batch size, etc), we'd have to implement some sort of partial load + merge config system which makes the interface harder to reason about from a user POV.
|
@claude review this PR |
|
Claude finished @yiming0416's task in 4m 16s —— View job Review of PR #2713: [graph_trainer] Add CooR precompile support
SummaryThis PR adds single-process precompilation using compile-on-one-rank (CooR). The key idea is that a single GPU can trace through distributed ops with a fake backend, producing a rank-agnostic artifact that all ranks can load during torchrun training. The bitwise-identical verification across 100 steps (Llama3-8B, 16 GPUs) is strong evidence of correctness. The architecture is clean: Issues1. Integration tests will fail — no precompile pre-step mechanism (Bug)The two new integration tests ( if not storage.exists(artifact_key):
raise ValueError(
f"Precompiled artifact not found at ..."
)The test infrastructure ( The previous behavior had a fallback (compile-on-the-fly if no artifact exists, then save). This PR removed that fallback in favor of the two-step workflow, but the integration tests weren't updated to accommodate the new two-step requirement. Suggestion: Either extend 2. CooR flag toggling is not exception-safe during init_weights (
|
…tic compilation"
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
<img width="2383" height="887" alt="image" src="https://github.com/user-attachments/assets/27b9ac3d-2b51-4bba-948c-befdb35dd846" />
[ghstack-poisoned]
…t for rank-agnostic compilation"
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
<img width="2383" height="887" alt="image" src="https://github.com/user-attachments/assets/27b9ac3d-2b51-4bba-948c-befdb35dd846" />
[ghstack-poisoned]
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 8234101
Pull-Request: #2713
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 9930518
Pull-Request: #2713
| --parallelism.tensor_parallel_degree 2 | ||
|
|
||
| # Step 2: load and train with torchrun (uses all GPUs) | ||
| torchrun --nproc_per_node=8 --virtual-local-rank \ |
There was a problem hiding this comment.
Do you actually want --virtual-local-rank in the README here
There was a problem hiding this comment.
I worry if we don't it will be a footgun since our graphs aren't actually device normalized without it. We could consider maybe turning the flag on by default in the torchtitan trainer? cc @aorenste
| --compile.joint_passes inductor_decomposition \ | ||
| --compile.precompile_artifact_dir /tmp/precompile_artifacts \ | ||
| --parallelism.data_parallel_shard_degree 4 \ | ||
| --parallelism.tensor_parallel_degree 2 |
There was a problem hiding this comment.
It is difficult to tell which of these flags are load bearing versus which ones can be dropped / changed.
There was a problem hiding this comment.
All of these flags are load bearing since they all feed into the config fingerprint.
| --parallelism.tensor_parallel_degree 2 | ||
|
|
||
| # Step 2: load and train with torchrun (uses all GPUs) | ||
| torchrun --nproc_per_node=8 --virtual-local-rank \ |
There was a problem hiding this comment.
what does this flag do? It's hard to tell from its pytorch docstring.
There was a problem hiding this comment.
It makes it so each rank sees cuda:0 by using CUDA_VISIBLE_DEVICES under the hood. We need this since torch.compile by default specializes on device id.
[ghstack-poisoned]
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 7c23061
Pull-Request: #2713
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 7c23061
Pull-Request: #2713
tianyu-l
left a comment
There was a problem hiding this comment.
lgtm, may need to rebase before merge
[ghstack-poisoned]
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 506cd3e
Pull-Request: #2713
…tion
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
- precompile.py: Artifact serialization/loading with config fingerprint
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
- precompile_main.py: Single-process entry point using fake PG backend
- graph_utils.py: Enable CooR in export_joint() when precompile is on,
so PG names are opaque graph inputs (not hardcoded string constants)
- compile.py: Precompile save/load integration with AOT compilation
- passes.py: Fix inductor_decomposition_pass for CooR opaque inputs
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps
20-step plot: https://pxl.cl/9c0Tv
100-step plot: https://pxl.cl/9c2FN
ghstack-source-id: 506cd3e
Pull-Request: #2713
Update `test_precompile.py` to align with the API changes from #2713 (CooR precompile support), which removed the explicit key parameter from `precompile_save` and `precompile_load` ``` pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py ```
…tion (pytorch#2713) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * __->__ pytorch#2713 Adds single-process precompilation using compile-on-one-rank (CooR) to generate rank-agnostic compiled artifacts. A single GPU traces through distributed ops with a fake backend, producing an artifact loadable by all ranks during torchrun training. Key changes: - precompile.py: Artifact serialization/loading with config fingerprint validation. DeviceMesh objects flow as opaque graph inputs (via DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load patching or PG aliasing is needed. - precompile_main.py: Single-process entry point using fake PG backend - graph_utils.py: Enable CooR in export_joint() when precompile is on, so PG names are opaque graph inputs (not hardcoded string constants) - compile.py: Precompile save/load integration with AOT compilation - passes.py: Fix inductor_decomposition_pass for CooR opaque inputs Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs): Model: graph_trainer_llama3_8b Parallelism: TP=8, SimpleFSDP=2 Compile: AOT, full_inductor_compilation + inductor_decomposition Training: 100 steps, local_batch_size=1, seq_len=2048 Determinism: --debug.seed=42 --debug.deterministic CooR precompile (1 node, 1 GPU, fake PG backend) -> train (2 nodes, 16 GPUs) vs baseline (no precompile) Result: bitwise identical loss and grad_norm for all 100 steps <img width="2383" height="887" alt="image" src="https://github.com/user-attachments/assets/27b9ac3d-2b51-4bba-948c-befdb35dd846" />
Update `test_precompile.py` to align with the API changes from pytorch#2713 (CooR precompile support), which removed the explicit key parameter from `precompile_save` and `precompile_load` ``` pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py ```
…tion (pytorch#2713) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * __->__ pytorch#2713 Adds single-process precompilation using compile-on-one-rank (CooR) to generate rank-agnostic compiled artifacts. A single GPU traces through distributed ops with a fake backend, producing an artifact loadable by all ranks during torchrun training. Key changes: - precompile.py: Artifact serialization/loading with config fingerprint validation. DeviceMesh objects flow as opaque graph inputs (via DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load patching or PG aliasing is needed. - precompile_main.py: Single-process entry point using fake PG backend - graph_utils.py: Enable CooR in export_joint() when precompile is on, so PG names are opaque graph inputs (not hardcoded string constants) - compile.py: Precompile save/load integration with AOT compilation - passes.py: Fix inductor_decomposition_pass for CooR opaque inputs Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs): Model: graph_trainer_llama3_8b Parallelism: TP=8, SimpleFSDP=2 Compile: AOT, full_inductor_compilation + inductor_decomposition Training: 100 steps, local_batch_size=1, seq_len=2048 Determinism: --debug.seed=42 --debug.deterministic CooR precompile (1 node, 1 GPU, fake PG backend) -> train (2 nodes, 16 GPUs) vs baseline (no precompile) Result: bitwise identical loss and grad_norm for all 100 steps <img width="2383" height="887" alt="image" src="https://github.com/user-attachments/assets/27b9ac3d-2b51-4bba-948c-befdb35dd846" />
Update `test_precompile.py` to align with the API changes from pytorch#2713 (CooR precompile support), which removed the explicit key parameter from `precompile_save` and `precompile_load` ``` pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py ```
…tion (pytorch#2713) Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.14.0) (oldest at bottom): * __->__ pytorch#2713 Adds single-process precompilation using compile-on-one-rank (CooR) to generate rank-agnostic compiled artifacts. A single GPU traces through distributed ops with a fake backend, producing an artifact loadable by all ranks during torchrun training. Key changes: - precompile.py: Artifact serialization/loading with config fingerprint validation. DeviceMesh objects flow as opaque graph inputs (via DTensor.__tensor_flatten__ -> OpaqueObjectState), so no post-load patching or PG aliasing is needed. - precompile_main.py: Single-process entry point using fake PG backend - graph_utils.py: Enable CooR in export_joint() when precompile is on, so PG names are opaque graph inputs (not hardcoded string constants) - compile.py: Precompile save/load integration with AOT compilation - passes.py: Fix inductor_decomposition_pass for CooR opaque inputs Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs): Model: graph_trainer_llama3_8b Parallelism: TP=8, SimpleFSDP=2 Compile: AOT, full_inductor_compilation + inductor_decomposition Training: 100 steps, local_batch_size=1, seq_len=2048 Determinism: --debug.seed=42 --debug.deterministic CooR precompile (1 node, 1 GPU, fake PG backend) -> train (2 nodes, 16 GPUs) vs baseline (no precompile) Result: bitwise identical loss and grad_norm for all 100 steps <img width="2383" height="887" alt="image" src="https://github.com/user-attachments/assets/27b9ac3d-2b51-4bba-948c-befdb35dd846" />
Update `test_precompile.py` to align with the API changes from pytorch#2713 (CooR precompile support), which removed the explicit key parameter from `precompile_save` and `precompile_load` ``` pytest torchtitan/experiments/graph_trainer/tests/test_precompile.py ```
Stack from ghstack (oldest at bottom):
Adds single-process precompilation using compile-on-one-rank (CooR) to
generate rank-agnostic compiled artifacts. A single GPU traces through
distributed ops with a fake backend, producing an artifact loadable by
all ranks during torchrun training.
Key changes:
validation. DeviceMesh objects flow as opaque graph inputs (via
DTensor.tensor_flatten -> OpaqueObjectState), so no post-load
patching or PG aliasing is needed.
so PG names are opaque graph inputs (not hardcoded string constants)
Verification (Llama3-8B, MAST, 2 nodes / 16 GPUs):
Model: graph_trainer_llama3_8b
Parallelism: TP=8, SimpleFSDP=2
Compile: AOT, full_inductor_compilation + inductor_decomposition
Training: 100 steps, local_batch_size=1, seq_len=2048
Determinism: --debug.seed=42 --debug.deterministic
CooR precompile (1 node, 1 GPU, fake PG backend)
-> train (2 nodes, 16 GPUs) vs baseline (no precompile)
Result: bitwise identical loss and grad_norm for all 100 steps