Repository navigation
fix(engine): accept Cast-backed QMoE scales - #771
Conversation
Trace one-hop Cast(initializer) inputs when planning static QMoE weight placement so DeepSeek-V2-Lite's fp16 scale initializers cast to fp32 remain placement-classifiable. Includes the native KV reservation cap prerequisite needed for the real DeepSeek decode lock. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #771 +/- ##
==========================================
- Coverage 79.88% 79.36% -0.53%
==========================================
Files 331 331
Lines 137462 137462
Branches 137462 137462
==========================================
- Hits 109812 109096 -716
- Misses 23306 24026 +720
+ Partials 4344 4340 -4
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Treat usize::MAX CUDA KV capacity as unbounded rather than reservable so models without a declared max context retain the warning-and-load behavior. Keep finite runtime caps preferred over metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔴 Benchmark Regression DetectedComparison of criterion micro-benchmarks: PR head vs merge-base, measured on the same runner in the same job (base first → PR second).
Visual flags: Host infoWhat this cannot catch
|
## Summary - gate the native KV reservation helper behind `native-backend` - gate the four helper-specific unit tests the same way - fixes ORT-only CLI clippy dead_code from #770/#771 ## Validation - Reproduced before fix: `cargo clippy --locked -p onnx-genai-cli --all-targets -- -D warnings` failed with dead_code on `native_kv_reservation_max_context` - After fix: `cargo clippy --locked -p onnx-genai-cli --all-targets -- -D warnings` - After fix: `cargo clippy --locked -p onnx-genai-engine --no-default-features --features cuda-13000 -- -D warnings` - After fix: `CUDA_VISIBLE_DEVICES=2 LD_LIBRARY_PATH=/home/tlwu/cudnn9.19_cuda13/lib:$LD_LIBRARY_PATH cargo clippy -p onnx-genai-engine --features "cuda native-backend" -- -D warnings` - `cargo fmt --all` Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Why not constant cast first? |
…-27B native CUDA (#779) ## Summary Enables **Qwen/Qwen3.6-27B** (`model_type: qwen3_5`, hybrid GDN `LinearAttention`/`CausalConvWithState` + periodic `GroupQueryAttention` + int4 `MatMulNBits`) to load and decode on the **native CUDA EP**, byte-exact vs an fp32 oracle. This was the last model the ORT-vs-native benchmark flagged as _"Unsupported native load: model needs unsupported native operators"_. ## Root cause (not a kernel gap, not a bad graph) The 27B `model.onnx` is a **correct** hybrid graph — 64 layers = 48 GDN linear-attention layers (`conv_state`/`recurrent_state`) + 16 periodic full-attention layers (dense `key`/`value`) — and the native kernels already exist. The blocker is the artifact's **thin `inference_metadata.yaml`**: it declares only `grouped_query_attention` and **no `io` port contract**. On the native load path the Resource Governor derives per-layer KV page byte geometry from `model.io.kv_inputs`/`kv_outputs`; with no `io` block `resolve_kv_layers` returns `None` (it deliberately never guesses KV pairing from tensor names), so load failed with `cannot derive the KV memory budget because per-layer KV page geometry is unknown`. ## Fix (DRY, attribute/shape-driven — no model-name gate) The native loader now auto-derives the decoder `io` port contract from the ONNX graph's own port inventory when the sidecar declares none, via `GenAiConfig::derive_decoder_io_from_graph` — the exact proven derivation the native decode step driver already uses in `derive_fallback_io`. New helper `maybe_fill_hybrid_io_from_graph` (`engine/load.rs`) fills the sparse dense `kv_inputs`/`kv_outputs` + fixed recurrent `state_pairs` (and token/mask/ position/logits port names by presence). It is gated on a non-empty derived `state_pairs` (the recurrent-hybrid case shape inference cannot classify); a declared `io` block always wins and pure-dense decoders are untouched. Added `Default` to `ModelCapabilities` so the derived spec can attach when `model` is absent. This makes **all** future hybrid GDN models with a correct graph but thin metadata auto-run the optimal native path. ## Validation (H200) - Native-CUDA fp16 greedy of `"The capital of France is"` → `[11751, 13, 271, 248068, 271, 248069, 271, 4639]` = `" Paris.\n\n<think>\n\n</think>\n\nThat"` (coherent). - Teacher-forced next token (fresh engine): native-CUDA fp16 = **11751** " Paris" (logprob −0.6080). - **fp32 oracle** (fp16→fp32 up-conversion, int4 preserved, native CPU) teacher-forced argmax = **11751** " Paris" (logprob −0.6100, top-1 margin **2.549** nats). Byte-exact parity ✅ — fp16/fp32 logits near-identical. Locked by `crates/onnx-genai-engine/tests/qwen35_27b_hybrid_native_cuda_e2e.rs` (ignored; env `QWEN35_27B_DIR`, `QWEN35_27B_FP32_ORACLE_DIR`), mirroring the 35B QMoE oracle lock. 🤖 Working as Cohaagen (native-model-enablement). Follows the GLM (#770) / DeepSeek-V2-Lite (#771) playbook. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…detail (#825) Justin asked to update `docs/PROGRESS.md` with the latest progress and drop stale info. It had grown to **1166 lines** of day-by-day changelog spanning 2026-07-15 → 2026-07-27, with the entire recent arc missing. ## Changes (1166 → 303 lines) - **Added recent milestones (2026-07-28 → 2026-08-12), newest-first:** - EP plugins run inside ORT via the plugin-EP C ABI (#762) and ship on PyPI — **`nxrt-ep-cpu` + `nxrt-ep-cuda` 0.1.0.dev5 both LIVE** (#819/#824/#820). - Absent-optional-output memory-safety wave (#762 review; Miri-clean). - VMM / KV-layout / offload / batching residency wave — managed no-spill VMM default, layout-governed KV floor (768× reduction), offload+capture coexist, #736 over-reservation audit (#755–#814). - Issue triage + autonomous fixes (#784/#785/#786/#788/#789); CPU-EP TopK correctness+perf (#774/#775). - Qwen3.5/3.6-27B hybrid Gated-DeltaNet native CUDA (#779); GLM-4-9B + DeepSeek-V2-Lite native + ORT 1.28 3-config fairness (#766/#770/#771). - Fused QMoE decode kernel + QMoE arc concluded; CUDA-graph capture trilogy, version-selectable CUDA (#708/#728/#757/#760), megakernel study (#769). - **Compressed stale detail:** the ~40 dated July day-by-day sections + verbose diffusion/LoRA/ORT2 narrative collapsed into a ~35-line "Foundational milestones" spine; superseded perf-wave numbers dropped; §1–§40 table condensed to a compact grid. - **Header refreshed:** last-updated → 2026-08-12; Published line now lists both EP plugins on PyPI + Miri CI. - **Preserved & updated** the DeepSeek/GLM known-gaps checklists and added new open items. Docs-only; full narrative remains in `.squad/decisions-archive/` and `docs/benchmarks/`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Validation
DeepSeek native CUDA token stream: [11, 304, 608, 245].