Repository navigation
Add RegionAC feed-forward regions - #4526
Conversation
[ghstack-poisoned]
| remat.recompute_needs_tensor(w1_out) | ||
| remat.recompute_needs_tensor(w3_out) |
There was a problem hiding this comment.
in the dist_gemm.py file, you have
remat.recompute_needs_tensor(h1, h3)
what's the rule here?
There was a problem hiding this comment.
Both are same but we should be consistent. I will choose one and stick with it.
There was a problem hiding this comment.
I have a proposal, which could be done in separate PR, but would like to run idea by you:
- we make a fused mlp implementation where (1) we fuse w1w3 during matmul, but (2) leave silu and mul torch-native (slow)
- It should be default for every model. The unfused w1 w3 version might be kept? Or should we delete it? Similar reasoning for the fused QKV linear in attention. I prefer to remove the unfused versions to reduce maintenance overhead (like in this PR).
- Regardless, every advanced feature should only integrate with this fused w1w3 impl, including dist_gemm, LoRA, quantization, etc. (But it's not clear to me what's the dist_gemm + quantization story)
- In
override/, we keep the additional impl which fuses silu_and_mul using a triton kernel, which all previous optimizations should work with it out-of-box.
There was a problem hiding this comment.
I think making the fused version the default makes sense. This will reduce maintenance burden.
I will do a quick investigation if the unfused version has any benefit, and if not, I can send the fused version PR.
There was a problem hiding this comment.
The suggested unfused removals are in the PRs stacked under this PR.
[ghstack-poisoned]
| # Optional QK normalization (before RoPE, per Qwen3) | ||
| if self.q_norm is not None or self.k_norm is not None: | ||
| assert self.q_norm is not None and self.k_norm is not None | ||
| remat.recompute_needs_tensor(xq_THK) |
There was a problem hiding this comment.
Code motion to follow the rule - "place the recompute_needs_tensor just before the consumer" - This rule is added in remat.md now.
[ghstack-poisoned]
ghstack-source-id: 81a5121 Pull-Request: pytorch/torchtitan#4526
[ghstack-poisoned]
[ghstack-poisoned]
[ghstack-poisoned]
ghstack-source-id: 59dd465 Pull-Request: pytorch/torchtitan#4526
[ghstack-poisoned]
ghstack-source-id: 5943262 Pull-Request: pytorch/torchtitan#4526
[ghstack-poisoned]
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.18.0) (oldest at bottom): * #4543 * #4542 * #4541 * #4623 * #4559 * #4591 * #4592 * #4540 * #4539 * #4643 * #4526 * #4546 * __->__ #4535 Use one physical w13 Linear config and parameter for dense feed-forward gate and up projections. Compose their initialization before module construction, configure activation implementations directly, and translate external gate/up checkpoint keys in model state-dict adapters.
[ghstack-poisoned]
|
Warning: Unknown label
Please add the new label to .github/pytorch-probot.yml |
ghstack-source-id: 6fa860d Pull-Request: pytorch/torchtitan#4526
… regrouping only pytorch#4526 (mandatory fused QKV) and pytorch#4535 (fused gate-up by default) change the arithmetic GROUPING, not the arithmetic. Verified on Perlmutter A100 against torch 2.13.0+cu130, the version HEAD requires. The naive seeded A/B is misleading and the writeup leads with why: building a model on each tree gives logits_sum -3716 vs +1090, not even the same sign. That is an INIT-ORDER difference, not a numerics one -- the fused w13 consumes the RNG stream differently than separate w1/w3. Proof: tok_embeddings, initialized before the first fused layer, is bit-identical across the merge, while everything after it differs in value but matches in std. The decisive test loads ONE state dict into both trees: missing: [], unexpected: [] hooks preserve logical w1/w3 max |delta| 1.907e-06 float32 eps = 1.192e-07 max rel err 1.275e-06 at |a|>1.0, falling monotonically with magnitude argmax 100.00% agreement top-5 100.00% agreement Monotone-decreasing relative error is the signature of float regrouping; a wrong layout would be large and magnitude-independent. Does NOT clear the XPU smoke. Recorded there: Perlmutter's torch has _fsdp_param.py at 1095 lines with zero _resolve_spmd_types_for_storage -- the SAME gap as the ALCF build -- so spmd_types is a torch version floor, not an XPU bug, and no NERSC run can answer it.
Stack from ghstack (oldest at bottom):