Repository navigation
Fix FFN depth-scaled initialization target - #5111
Conversation
|
|
|
The following ciflow label(s) have been added but CI has not been triggered yet because the workflows are awaiting approval:
Once a maintainer approves the workflows (scroll to the bottom of the PR page), the corresponding CI jobs will be triggered automatically. Please ping one of the reviewers if you do not have access to approve and run workflows. |
|
@claude review this PR |
|
Claude finished @tianyu-l's task in 1m 21s —— View job Review: Fix FFN depth-scaled initialization target
The change itself is correct. Every edited site now initializes the logical
In DeepSeek V4 MTP and Qwen3.5, the 1. The PR description misstates where this behavior came from (please fix it)The description says the fused nn.init.trunc_normal_(self.w1.weight, mean=0.0, std=0.02)
for linear in (self.w2, self.w3):
nn.init.trunc_normal_(linear.weight, mean=0.0, std=init_std)That is where the name Under the repo's rules (Core Principle 5 and "Validating Numerics"), a computation change needs loss convergence evidence on a representative dataset (e.g. C4). At minimum that means before/after curves for Llama3 8B or the debug model, plus one MoE model such as DSv3 16B. The PR currently lists only the CPU unit test and CI. Please add the convergence results and update the description so it says this is an intentional numerics change. 2. The optional override has no in-tree user of its defaultAfter this PR, every in-tree caller that passes a depth-scaled
A cleaner API, following Principle 3 (reuse over duplication) and the config rule against
This touches about 15 call sites, mostly in tests ( 3. GPT-OSS is still inconsistent (could be a follow-up)
4. Test coverage
Nits
SummaryThe fix does what it says. Before merge, it needs convergence evidence because it changes init numerics for every depth-init model, and a more accurate description of where the old behavior came from. I'd also recommend renaming |
|
oops, ill fix that real quick |
882e1aa to
3ddb7ec
Compare
d6668fe to
10503c1
Compare
|
Cleaned up the API and added the missing tests :) |
|
@claude review this PR |
| ``w1`` and ``w3`` are the gate/up projections and share | ||
| ``w1_param_init``; ``w2`` is the residual output projection. |
There was a problem hiding this comment.
should we rename to w13_param_init then?
There was a problem hiding this comment.
yeah thats probably a lot cleaner
|
@claude review again |
|
Claude finished @tianyu-l's task in 1m 16s —— View job Re-review: Fix FFN depth-scaled initialization target
The code matches what my first review asked for. 1. Rename
|
|
Renamed it to |
| w1_param_init=_LINEAR_INIT, | ||
| w2w3_param_init=_depth_init(layer_id), | ||
| w13_param_init=_LINEAR_INIT, | ||
| w2_param_init=_depth_init(layer_id), |
There was a problem hiding this comment.
should we deprecate depth_init? I'm not sure if it's useful, do you have any idea?
There was a problem hiding this comment.
I would keep it, alteast for now and separate that decision from this fix. Removing depth scaling changes initialization numerics across several models and would need a closer look upon.
| w1_param_init=_LINEAR_INIT, | ||
| w2w3_param_init=_LINEAR_INIT, | ||
| w13_param_init=_LINEAR_INIT, | ||
| w2_param_init=_LINEAR_INIT, |
There was a problem hiding this comment.
e.g. qwen3 is not using depth init
There was a problem hiding this comment.
Yeah, Qwen3 already uses uniform initialization, so its behavior stays the exact same here. I would keep depth scaling model-specific for now, since removing it from the other models would need a closer look.
|
Fixed a CI error which was expecting exact SFT numerics from the old initialization. |
|
@GodlyDonuts please wait until all CI finishes and push a single change to fix all the numerics |
Sorry! Won't happen again :) |
|
@GodlyDonuts |
|
Updated all five snapshots responsible for the six failing configurations. |
|
looks like the real pg loss is not updated, therefore failing the CI. https://github.com/pytorch/torchtitan/actions/runs/37873979056/job/113638386726 codex tells me those are the missing updated files |
Summary
Depth-scale only the FFN output projection (
w2), while keeping the gate/up projections (w1andw3) on the regular initializer across the affected dense, shared-expert, and routed-expert paths.The common FFN helpers now use
w13_param_initandw2_param_init, which makes the initialization roles explicit and avoids carrying forward the oldw2w3_param_initgrouping.This is an intentional change to initialization numerics for models that use depth-scaled output projections. It is not a regression introduced by the fused
w13representation; the older unfused implementation also depth-scaledw3. Existing checkpoints are unaffected, as are models such as Qwen3 that already initialize these projections uniformly.depth_initremains model-specific. GPT-OSS uses a separate initialization scheme and is intentionally left for a follow-up rather than changing its numerics in this PR.Changes
w13projections (w1andw3).w2.w13_param_initandw2_param_init.w3_EFDinitialization in the affected routed-expert paths.Validation
The new routed-expert regression cases pass on this branch and fail against the original base, covering the initialization behavior this PR changes.
Passing:
Because this changes initialization for from-scratch training, dense and MoE convergence validation is still pending.