Commit 7154a00
Fix AutoTP metadata updates for unsharded modules (#8299)
## Summary
- defer module metadata updates until recursive AutoTP replacement has
completed
- update logical dimensions only when a subtree contains parameters
carrying AutoTP TP metadata
- preserve metadata for replicated vision modules and high-dimensional
weights while retaining existing sharded Linear behavior
- add regression coverage for PatchEmbed-style Conv3d wrappers,
unsharded attention subtrees, and genuinely sharded parameters
Fixes #8285.
## Problem
`update_mp_params()` previously ran before Linear replacement and scaled
logical attributes for every traversed module. In multimodal models this
changed replicated vision metadata, such as Qwen2-VL PatchEmbed
`embed_dim`, even though the corresponding Conv3d weight was not
partitioned. The metadata then disagreed with the full weight shape and
broke vision forward.
## Validation
Current master baseline `e70b90352e93e07862c45ebb946d75b813f025a2`
reproduces on 2-GPU NCCL with `patch_embed.embed_dim=60` while
`proj.out_channels=120`.
- CPU targeted: `7 passed, 20 deselected`
- 2-process Gloo metadata check: unsharded `num_heads=16`, sharded
`hidden_size=6` on both ranks
- 2-GPU custom-pattern suite: `27 passed`
- 4-GPU AutoTP/ZeRO adjacent suite: `33 passed, 2 skipped, 24
deselected`
- synthetic training on 1/2/3/5 RTX 3090 GPUs: forward, backward, and
optimizer step all complete with zero cross-rank output, PatchEmbed
gradient, and PatchEmbed parameter difference
- 5-GPU synthetic, 3 runs with 3 warmup and 20 measured steps each:
`5.008 ms` mean step latency, `409,216 tokens/s`, `28,170,752` peak
allocated bytes, `52,428,800` peak reserved bytes
- Qwen2-VL-2B AutoTP=2 vision forward: PatchEmbed `1280 -> 1280`, vision
heads `16 -> 16`, language q_proj `[1536,1536] -> [768,1536]`, zero
cross-rank output difference
- changed-file pre-commit hooks, `DS_BUILD_OPS=0 python setup.py check`,
`compileall`, and `git diff --check` pass
---------
Signed-off-by: Wang Zupeng <zupenwang@gmail.com>
Co-authored-by: Ma, Guokai <guokai.ma@gmail.com>1 parent eba5d27 commit 7154a00
2 files changed
Lines changed: 85 additions & 9 deletions
File tree
- deepspeed/module_inject
- tests/unit/model_parallelism
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
625 | 625 | | |
626 | 626 | | |
627 | 627 | | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
628 | 631 | | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
634 | 639 | | |
635 | 640 | | |
636 | 641 | | |
| |||
683 | 688 | | |
684 | 689 | | |
685 | 690 | | |
686 | | - | |
687 | 691 | | |
| 692 | + | |
688 | 693 | | |
689 | 694 | | |
690 | 695 | | |
| |||
732 | 737 | | |
733 | 738 | | |
734 | 739 | | |
735 | | - | |
736 | 740 | | |
| 741 | + | |
737 | 742 | | |
738 | 743 | | |
739 | 744 | | |
| |||
750 | 755 | | |
751 | 756 | | |
752 | 757 | | |
753 | | - | |
754 | 758 | | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
755 | 762 | | |
756 | 763 | | |
757 | 764 | | |
| |||
Lines changed: 70 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
496 | 497 | | |
497 | 498 | | |
498 | 499 | | |
| 500 | + | |
| 501 | + | |
499 | 502 | | |
500 | 503 | | |
501 | 504 | | |
| |||
515 | 518 | | |
516 | 519 | | |
517 | 520 | | |
| 521 | + | |
| 522 | + | |
518 | 523 | | |
519 | 524 | | |
520 | 525 | | |
| |||
529 | 534 | | |
530 | 535 | | |
531 | 536 | | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
532 | 601 | | |
533 | 602 | | |
534 | 603 | | |
| |||
0 commit comments