Commit 32110a9
authored
Preserve AutoEP score correction bias buffers (#8369)
## Summary
Fix AutoEP replacement silently dropping `e_score_correction_bias` when
Hugging Face models register it as a buffer or place it somewhere other
than the router module expected by the preset.
The parser now records the bias owner's actual path inside each MoE
layer. Replacement then copies the bias while preserving whether it is
an `nn.Parameter` or registered buffer, including the buffer's
persistence setting.
The implementation supports locations such as:
- `gate`
- the MoE block itself
- `router`
- nested modules such as `gate.moe_statics`
Ambiguous layers containing more than one `e_score_correction_bias` are
rejected rather than selecting one silently. Unsupported
non-parameter/non-buffer values produce a warning.
## Validation
- Full AutoEP unit test file: `103 passed`
- All pre-commit hooks passed
- Tested with a real Transformers 5.15.1 `DeepseekV3MoE`
- GPU validation environment:
- NVIDIA GeForce RTX 5090
- PyTorch 2.8.0+cu128
- Transformers 5.15.1
- DeepSpeed 0.19.6
- The replacement preserved the CUDA registered buffer and its value
- Native and EP2 replacement routing selected the same experts
- Single-GPU full MoE forward comparison had a maximum absolute
difference of `0.0`
The available validation machine has one GPU, so a multi-GPU
collective/ZeRO-3 end-to-end run was not performed.
Fixes #8358
Signed-off-by: poorpaper <43514747+poorpaper@users.noreply.github.com>1 parent 05daf05 commit 32110a9
4 files changed
Lines changed: 109 additions & 6 deletions
File tree
- deepspeed/module_inject
- auto_ep_presets
- tests/unit/v1/moe
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
85 | 98 | | |
86 | 99 | | |
87 | 100 | | |
| |||
413 | 426 | | |
414 | 427 | | |
415 | 428 | | |
| 429 | + | |
416 | 430 | | |
417 | 431 | | |
418 | 432 | | |
| |||
472 | 486 | | |
473 | 487 | | |
474 | 488 | | |
| 489 | + | |
475 | 490 | | |
476 | 491 | | |
477 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
88 | 115 | | |
89 | 116 | | |
90 | 117 | | |
| |||
398 | 425 | | |
399 | 426 | | |
400 | 427 | | |
401 | | - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
402 | 436 | | |
403 | 437 | | |
404 | 438 | | |
| |||
434 | 468 | | |
435 | 469 | | |
436 | 470 | | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
| 471 | + | |
| 472 | + | |
442 | 473 | | |
443 | 474 | | |
444 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1308 | 1308 | | |
1309 | 1309 | | |
1310 | 1310 | | |
| 1311 | + | |
1311 | 1312 | | |
| 1313 | + | |
1312 | 1314 | | |
1313 | 1315 | | |
1314 | 1316 | | |
| |||
1317 | 1319 | | |
1318 | 1320 | | |
1319 | 1321 | | |
| 1322 | + | |
1320 | 1323 | | |
1321 | 1324 | | |
1322 | 1325 | | |
| |||
1333 | 1336 | | |
1334 | 1337 | | |
1335 | 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 | + | |
| 1390 | + | |
| 1391 | + | |
1336 | 1392 | | |
1337 | 1393 | | |
1338 | 1394 | | |
| |||
0 commit comments