Repository navigation
Commit 1e6f61f
Add NVIDIA Nemotron Parse 2.0 support (#473)
## Summary
Add end-to-end support for `nvidia/NVIDIA-Nemotron-Parse-2.0`
(`model_type: nemotron_parse`) as a two-model image-to-text package.
### Architecture
- C-RADIOv2-H vision backbone: linear patch projection emitted as Conv,
cropped CPE positions, eight register/teacher tokens, 32 ViT-H blocks,
and three flattened teacher summaries.
- Nemotron feature neck: 1280→1024 projection, horizontal 1×4
convolutional compression, summary-token projection, and LayerNorms.
- Position-free scaled-embedding mBART decoder: 10 pre-norm
self/cross-attention layers, causal self KV cache, exact GELU FFN, tied
LM head.
- Standardized package keys: `vision_encoder` and `decoder`.
- Vision graph accepts the official processor's float32 pixels and casts
internally for f16/bf16 weights.
- Config/registry/task wiring, Conv2d asymmetric kernels, CLI/runtime
guard, real document fixture, L1-L5 tests, and committed real-image
goldens.
## Validation
GPU: **NVIDIA RTX A1000, 8188 MiB, driver 573.44**. CUDA runs explicitly
requested `CUDAExecutionProvider`; sessions reported
`['CUDAExecutionProvider', 'CPUExecutionProvider']` (CPU is retained for
ORT shape operations).
| Gate | Exact result |
|---|---|
| L1 graph | `4 passed, 1350 deselected in 8.74s` |
| Weight alignment | `1 passed, 226 deselected in 8.80s` |
| L2 YAML schema | `237 passed in 1.94s` |
| L3 synthetic fp32 parity | `1 passed, 203 deselected in 7.43s` at
`rtol=atol=1e-3` (ONNX vision output fed to ONNX decoder) |
| Real-image BF16 HF/ONNX CUDA parity | `1 passed, 122 deselected in
71.49s` (74.683s wall); encoder cosine >0.99, logits cosine >0.995,
identical argmax |
| L4 + deterministic L5 CUDA | `2 passed, 377 deselected in 103.13s`
(106.441s wall); real nonzero image, exact L4 top-1 and exact 24-token
L5 golden |
| Regression suite | `3638 passed, 57 skipped in 47.45s` |
| Lint | initialized `lintrunner`; `lintrunner -a`: `ok No lint issues`
|
| Automated review | final code-review agent: no significant issues |
### CUDA CLI and dtype matrix
All three exports used `mobius build --model
nvidia/NVIDIA-Nemotron-Parse-2.0 --trust-remote-code --dtype <dtype>
--ep cuda` and produced `vision_encoder/model.onnx` plus
`decoder/model.onnx`.
- **bf16:** export 52.083s; saved package 1,806,874,350 bytes; float32
processor input; vision load+run 5.631s, decoder load+prefill 1.664s;
golden top-1 `50251` matched.
- **f16:** export 51.423s; full CUDA load+prefill 8.032s; golden top-1
`50251` matched.
- **f32:** export 51.346s; saved package 3,613,010,525 bytes; full CUDA
load+prefill 24.155s; golden top-1 `50251` matched.
### Olive
Olive 0.13.0 `OnnxBnb4Quantization` NF4 quantized the final f16 decoder
successfully in 29.320s (237,677,671-byte model). CUDA generation
produced 24 non-degenerate OCR tokens in 7.112s:
`# MOBIUS OCR VALIDATION ... Nemotron Parse 2.`
## Checklist
- [x] Microsoft/MIT headers, model docstrings, Multimodal metadata,
public component imports, no explicit protobuf APIs
- [x] Registry/export/task/config extraction and representative tiny
config
- [x] Identity weight alignment
- [x] L1 graph construction and L2 schema/config
- [x] L3 synthetic and real-weight parity
- [x] Real-image BF16 CUDA L4 golden
- [x] Deterministic greedy 24-token CUDA L5 golden
- [x] fp32/fp16/bf16 CUDA CLI exports and exact real-image top-1 match
- [x] CUDA CLI artifact reload/runtime
- [x] Olive NF4 quantization and non-degenerate CUDA generation
- [x] Initialized `lintrunner -a` clean
- [x] Final automated code review clean
## Narrow waivers / limitations
- **ORT GenAI:** waived. Installed ORT GenAI 0.15.2 has no generic
image-to-text vision-encoder-decoder pipeline/schema for this two-model
package (it is not the supported VLM decoder+embedding+vision contract).
Emitting a `genai_config.json` would create an unloadable artifact, so
export explicitly raises `NotImplementedError`; the guard test passed
(`1 passed, 76 deselected in 7.08s`). Direct ONNX CUDA runtime is fully
validated above.
- **Foundry Local:** waived. Foundry Local 0.10.2 consumes ORT GenAI
packages and therefore cannot load this package without the unsupported
GenAI configuration above. The installed CLI was checked; fabricating
registration metadata would not make the image-to-text pipeline
executable.
- **Cross-attention projection cache:** the shared
`EncoderDecoderAttention` contract currently recomputes encoder K/V
projections per decode token. Adding a lazy cross-cache requires a
broader split-prefill/decode redesign; this is a performance limitation,
not a correctness gap, and the exact 24-token CUDA L5 run passes.
## Baseline note
Before validation, `.pytest_cache/v/cache/lastfailed` contained only
`tests/synthetic_parity_test.py::test_synthetic_parity[granitemoehybrid]`.
That cached unrelated baseline was not treated as a Nemotron failure;
targeted Nemotron parity and the full non-integration regression suite
pass as reported above.
### Post-push CI baseline status
The repository-wide GitHub matrix and L3 jobs currently fail only the
untouched `bamba_0`/`bamba_1` synthetic cases on every Python/OS matrix
entry (`max_abs_diff=0.001375` / `0.001662`, argmax matches, cosine
≥0.999996). Nemotron's affected-model L1 job passes, and its targeted
local L1-L5 results are above. The benchmark-base job separately failed
while finalizing an artifact with GitHub `403 Forbidden`; benchmark head
passed. These unrelated failures are not masked or changed in this PR.
---------
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: justinchuby <[email protected]>
Co-authored-by: Copilot App <[email protected]>1 parent a2e0ab7 commit 1e6f61f
26 files changed
Lines changed: 1629 additions & 20 deletions
File tree
- scripts
- src/mobius
- _configs
- components
- integrations/ort_genai
- models
- tasks
- testdata
- cases/vision-language
- golden/vision-language
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
539 | 539 | | |
540 | 540 | | |
541 | 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 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
542 | 622 | | |
543 | 623 | | |
544 | 624 | | |
| |||
1674 | 1754 | | |
1675 | 1755 | | |
1676 | 1756 | | |
| 1757 | + | |
1677 | 1758 | | |
1678 | 1759 | | |
1679 | 1760 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1282 | 1282 | | |
1283 | 1283 | | |
1284 | 1284 | | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 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 | + | |
1285 | 1380 | | |
1286 | 1381 | | |
1287 | 1382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
9 | 43 | | |
10 | 44 | | |
11 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
576 | 578 | | |
577 | 579 | | |
578 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
579 | 586 | | |
580 | 587 | | |
581 | 588 | | |
| |||
892 | 899 | | |
893 | 900 | | |
894 | 901 | | |
| 902 | + | |
895 | 903 | | |
896 | 904 | | |
897 | 905 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| 269 | + | |
268 | 270 | | |
269 | 271 | | |
270 | 272 | | |
| |||
0 commit comments