Repository navigation
Commit 023680c
committed
[JAX] EP overlap: support TE checkpoint (remat) names
The overlap path no longer rejects TE checkpoint names. The forward tags the
residuals of the fused dispatch+FC1 call (routing state, received tokens and
their MXFP8 scales, received routing weights, per-expert counts, the FC1
output and, for BF16, the SwiGLU output) with checkpoint_name; the wo name
tags nothing because the overlap backward does not read FC2's output. Under a
names-based remat policy JAX rebuilds unsaved residuals by re-running only the
fused dispatch+FC1 call; FC2+combine is never re-run (no separate recompute
path).
A re-run dispatch can place the received rows in a different order, so mixing
saved and rebuilt residuals corrupts the gate and input gradients (measured:
relative error ~1). Every fused-call residual therefore carries all given
names (dispatch, wi_0, wi_1), nested, and is saved when the policy saves any
of them: a mixed policy saves all of them, otherwise all are rebuilt.
_MoEBlock gains wi_0/wi_1/wo_checkpoint_name (forwarded to moe()).
Tests (tests/jax/test_te_ep_moe.py, 4x GB300, EP2xFSDP2, unfused mode):
test_ep_remat_policy over BF16/MXFP8 x policies {wo saved (MaxText custom
remat), nothing saved, dispatch+wo, wi+wo}: overlap loss and gradients match
the un-rematerialized flag-off step; compiled HLO has 2x
te_ep_dispatch_gemm_fwd_ffi when no fused-call name is saved (1x otherwise)
and 1x each other overlap call. The flag-off path is checked only with
everything rematerialized: with saved residuals and a re-run dispatch it shows
the same row-order mismatch (pre-existing, not changed here).
`-k "overlap or remat or checkpoint"`: 63 passed, 29 skipped.
DeepSeek-V3 MaxText proxy (4x GB300, EP4, 1 dense + 4 MoE layers, FP8 dense
+ MXFP8 MoE, pdb 6 x seq 4096, GA 2, custom remat: dispatch and moe_mlpwi
remat, moe_mlpwo saved): the compiled train step has
te_ep_dispatch_gemm_fwd_ffi x16, te_ep_combine_gemm_fwd_ffi x8 and each
backward call x8 (4 layers x 2 microbatches: dispatch+FC1 re-run once per
layer, FC2+combine not re-run). With the overlap on (+ native layouts) vs
off: step 0.991 vs 1.090 s (-9.0%), LHS estimate 98.2 vs 107.7 GiB, peak
159.5 vs 169.7 GiB, losses within 0.004 over 24 steps.
Depends on upstream PR NVIDIA#3906.
Signed-off-by: Deep Patel <deepatel@nvidia.com>1 parent 6cce050 commit 023680c
3 files changed
Lines changed: 130 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| 433 | + | |
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
439 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
440 | 444 | | |
441 | 445 | | |
442 | 446 | | |
| |||
1279 | 1283 | | |
1280 | 1284 | | |
1281 | 1285 | | |
1282 | | - | |
1283 | 1286 | | |
1284 | 1287 | | |
1285 | 1288 | | |
| |||
1303 | 1306 | | |
1304 | 1307 | | |
1305 | 1308 | | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
1306 | 1390 | | |
1307 | 1391 | | |
1308 | 1392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
119 | 122 | | |
120 | 123 | | |
121 | 124 | | |
| |||
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
| |||
403 | 409 | | |
404 | 410 | | |
405 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
406 | 415 | | |
407 | 416 | | |
408 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1621 | 1621 | | |
1622 | 1622 | | |
1623 | 1623 | | |
| 1624 | + | |
| 1625 | + | |
1624 | 1626 | | |
1625 | 1627 | | |
1626 | 1628 | | |
| |||
2204 | 2206 | | |
2205 | 2207 | | |
2206 | 2208 | | |
2207 | | - | |
2208 | 2209 | | |
2209 | 2210 | | |
2210 | 2211 | | |
| |||
2237 | 2238 | | |
2238 | 2239 | | |
2239 | 2240 | | |
2240 | | - | |
2241 | | - | |
2242 | 2241 | | |
2243 | 2242 | | |
2244 | 2243 | | |
| |||
2380 | 2379 | | |
2381 | 2380 | | |
2382 | 2381 | | |
| 2382 | + | |
| 2383 | + | |
2383 | 2384 | | |
2384 | 2385 | | |
2385 | 2386 | | |
2386 | 2387 | | |
2387 | 2388 | | |
2388 | | - | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
| 2393 | + | |
| 2394 | + | |
| 2395 | + | |
| 2396 | + | |
| 2397 | + | |
| 2398 | + | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
2389 | 2402 | | |
2390 | 2403 | | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
2391 | 2412 | | |
2392 | 2413 | | |
2393 | 2414 | | |
| |||
2474 | 2495 | | |
2475 | 2496 | | |
2476 | 2497 | | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
2477 | 2501 | | |
2478 | 2502 | | |
2479 | 2503 | | |
| |||
2798 | 2822 | | |
2799 | 2823 | | |
2800 | 2824 | | |
2801 | | - | |
| 2825 | + | |
2802 | 2826 | | |
2803 | 2827 | | |
2804 | | - | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
2805 | 2835 | | |
2806 | 2836 | | |
2807 | 2837 | | |
| |||
2913 | 2943 | | |
2914 | 2944 | | |
2915 | 2945 | | |
2916 | | - | |
2917 | | - | |
2918 | | - | |
2919 | | - | |
2920 | | - | |
2921 | | - | |
2922 | 2946 | | |
2923 | 2947 | | |
2924 | 2948 | | |
| |||
0 commit comments