Skip to content

helios,heliopause,ignition: add FP8_E4M3_GLOBAL single-plane engram table support - #732

Open
yatesdr wants to merge 1 commit into
NVIDIA:mainfrom
yatesdr:feat/qwen4-fp8-ple
Open

yatesdr wants to merge 1 commit into
NVIDIA:mainfrom
yatesdr:feat/qwen4-fp8-ple

Conversation

@yatesdr

@yatesdr yatesdr commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Adds EngramTable.Encoding.FP8_E4M3_GLOBAL = 4 single-plane engram / Per-Layer Embedding (PLE) table support across Helios, Heliopause, and Ignition.

Summary

  • Protobuf (helios/proto/core.proto, helios/proto/runtime_core.proto, ignition/preparation/runtime_core_pb2.py): Appends Encoding::FP8_E4M3_GLOBAL = 4 alongside FP8_E4M3_E8M0 = 1, NVFP4_E4M3_GLOBAL = 2, and BF16 = 3.
  • Signed-core schema validation & runtime decoding (helios/src/core/schema.rs, helios/src/runtime_core/engram.rs): Exhaustively matches the decoded Encoding enum once in validate_engram, enforces single-plane 1-byte-per-element row sizing (rows * embedding_width), scale_block == 0, absent scale plane/buffer, and finite positive global_scale, and consolidates single-plane row-byte geometry in runtime_core::engram.
  • Ignition PLE delivery (ignition/components/ngram_delivery.py): Extracts _ple_lookup_planes(mode, weight, scales, scale) shared by PreparedPLELookup and flare::staged_ple, explicitly validating "nvfp4_group16", "fp8_e4m3_per_tensor", and "bf16" plane/scale contracts and raising ValueError on unsupported modes or mismatched planes.
  • Backward compatibility: Preserves wire and behavioral compatibility for FP8_E4M3_E8M0, NVFP4_E4M3_GLOBAL (including omitted default encoding), and BF16 cores without re-export.
  • Docs & tests (docs/core-format-design.md, docs/core-design.md, helios/manifest.md, heliopause/src/export/core.rs, tests/components/test_ngram_delivery.py): Covers shared and partitioned FP8_E4M3_GLOBAL export, signed round-trip, and hardlink reuse (reuse_engram_hardlinks_shared_and_partitioned_embedding_planes), plus invalid mode/plane rejection tests.

Companion recipe PR: local-inference-lab/hyperflare-recipes#165

Verification

  • cargo test --release --manifest-path heliopause/Cargo.toml --lib: 234 passed, 0 failed, 6 ignored (including shared & partitioned FP8_E4M3_GLOBAL export and hardlink reuse).
  • cargo test --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib core::: 527 passed, 0 failed, 14 ignored.
  • cargo test --release --manifest-path helios/Cargo.toml --features runtime-core,server --lib runtime_core::: 204 passed, 0 failed, 13 ignored.
  • cargo test --release --manifest-path flare/Cargo.toml --lib: 247 passed, 0 failed, 4 ignored.
  • pytest tests/components/test_ngram_delivery.py: 10 passed, 0 failed.
  • Live DGX Spark (GB10, SM121) ignition export (--max-concurrency 4 --prefill-chunk-size 2048 --autotune-effort default) + native flare run serving verified on both FP8_E4M3_GLOBAL (eidonix/Qwen4-35B-A3B-MXFP8, disk and --embedding-table-storage ram backing: 37.8 GiB GPU, 71.3 GiB disk / 53.1 GiB RAM KV cache) and backward-compatible NVFP4_E4M3_GLOBAL (eidonix/Qwen4-35B-A3B-NVFP4-MXFP8-Hybrid: 28.0 GiB GPU, 81.1 GiB KV cache).

Discord: D-Rock

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 732.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot flare-autobot added area:engram Engram row gathering, disk I/O, and embedding-row caching. enhancement New feature or request triage:review Proposed change needs code review; this does not imply merge readiness. labels Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The EngramTable.Encoding.FP8_E4M3_GLOBAL = 4 format, schema validation, and runtime decoding additions are small, additive, and wire-compatible, cleanly reusing #664's Planes { weights, scales: Option<Plane> } seam with no FP8-specific exporter or native reader branches. However, Layer-1 verification is incomplete (only narrow name-filtered debug subsets for helios and heliopause), and there are two should-fixes: non-exhaustive fallback dispatch with missing None guards in ignition/components/ngram_delivery.py, and factual discrepancies in the PR description.

  • Blockers: 1 · Should fix: 2 · Subtract/Simplify: 2 · Nits: 2
Walkthrough
  • Protobuf & Python bindings (helios/proto/core.proto:268-269, helios/proto/runtime_core.proto:664-665, ignition/preparation/runtime_core_pb2.py:27,182-183): Appends EngramTable.Encoding.FP8_E4M3_GLOBAL = 4 (raw 1-byte-per-element FP8 E4M3 rows, no scale plane, scale_block == 0, finite positive global_scale) and regenerates runtime_core_pb2.py (_ENGRAMTABLE_ENCODING descriptor expands by 21 bytes with FP8_E4M3_GLOBAL = 4).
  • Signed-core schema validation (helios/src/core/schema.rs:451-454, 497-512, 561-586, 622-630, 2067-2167): Classifies Fp8E4m3Global as single-plane in engram_encoding_has_scales, enforces empty scale_buffer, scale_block == 0, finite positive global_scale, absent scales plane, and exact rows * embedding_width byte lengths for both shared and partitioned tables (generalizing helios,heliopause,ignition: support single-plane BF16 and identity-indexed offloaded embedding tables #664's bf16_row_bytes into single_plane_row_bytes without changing BF16 behavior), and adds validates_single_plane_fp8_global_engram_table.
  • Runtime-core decoding (helios/src/runtime_core/engram.rs:159-167, 1161-1235): Adds the Encoding::Fp8E4m3Global decode arm yielding (embedding_width, 0, row_bytes, None) for positive embedding_width and finite positive global_scale, plus unit test fp8_global_single_plane_tables_decode_shared_and_partitioned.
  • Heliopause export tests (heliopause/src/export/core.rs:4413-4768): Adds shared and partitioned Fp8E4m3Global tables (plus scale-plane rejection and signed round-trip verification) to core_engram_preserves_shared_and_partitioned_plane_layouts; production export paths require no changes.
  • Ignition PLE delivery & tests (ignition/components/ngram_delivery.py:98-115, 131-157, tests/components/test_ngram_delivery.py): Updates flare::staged_ple (_lookup) and PreparedPLELookup.__init__ to accept optional scales/scale tensors and select views/scales for "bf16", "fp8_e4m3_per_tensor", and two-plane NVFP4, with a new parametrized CPU test covering view selection and make_fx tracing.
  • Docs (docs/core-format-design.md:94-95, helios/manifest.md:526-528): Documents FP8_E4M3_GLOBAL single-plane layout, omitted -scales safetensors file, and global_scale contract.
Merge Risk: Low · up to 078b043
  • Wire & runtime surface is strictly additive: FP8_E4M3_GLOBAL = 4 is appended to EngramTable.Encoding in helios/proto/{core,runtime_core}.proto (with ignition/preparation/runtime_core_pb2.py regenerated to match), leaving FP8_E4M3_E8M0 = 1, NVFP4_E4M3_GLOBAL = 2, and BF16 = 3 wire layouts and validation semantics intact.
  • No new exporter or native serving branches: heliopause/src/export/core.rs, helios/src/core/reader.rs, helios/src/engram.rs, helios/src/runtime_core/selection.rs, and helios/src/runtime_core/describe.rs already route through schema::engram_encoding_has_scales, schema::engram_scales, and Planes { weights, scales: Option<Plane> }.
  • Remaining risk: Full release-mode Layer-1 test suites for helios, heliopause, and tests/preparation/ have not been run on 078b043, and ignition/components/ngram_delivery.py silently falls into two-plane NVFP4 on unknown quant_mode values (dereferencing None when scales is absent).
Pre-merge checks: ✅ 2 passed · ⚠️ 2 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

…able support

Offloaded engram and PLE tables previously supported only two-plane
FP8_E4M3_E8M0 (=1) and NVFP4_E4M3_GLOBAL (=2), plus single-plane BF16 (=3).
Checkpoints such as Qwen4-35B-A3B store 160M-row PLE tables as single-plane
FP8 E4M3 weights with a shared FP32 tensor scale, which could not be exported
or served natively without a matching single-plane encoding contract.

Add Encoding::FP8_E4M3_GLOBAL = 4 to helios/proto/core.proto and
helios/proto/runtime_core.proto (and regenerate
ignition/preparation/runtime_core_pb2.py). Validate single-plane
1-byte-per-element row sizing, scale_block == 0, absent scale plane/buffer,
and finite positive global_scale in helios/src/core/schema.rs (matching the
decoded Encoding enum exhaustively once) and helios/src/runtime_core/engram.rs
(sharing single-plane row-byte geometry). Update
ignition/components/ngram_delivery.py with an explicit _ple_lookup_planes
validator shared by PreparedPLELookup and flare::staged_ple across
nvfp4_group16, fp8_e4m3_per_tensor, and bf16. Preserve wire and behavioral
compatibility for existing FP8_E4M3_E8M0, NVFP4_E4M3_GLOBAL (including
omitted default encoding), and BF16 cores. Document the encoding in
docs/core-format-design.md, docs/core-design.md, and helios/manifest.md, and
add unit coverage in helios, heliopause (including shared and partitioned
FP8_E4M3_GLOBAL hardlink reuse), and tests/components/test_ngram_delivery.py.

This enables single-plane FP8 engram/PLE export, hardlink reuse, and disk- or
RAM-backed native serving via flare run without re-exporting existing cores.

Verification:
- cargo test --release --manifest-path heliopause/Cargo.toml --lib:
  234 passed, 0 failed, 6 ignored (including shared and partitioned
  FP8_E4M3_GLOBAL export and hardlink reuse alongside NVFP4_E4M3_GLOBAL and
  BF16).
- cargo test --release --manifest-path helios/Cargo.toml --features
  runtime-core,server --lib core::: 527 passed, 0 failed, 14 ignored.
- cargo test --release --manifest-path helios/Cargo.toml --features
  runtime-core,server --lib runtime_core::: 204 passed, 0 failed, 13 ignored.
- cargo test --release --manifest-path flare/Cargo.toml --lib:
  247 passed, 0 failed, 4 ignored.
- pytest tests/components/test_ngram_delivery.py: 10 passed, 0 failed
  (covers nvfp4_group16, fp8_e4m3_per_tensor, bf16, FX tracing, and invalid
  mode/plane rejection).
- Live single-GPU DGX Spark (NVIDIA GB10, SM121) ignition export
  (--max-concurrency 4 --prefill-chunk-size 2048 --autotune-effort default)
  and native flare run serving verified end-to-end with FP8_E4M3_GLOBAL
  (eidonix/Qwen4-35B-A3B-MXFP8, disk and --embedding-table-storage ram
  backing, 37.8 GiB GPU, 71.3 GiB disk / 53.1 GiB RAM KV cache) and
  backward-compatible NVFP4_E4M3_GLOBAL (eidonix/Qwen4-35B-A3B-NVFP4-MXFP8-Hybrid,
  28.0 GiB GPU, 81.1 GiB KV cache).
- Limitations: partitioned TP>1 FP8_E4M3_GLOBAL export, hardlink reuse, and
  decode are covered by CPU unit tests rather than multi-GPU hardware
  execution.

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
@yatesdr
yatesdr force-pushed the feat/qwen4-fp8-ple branch from 078b043 to 02ba762 Compare December 4, 2026 21:21
@nero-

nero- commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

+1 — closed #733 in favor of this PR since the FP8_E4M3_GLOBAL = 4 single-plane wire contract is identical. Independently verified this encoding end-to-end (export, serving, warm prefix cache, and full GSM8K-1319 qualification) on both SM120 (RTX 5090, --embedding-table-storage ram) and SM121 (DGX Spark, both disk and ram).

@flare-autobot flare-autobot added the performance Performance, latency, throughput, or memory-efficiency investigation or improvement. label Dec 4, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The FP8_E4M3_GLOBAL = 4 wire, schema, runtime-decode, and export additions are sound, strictly additive, and wire-compatible, and independent SM120/SM121 GSM8K-1319 verification from @nero- strengthens confidence in the contract. However, the follow-up code, test, and doc fixes described in the updated PR body are not present at head 02ba762, and Round 1's Layer-1 CPU verification gap remains partially unresolved.

  • Blockers: 2 · Should fix: 1 · Subtract/Simplify: 3 · Nits: 3
Walkthrough
  • Protobuf & Python bindings (helios/proto/core.proto:268-269, helios/proto/runtime_core.proto:664-665, ignition/preparation/runtime_core_pb2.py:5,27,182-183): Appends EngramTable.Encoding.FP8_E4M3_GLOBAL = 4 (raw 1-byte-per-element FP8 E4M3 rows, no scale plane, scale_block == 0, finite positive global_scale) and regenerates runtime_core_pb2.py (_ENGRAMTABLE_ENCODING span 11543..11643, verified consistent).
  • Signed-core schema validation (helios/src/core/schema.rs:445-457, 497-512, 561-589, 622-637, 2067-2167): Classifies Fp8E4m3Global as single-plane in engram_encoding_has_scales, enforces empty scale_buffer, scale_block == 0, finite positive global_scale, absent scales plane, and exact rows * embedding_width byte lengths for shared and partitioned tables (preserving helios,heliopause,ignition: support single-plane BF16 and identity-indexed offloaded embedding tables #664's BF16 behavior), plus validates_single_plane_fp8_global_engram_table.
  • Runtime-core decoding (helios/src/runtime_core/engram.rs:159-167, 1161-1235): Adds the Encoding::Fp8E4m3Global decode arm yielding (embedding_width, 0, row_bytes, None) for positive embedding_width and finite positive global_scale, plus fp8_global_single_plane_tables_decode_shared_and_partitioned.
  • Heliopause export tests (heliopause/src/export/core.rs:4410-4768): Adds shared and partitioned Fp8E4m3Global tables (plus scale-plane rejection and signed round-trip verification) to core_engram_preserves_shared_and_partitioned_plane_layouts; production export code needs no FP8-specific branch. (reuse_engram_hardlinks_shared_and_partitioned_embedding_planes at :3907-3971 is unchanged at 02ba762.)
  • Ignition PLE delivery & tests (ignition/components/ngram_delivery.py:98-115, 131-157, tests/components/test_ngram_delivery.py:29-135): Widens scales/scale to torch.Tensor | None and adds an "fp8_e4m3_per_tensor" branch in both _lookup and PreparedPLELookup.__init__, with 1 parametrized test over the 3 valid modes.
  • Docs (docs/core-format-design.md:94-95, helios/manifest.md:526-528): Documents FP8_E4M3_GLOBAL single-plane layout, omitted -scales safetensors file, and global_scale contract.
Merge Risk: Low · up to 02ba762
  • Core Rust/wire surface is verified clean and additive: FP8_E4M3_GLOBAL = 4 is appended cleanly to helios/proto/{core,runtime_core}.proto with ignition/preparation/runtime_core_pb2.py regenerated to match (+21 bytes in _ENGRAMTABLE_ENCODING), and downstream consumers (helios/src/core/reader.rs:221, helios/src/engram.rs:203-219, helios/src/runtime_core/describe.rs:479,646, helios/src/core/conversion.rs:2862-2863, heliopause/src/export/weight_reuse.rs:397-410,472) already route generically through helios,heliopause,ignition: support single-plane BF16 and identity-indexed offloaded embedding tables #664's single-plane seam.
  • Unpushed follow-up commit risk: 02ba762 does not contain the _ple_lookup_planes refactor, negative mode/plane tests, FP8 hardlink-reuse test coverage, or Rust/doc cleanups claimed in the PR description, meaning the reported verification runs (pytest: 10 passed, FP8 hardlink reuse) do not correspond to the commit currently queued to merge.
  • Remaining code & verification gaps: ignition/components/ngram_delivery.py:105-114, 136-144 still crashes with AttributeError on unknown quant_mode with single-plane tables (scales is None), and unfiltered helios + tests/preparation/ Layer-1 CPU suites have not been reported on the pushed head.
Pre-merge checks: ✅ 3 passed · ⚠️ 1 warnings

Have your agent review the Full Review for complete verified findings, file:line citations, and suggested changes.

To opt out, include #autobot:ignore in your post or comment.

yatesdr added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 5, 2026
…PLE and MXFP8 MoE support

The existing qwen4_35b recipe entry pointed to an unpinned local path and
assumed NVFP4_E4M3_GLOBAL PLE, NVFP4-only routed MoE layers, separate
up/gate/down MTP expert weights, and quantized-only QSA projections carrying
calibrated KV scales. As a result, published Qwen4-35B-A3B checkpoints using
FP8_E4M3_GLOBAL PLE, MXFP8 or hybrid MXFP8/NVFP4 MoE layers, BF16 early QSA
layers with calibrated k_scale/v_scale, and fused 3D BF16 MTP experts could
not be prepared or exported for single-GPU NVIDIA DGX Spark (GB10, SM121).

Update the qwen38 recipe family and shared weight loader to support these
checkpoint contracts cleanly:
- Pin three Hugging Face checkpoints on QWEN4_35B_RECIPE in
  hyperflare_recipes/recipes/qwen38/recipe.py with verified model-card
  sampling defaults (Qwen/Qwen4-35B-A3B thinking mode):
  - qwen4-35b-a3b (local-inference-lab/Qwen4-35B-A3B-NVFP4 @ 42496ec4)
  - qwen4-35b-a3b-mxfp8 (eidonix/Qwen4-35B-A3B-MXFP8 @ f1feaf48)
  - qwen4-35b-a3b-hybrid (eidonix/Qwen4-35B-A3B-NVFP4-MXFP8-Hybrid @ 4590c68c)
- Support FP8_E4M3_GLOBAL (fp8_e4m3_per_tensor) and BF16 single-plane PLE
  tables alongside NVFP4_E4M3_GLOBAL across checkpoint.py,
  checkpoint_schema.py, geometry.py, and ple.py.
- Load calibrated QSA k_proj.k_scale / v_proj.v_scale in attention.py,
  weights.py, and mtp_weights.py via shared QwenWeightLoader.load_qsa_kv_scales,
  allow those side-tensors on unquantized BF16 projections in
  DirectWeightLoader.linear_format() (components/weights.py), and keep b12x
  QSA attention on SM103 when calibrated FP8 KV scales are present.
- Support MXFP8 routed MoE layers in QwenWeightLoader.load_experts() ahead of
  the force_moe_decode_a16 NVFP4 check so hybrid MXFP8/NVFP4 checkpoints apply
  W4A16 decode to NVFP4 layers while keeping MXFP8 layers on MXFP8 A8 kernels.
- Extend load_bf16_experts_as_nvfp4 (components/weights.py) and
  mtp_weights.py to load fused 3D BF16 gate_up_proj / down_proj draft experts.
- Document DGX Spark export and serving in docs/model-preparation.md and add
  regression coverage in tests/recipes/test_qwen4_35b.py.

This enables single-GPU DGX Spark (GB10, SM121) export and native flare run
serving for all three Qwen4-35B-A3B checkpoints. On the 64-window (131,008
positions) confirmation KLD benchmark against the bit-exact BF16 teacher,
qwen4-35b-a3b-mxfp8 reduces mean KLD by 1.86x vs qwen4-35b-a3b (0.02761 vs
0.05122 nats; 94.04% vs 92.04% top-1; PPL 3.2788 vs 3.3005, teacher 3.2752),
and qwen4-35b-a3b-hybrid with --force-moe-decode-a16 reaches 0.04824 KLD in
28.0 GiB GPU memory (81.2 GiB / 7.26M KV tokens headroom) and 71.1-81.1 tok/s
single-request MTP decode in live compiled flare run serving.

Verification:
- CUDA_VISIBLE_DEVICES=0 FLARE_RUN_CUDA_TESTS=1 pytest on SM121 (GB10):
  tests/recipes/test_qwen4_35b.py, test_qwen38_ple.py, test_qwen38_mtp.py,
  and tests/cli/{test_models,test_planning}.py (-k qwen4/qwen38/mtp/ple/hybrid):
  51 passed, 6 skipped, 0 failed (including CUDA fused-3D gate/up parity,
  MTP KV-scale loading, and hybrid MXFP8/NVFP4 force_moe_decode_a16 routing).
- Live compiled + autotuned DGX Spark (NVIDIA GB10, SM121) ignition export
  (--max-concurrency 4 --prefill-chunk-size 2048 --autotune-effort default)
  and native flare run serving verified on qwen4-35b-a3b-mxfp8 and
  qwen4-35b-a3b-hybrid.
- Limitations: qwen4-35b-a3b and qwen4-35b-a3b-mxfp8 require the companion
  NVIDIA/hyperflare-inference#732 FP8_E4M3_GLOBAL engram table support;
  TP2/TP4 serving and SM103 execution were not hardware-tested in this change.

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=6fcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:engram Engram row gathering, disk I/O, and embedding-row caching. enhancement New feature or request performance Performance, latency, throughput, or memory-efficiency investigation or improvement. triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants