Repository navigation
Commit 5028076
feat(deepseek-v4): defer block-quant reject for native CSA, gate runnable export on nxrt runtime capability
Rebased #593 (native pkg.nxrt::CompressedSparseAttention export, ratio-4 CSA +
ratio-128 HCA) onto Mobius main now that #578 (6992181) and #602 (d16cd4a,
mobius.integrations._block_quant block-FP8 / packed-FP4 loading contract) are
merged. Consumes the merged _block_quant API directly; the temporary stacked
duplicate-parse branch is retired.
#602 rejects the block-scaled-FP8 + packed-FP4 DeepSeek-V4-Flash checkpoint at
config resolution (the INT4/per-tensor path cannot load it). That is correct
for a normal export, but it also blocks a native-CSA export before any graph
exists. Split the behavior into the two stages the directive requires:
* Non-native (default) export keeps #602's early, loud config-resolution
reject -- unchanged, its tests still pass.
* native_csa opts into DEFERRING that reject: ArchitectureConfig.from_transformers
catches the typed BlockQuantExportError, records the parsed block_quant_scheme
on the config, and lets graph construction PROGRESS past the former generic
"Weight shape mismatch" (build_from_module emits the CSA nodes + compressed
state IO). The runnable FULL EXPORT then fails closed at a runtime-capability
gate (assert_native_runtime_supports_block_quant, enforced at the top of
DeepSeekV4 preprocess_weights, before apply_weights) while nxrt cannot
execute block-FP8 / planar-FP4 weights. The gap string is sourced from
_block_quant.runtime_representation_gap, so the gate tracks the real nxrt
format strings and opens automatically when the native runtime slice lands
-- no change here. Never a silent dense fallback, never partial-native.
No BC shims: ArchitectureConfig gains a block_quant_scheme field; deepseek_v4.py
adds no FP8/FP4 weight parsing (delegates to _block_quant). No performance claim
-- ratio-4 sparse execution and >=16-decode remain blocked on the unmerged
native block-FP8 / planar-FP4 runtime.
Tests (deepseek_v4_flash_test.py, 45 pass): non-native fail-closed at config
resolution; fp4-experts-alone owned; native_csa defers (scheme recorded, quant
None); full export typed-rejects at the runtime-capability gate; graph
construction progresses past block-quant (CSA node built); preprocess_weights
enforces the gate; property-gated not a blanket V4/native_csa refusal;
per-tensor fp8 not over-owned. #602 (_block_quant_test) + config
(_base_test/_extractors_test) suites unchanged (69 pass).
Co-authored-by: Copilot <[email protected]>1 parent db491a3 commit 5028076
4 files changed
Lines changed: 435 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
25 | 29 | | |
26 | 30 | | |
27 | 31 | | |
| |||
631 | 635 | | |
632 | 636 | | |
633 | 637 | | |
634 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
635 | 648 | | |
636 | 649 | | |
637 | 650 | | |
| |||
1207 | 1220 | | |
1208 | 1221 | | |
1209 | 1222 | | |
1210 | | - | |
1211 | | - | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
1212 | 1245 | | |
1213 | 1246 | | |
1214 | 1247 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
414 | 422 | | |
415 | 423 | | |
416 | 424 | | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
417 | 544 | | |
418 | 545 | | |
419 | 546 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
1403 | 1404 | | |
1404 | 1405 | | |
1405 | 1406 | | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1406 | 1414 | | |
1407 | 1415 | | |
1408 | 1416 | | |
| |||
0 commit comments