Commit e354e30
Fix FP4 swapAB L1 accuracy: align routing-weight fold order with non-swap
The L1 swap epilogue folded the per-token routing weight into the value
before the per-token amax / FP8 quantization, whereas the non-swap path
folds it into sf_inv afterwards. The differing FP32 multiply order
(value*weight)*sf_inv vs value*(weight*sf_inv) produced occasional FP8
scale-factor mismatches, costing ~6 GSM8K points (0.890 vs 0.952) and
surfacing as multi-rank run-to-run nondeterminism. Fold the weight after
amax (weighted sf_inv) in the swap path to match non-swap; the L1 output
becomes bit-identical to non-swap and GSM8K recovers to ~0.95 at full
swap performance.
Keep the N32 L1 swapAB bucket avoidance: with the weight-fold bug fixed,
run_swap_ab_l1<32> is revealed to have a separate accuracy bug (N=32 ->
0.893 vs N=64 -> 0.953), so 25-32 token cases route to the <64> bucket.
Add a DG_SM90_FP4_SWAP_AB env kill-switch (default on) to force the
non-swap path for A/B accuracy comparison.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent b25bd49 commit e354e30
2 files changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
158 | 161 | | |
| 162 | + | |
159 | 163 | | |
160 | 164 | | |
161 | 165 | | |
| 166 | + | |
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
| |||
Lines changed: 7 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1945 | 1945 | | |
1946 | 1946 | | |
1947 | 1947 | | |
1948 | | - | |
1949 | 1948 | | |
| 1949 | + | |
1950 | 1950 | | |
1951 | 1951 | | |
| 1952 | + | |
1952 | 1953 | | |
1953 | 1954 | | |
1954 | 1955 | | |
| |||
1962 | 1963 | | |
1963 | 1964 | | |
1964 | 1965 | | |
1965 | | - | |
1966 | 1966 | | |
| 1967 | + | |
1967 | 1968 | | |
1968 | 1969 | | |
| 1970 | + | |
1969 | 1971 | | |
1970 | 1972 | | |
1971 | 1973 | | |
| |||
2047 | 2049 | | |
2048 | 2050 | | |
2049 | 2051 | | |
| 2052 | + | |
| 2053 | + | |
2050 | 2054 | | |
2051 | 2055 | | |
2052 | 2056 | | |
2053 | 2057 | | |
2054 | | - | |
| 2058 | + | |
2055 | 2059 | | |
2056 | 2060 | | |
2057 | 2061 | | |
| |||
0 commit comments