Repository navigation
helios: derive NVFP4 engram row and scale widths from embedding_width - #716
Merged
Merged
Conversation
Why: Helios's runtime-core engram table decoder hardcoded NVFP4 (`Nvfp4E4m3Global`) tables to a 160-element width (80 weight bytes and 10 scale bytes per row), matching Qwen3.8-Flash-Next (`ple_embed_dim=2560`, 16 heads). Qwen4-35B-A3B uses `ple_embed_dim=2048` across 16 heads (`embedding_width=128`, 64 weight bytes and 8 scale bytes per row), so core decoding rejected Qwen4-35B-A3B engram tables even though the protobuf metadata already carries `embedding_width`. What changed: In `helios/src/runtime_core/engram.rs`, `decode()` previously matched `Encoding::Nvfp4E4m3Global` to the fixed tuple `(160, 16, 80, 10)`. It now validates `table.embedding_width > 0 && table.embedding_width % 16 == 0` alongside the positive finite `global_scale` check and derives the row geometry `(width, 16, width / 2, width / 16)` from `table.embedding_width`. Added unit test `nvfp4_tables_accept_width_128_and_160_and_reject_unaligned_widths` covering valid widths 128 and 160 and rejecting 0, 8, and 120. Benefit: Existing 160-wide NVFP4 engram cores decode identically while 128-wide Qwen4-35B-A3B cores (and any other 16-aligned NVFP4 table width) load without model-specific runtime branches. Evidence: - `cargo check --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server` succeeded against `origin/main` (`45e1c1ad`). - Limitation: `cargo test --lib` on `origin/main` (`45e1c1ad`) currently fails to compile on an unrelated `Core` literal missing `external_extents` at `helios/src/runtime_core/cache_memory.rs:1659` (fixed separately in #714), so the new unit test was compile-checked via inspection and requires #714 on `main` for `cargo test` execution. Design-Signed-Off-By: Gemini 4 Neon; design-review=2e5b
Collaborator
|
A case file has been opened for 716. Future reviews will auto-run 90 minutes after code updates are pushed.
|
lukealonso
added a commit
to local-inference-lab/hyperflare-recipes
that referenced
this pull request
Dec 4, 2026
…B-A3B recipe (#154) Why: Qwen4-35B-A3B (`Qwen4MoeForConditionalGeneration`) uses the same hybrid GDN/QSA/HyperConnection/PLE/MoE/MTP execution architecture as Qwen3.8-Flash-Next (`Qwen4ExpForConditionalGeneration`), but with narrower dimensions: `hidden_size=2048` (4 streams -> residual width 8192), 40 layers (10 QSA + 30 GDN), 16/32 GDN heads, 16 attention heads, 256 routed experts of intermediate size 512 (`top_k=8`), `hc_lowrank=256`, `ple_embed_dim=2048` (128-wide NVFP4 engram rows across 128 planes of 1,250,028 rows), and 1,048,576 max position embeddings. Because `components/gated_delta.py` and the `recipes/qwen38/` modules hardcoded Qwen3.8's dimensions, Qwen4-35B-A3B checkpoints could not be validated, prepared, or exported without duplicating the recipe. What changed: - Added `hyperflare_recipes/recipes/qwen38/geometry.py` defining `QwenGeometry`, `QWEN38_GEOMETRY`, `QWEN4_35B_GEOMETRY`, `geometry_for_config`, and `adapt_qwen4_config_dict`. - Parameterized `components/gated_delta.py` (`GDNState`, `GDNScratch`, `_validate_geometry`, `PreparedGDN`) over `key_heads` and `value_heads` (defaulting to 16/48 for Qwen3.8). - Added `QWEN4_IMAGE_SPEC` (`model_type="qwen4_moe"`, `processor_class="Qwen4VLProcessor"`) to `components/image_specs.py`. - Parameterized `recipes/qwen38/` (`checkpoint`, `checkpoint_schema`, `bootstrap`, `attention`, `decoder`, `decoder_state`, `draft_state`, `hyperconnection`, `maintenance`, `mixed_model`, `mixed_state`, `model`, `moe`, `mtp`, `mtp_weights`, `ple`, `speculative_model`, `speculative_state`, `state`, `vision_state`, `weights`) over `QwenGeometry`, defaulting to `QWEN38_GEOMETRY` so Qwen3.8-Flash-Next behavior and layouts are unchanged. - Added `frontend_asset_path` (`tokenizer-compat/` fallback) and `_qwen4_template_asset` (stripping Jinja `generation` span tags and adding Helios `mark` turn boundaries) in `checkpoint.py` and `bootstrap.py`. - Registered `QWEN4_35B_RECIPE` (`qwen4_35b`, alias `qwen4-35b-a3b`, `served_model_name="Qwen4-35B-A3B"`) in `recipes/qwen38/recipe.py` and `recipes/__init__.py`, and updated `tests/cli/{test_models,test_mtp_only,test_planning}.py`. Benefit: Supports Qwen4-35B-A3B preparation (TP 1/2/4, MTP depth up to 7, vision, mixed prefill, prompt logprobs) by reusing the existing Qwen3.8 execution stack and b12x operators with zero code duplication. Evidence: - `pytest tests/cli/test_models.py tests/cli/test_mtp_only.py tests/cli/test_planning.py -k "qwen4 or qwen38"` -> 13 passed (covering recipe registration, `PreparationConfig` inheritance and shared plan field forwarding, `--mtp-only` adapter preservation, and planning defaults for both `qwen38` and `qwen4_35b`). - Limitations: requires NVIDIA/hyperflare-inference#716 (128-wide NVFP4 engram decoding in Helios) and local-inference-lab/flashinfer `feat/qwen4-2048` (`H=2048` HyperConnection/MTP feedback and 2:1 GDN head ratio in b12x) to be merged and pinned in `uv.lock`. Full-checkpoint `ignition export` and live `flare run` serving were not re-run in this commit pass. Design-Signed-Off-By: Gemini 4 Neon; design-review=6fcc
kbenkhaled
added a commit
to kbenkhaled/hyperflare-inference
that referenced
this pull request
Dec 4, 2026
Resolve merge conflicts against origin/main (0a0158b) so PR NVIDIA#664 merges cleanly without rewriting prior PR history. Changes in merge resolution: - helios/src/runtime_core/engram.rs: preserve NVIDIA#716's dynamic embedding_width NVFP4 row/scale geometry alongside BF16 single-plane decoding, adapt NVIDIA#716's new unit test to Planes.{weights,scales}, and populate NVIDIA#711's new async_transfers/external_extents fields in PR NVIDIA#664's test fixture. - heliopause/src/export/core.rs: populate NVIDIA#711's external_extents field in PR NVIDIA#664's RankOutput test literal. - ignition/preparation/runtime_core_pb2.py: regenerate from the cleanly merged helios/proto/runtime_core.proto. Validation (Jetson AGX Thor SM110): - cargo check --locked --manifest-path helios/Cargo.toml --features runtime-core,server: passed. - cargo test --manifest-path heliopause/Cargo.toml --lib engram: 7 passed, 0 failed. - cargo check --tests --manifest-path helios/Cargo.toml --features runtime-core: zero errors in engram.rs (only unrelated upstream origin/main cache_memory.rs:1659 missing external_extents noted in NVIDIA#716). - pytest tests/preparation/test_embedding_table_handoff.py tests/preparation/test_frontend_spec.py tests/cli/test_config.py: 82 passed, 0 failed. Design-Signed-Off-By: Gemini 4 Neon; design-review=2e5b Signed-off-by: kbenkhaled <kbenkhaled@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Helios's runtime-core engram decoder hardcoded
Encoding::Nvfp4E4m3Globaltables to a 160-element width (80 weight bytes and 10 scale bytes per row), matching Qwen3.8-Flash-Next (ple_embed_dim=2560, 16 heads). Qwen4-35B-A3B usesple_embed_dim=2048across 16 heads (embedding_width=128, 64 weight bytes and 8 scale bytes per row), causing core decoding to reject Qwen4-35B-A3B engram tables even though the protobuf metadata already specifiesembedding_width.What changed
helios/src/runtime_core/engram.rs,decode()previously matchedEncoding::Nvfp4E4m3Globalto the fixed geometry(160, 16, 80, 10).decode()now validatestable.embedding_width > 0 && table.embedding_width % 16 == 0alongside the positive finiteglobal_scalecheck, and derives(width, 16, width / 2, width / 16)fromtable.embedding_width.nvfp4_tables_accept_width_128_and_160_and_reject_unaligned_widthsverifying acceptance of widths 128 and 160 and rejection of 0, 8, and 120.Claimed benefit
Existing 160-wide NVFP4 engram cores decode identically while 128-wide Qwen4-35B-A3B cores (and any other 16-aligned NVFP4 table width) load through the shared metadata-driven contract with no model-specific runtime branches.
Supporting evidence and limitations
cargo check --locked --release --manifest-path helios/Cargo.toml --features runtime-core,serversucceeded on top oforigin/main(45e1c1ad).cargo test --libonorigin/main(45e1c1ad) currently fails to compile at an unrelated test literal missingexternal_extentsinhelios/src/runtime_core/cache_memory.rs:1659(addressed separately by NVIDIA/hyperflare-inference#714), socargo testexecution of the new unit test awaits fix(helios): add missing external_extents field in cache_memory test Core literal #714 onmain.H=2048/ 2:1 GDN b12x support) and local-inference-lab/hyperflare-recipes#154 (qwen4_35brecipe).Discord: lukealonso