Repository navigation
Commit f343ede
authored
[Sgl Atom][fix] GDN target verify: zero padded rows in the batched recurrence (#3552)
* plugin/sglang: zero padded rows in batched GDN target verify
With ReplaySSM off, CUDA-graph pad rows (mamba cache index -1) return
early in the conv, so their q/k/v hold whatever torch.empty returned.
The batched fused_recurrent call still ran them through the arange slot
table and could write NaN into core_attn_out. Pass slot -1 for those
rows so fused_recurrent zeroes their output and skips their state, as
it does elsewhere. Real rows are unchanged.
Also fix the host comment in causal_conv1d_update: only the read table
is checked for pad_slot_id, so a row padded in the write table must
also be padded in the read table. This matches the docstring and the
kernel comment.
Add a GPU test that fills the pad rows' q/k/v with NaN and checks that
pad rows come out zero and real rows match an unpadded run bit for bit,
for both the VK and logical-KV state layouts.
* plugin/sglang: check pad rows' skipped state in batched GDN verify test
Address review on #3552:
- The pad-row test now asserts that the kernel leaves the pad rows'
intermediate_ssm steps 1.. untouched (zero). Step 0 holds the host
seed ssm_states[-1] and is not checked. Without this, keeping the
arange slot table and zeroing pad outputs on the host passed the test.
- _spec_ssm_slot_table: the table is built once per shape and never
mutated; the kernel gets the pad-masked copy.
- Test module docstrings no longer call this the default verify path:
with MTP, ReplaySSM is the default and this path runs only with
ATOM_ENABLE_REPLAYSSM=0. The module now sets that for every test
instead of relying on the absence of server args.
* plugin/sglang: drop "default" from batched GDN verify test names
Address the second review on #3552:
- Rename test_default_batched_path_populates_verify_buffers and
test_default_ssm_path_uses_one_kernel_call to test_batched_*: this
path is not the default. test_default_conv_path_* keep their names,
since ReplaySSM also goes through _spec_conv_qkv.
- The module docstring credits ReplaySSM's default to any speculative
algorithm (MTP, DFLASH, ...), not just MTP.
* plugin/sglang: fix stale GDN verify comments in attention_gdn
Address the third review on #3552, comments and docstrings only:
- _verify_batched_ssm: cite test_gdn_target_verify_batched_equiv.py for
equivalence with the per-step loop; test_sglang_gdn_verify_batched_ssm.py
checks the plugin contract (buffers, live state, one kernel call, pad
rows). Say the live SSM state is only read.
- _build_gdn_metadata: TARGET_VERIFY runs SGLangGatedDeltaNet's own conv +
SSM verify (ReplaySSM, or the batched path with ATOM_ENABLE_REPLAYSSM=0)
and needs no native GDN metadata.
- SGLangGatedDeltaNet class docstring: it no longer fills SGLang's verify
snapshots; name the two verify paths.
- _spec_conv_window_phys: state what the single call writes instead of
what it replaced.
- test_batched_ssm_leaves_live_state_untouched: state the constraint, not
the history.
* plugin/sglang: fix remaining stale GDN verify docstrings and error text
Address the fourth review on #3552, text only:
- _conv_per_step_loop: it is the removed production path, retained as a
test-only numerical reference.
- causal_conv1d_update docstring: it returns (query, key, value), not an
`out` shaped like `x`; padded entries' rows are left unwritten.
- _spec_conv_window_phys errors no longer say "batched TARGET_VERIFY":
the default ReplaySSM path raises them too.
* Clarify GDN verify coverage and check per-step buffer contents
Check nonzero intermediate SSM and conv contents for every live request
at steps 1..draft-1, excluding the host-seeded SSM step zero. Distinguish
these forward-path checks from the isolated batched-versus-loop kernel
comparison and remove its vacuous live-state test.
Use algorithm-neutral TARGET_VERIFY wording and align conv docstrings
with the split q/k/v outputs, read-side pad check, and single-token
non-varlen input contract.
* docs: correct GDN verify state layout and pointer labels
Name the pad-test cases plain KV and FlyDSL logical KV. Document the
query/key and value pointer dimensions separately.1 parent 6d2f713 commit f343ede
4 files changed
Lines changed: 170 additions & 92 deletions
File tree
- atom
- model_ops/mamba_ops
- plugin/sglang/attention_backend
- tests/plugin
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
120 | | - | |
121 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| |||
658 | 658 | | |
659 | 659 | | |
660 | 660 | | |
661 | | - | |
662 | | - | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
663 | 664 | | |
664 | 665 | | |
665 | 666 | | |
| |||
672 | 673 | | |
673 | 674 | | |
674 | 675 | | |
675 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
676 | 680 | | |
677 | 681 | | |
678 | 682 | | |
| |||
725 | 729 | | |
726 | 730 | | |
727 | 731 | | |
728 | | - | |
| 732 | + | |
729 | 733 | | |
730 | 734 | | |
731 | 735 | | |
| |||
837 | 841 | | |
838 | 842 | | |
839 | 843 | | |
840 | | - | |
| 844 | + | |
841 | 845 | | |
842 | 846 | | |
843 | 847 | | |
| |||
858 | 862 | | |
859 | 863 | | |
860 | 864 | | |
861 | | - | |
862 | | - | |
863 | | - | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
864 | 868 | | |
865 | 869 | | |
866 | 870 | | |
| |||
960 | 964 | | |
961 | 965 | | |
962 | 966 | | |
963 | | - | |
| 967 | + | |
| 968 | + | |
964 | 969 | | |
965 | 970 | | |
966 | 971 | | |
| |||
1243 | 1248 | | |
1244 | 1249 | | |
1245 | 1250 | | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
1249 | 1255 | | |
1250 | 1256 | | |
1251 | 1257 | | |
| |||
1285 | 1291 | | |
1286 | 1292 | | |
1287 | 1293 | | |
1288 | | - | |
1289 | | - | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
1290 | 1297 | | |
1291 | 1298 | | |
1292 | | - | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1293 | 1303 | | |
1294 | 1304 | | |
1295 | 1305 | | |
| |||
1329 | 1339 | | |
1330 | 1340 | | |
1331 | 1341 | | |
1332 | | - | |
1333 | | - | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1334 | 1346 | | |
1335 | 1347 | | |
1336 | 1348 | | |
| |||
1339 | 1351 | | |
1340 | 1352 | | |
1341 | 1353 | | |
1342 | | - | |
1343 | | - | |
| 1354 | + | |
| 1355 | + | |
1344 | 1356 | | |
1345 | 1357 | | |
1346 | 1358 | | |
| |||
1362 | 1374 | | |
1363 | 1375 | | |
1364 | 1376 | | |
1365 | | - | |
1366 | 1377 | | |
1367 | 1378 | | |
1368 | 1379 | | |
| |||
1375 | 1386 | | |
1376 | 1387 | | |
1377 | 1388 | | |
1378 | | - | |
| 1389 | + | |
1379 | 1390 | | |
1380 | 1391 | | |
1381 | 1392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
| 450 | + | |
450 | 451 | | |
451 | 452 | | |
452 | 453 | | |
| |||
480 | 481 | | |
481 | 482 | | |
482 | 483 | | |
483 | | - | |
484 | | - | |
| 484 | + | |
485 | 485 | | |
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
489 | | - | |
490 | | - | |
| 489 | + | |
491 | 490 | | |
492 | 491 | | |
493 | 492 | | |
494 | | - | |
495 | | - | |
496 | | - | |
| 493 | + | |
497 | 494 | | |
498 | 495 | | |
499 | 496 | | |
500 | 497 | | |
501 | 498 | | |
502 | | - | |
| 499 | + | |
503 | 500 | | |
504 | 501 | | |
505 | 502 | | |
| |||
526 | 523 | | |
527 | 524 | | |
528 | 525 | | |
529 | | - | |
| 526 | + | |
| 527 | + | |
530 | 528 | | |
531 | 529 | | |
532 | 530 | | |
| |||
692 | 690 | | |
693 | 691 | | |
694 | 692 | | |
695 | | - | |
696 | | - | |
| 693 | + | |
| 694 | + | |
697 | 695 | | |
698 | 696 | | |
699 | 697 | | |
| |||
734 | 732 | | |
735 | 733 | | |
736 | 734 | | |
737 | | - | |
| 735 | + | |
738 | 736 | | |
739 | 737 | | |
740 | 738 | | |
741 | 739 | | |
742 | | - | |
743 | | - | |
744 | | - | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
745 | 748 | | |
746 | 749 | | |
747 | 750 | | |
| |||
765 | 768 | | |
766 | 769 | | |
767 | 770 | | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
768 | 775 | | |
769 | 776 | | |
770 | 777 | | |
| |||
791 | 798 | | |
792 | 799 | | |
793 | 800 | | |
794 | | - | |
| 801 | + | |
795 | 802 | | |
796 | 803 | | |
797 | 804 | | |
| |||
867 | 874 | | |
868 | 875 | | |
869 | 876 | | |
870 | | - | |
| 877 | + | |
871 | 878 | | |
872 | | - | |
873 | | - | |
| 879 | + | |
| 880 | + | |
874 | 881 | | |
875 | 882 | | |
876 | 883 | | |
877 | | - | |
878 | | - | |
| 884 | + | |
879 | 885 | | |
880 | 886 | | |
881 | 887 | | |
882 | 888 | | |
883 | | - | |
| 889 | + | |
884 | 890 | | |
885 | 891 | | |
886 | 892 | | |
| |||
894 | 900 | | |
895 | 901 | | |
896 | 902 | | |
897 | | - | |
| 903 | + | |
898 | 904 | | |
899 | 905 | | |
900 | 906 | | |
| |||
1087 | 1093 | | |
1088 | 1094 | | |
1089 | 1095 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1093 | 1100 | | |
1094 | 1101 | | |
1095 | 1102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| |||
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
53 | | - | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
217 | 222 | | |
218 | 223 | | |
219 | 224 | | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | 225 | | |
231 | 226 | | |
232 | 227 | | |
| |||
260 | 255 | | |
261 | 256 | | |
262 | 257 | | |
263 | | - | |
| 258 | + | |
| 259 | + | |
264 | 260 | | |
265 | 261 | | |
266 | 262 | | |
| |||
438 | 434 | | |
439 | 435 | | |
440 | 436 | | |
441 | | - | |
| 437 | + | |
442 | 438 | | |
443 | 439 | | |
444 | 440 | | |
| |||
0 commit comments