Skip to content

helios,heliopause,ignition,flare: add domain-agnostic AsyncTransfer primitive and runtime-sized device pools - #711

Merged
lukealonso merged 1 commit into
mainfrom
async-transfer-primitive
Dec 3, 2026
Merged

lukealonso merged 1 commit into
mainfrom
async-transfer-primitive

Conversation

@lukealonso

@lukealonso lukealonso commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why

Captured CUDA graphs cannot issue asynchronous disk I/O or host-to-device Copy Engine transfers directly, and oversized models whose external weights exceed single-GPU VRAM cannot back full device pools statically at preparation time. Keeping Helios simple and model-agnostic requires an irreducible runtime primitive: runtime-sized Capacity::DEVICE_POOL allocations mapped at fixed reserved virtual addresses, plus a stateless asynchronous extent-copy channel driven by a mapped-host command ring (Execution.async_transfers) over authenticated 4 KiB-aligned external payload segments (RankBody.external_extents).

All model-specific layout packing, tier partitioning, eviction policy, and staging remain outside Helios in recipes and captured graphs. The companion consumer PR in the recipes repository is local-inference-lab/hyperflare-recipes#150.

What changed

Previously, Helios supported runtime-sized STATE_ROWS and KV_PAGES allocations and disk-backed embedding tables, with no domain-agnostic primitive for captured graphs to stream arbitrary authenticated payload extents into runtime-sized VRAM and pinned host RAM pools. Cores without Execution.async_transfers retain identical loading and serving behavior.

  • Signed wire format and validation (helios/proto/{core,runtime_core}.proto, helios/src/core/{schema,reader,protection,export}.rs, heliopause/src/export/):
    • Adds Capacity::DEVICE_POOL = 2, Execution.async_transfers = 9 (message AsyncTransfer), and RankBody.external_extents = 18 (ExternalExtentTable carrying one Weights-role directory payload and ordered Weights-role aligned segment slices entering required_payloads).
    • Validates 24-byte little-endian directory entries (segment_index: u32, reserved: u32, offset: u64, length: u64) against real segment lengths and channel direct-I/O alignment on both export and load.
  • Runtime worker, scheduler, and I/O backend (helios/src/async_transfer/):
    • Implements mapped-host ABI v1 (ControlHeader + 64-byte TransferCommand ring), overflow-free command/extent/pool validators (ring.rs), preemptible priority scheduler (Demand, Prefetch, Warm, epoch cancellation, and bounded bounce slots in scheduler.rs), Linux io_uring / cross-platform pread direct-I/O backend (io_backend.rs), and Copy Engine DMA worker (worker.rs).
    • Uses cuStreamWriteValue64_v2 for stream-ordered device completion writes while mirroring completion words into the mapped-host completion array on all opcodes (DISK_TO_HOST, HOST_TO_DEV, DISK_TO_DEV, CANCEL_EPOCH), detects producer ring overruns (ErrorCode::RingOverrun), backs off busy-wait spins when work is in flight, and finalizes shutdown drain through TransferScheduler::finish_drain after harvesting all canceled I/O completions.
  • Memory sizing, CLI/config, and metrics (helios/src/runtime_core/{limits,memory,mod,model}.rs, selene/src/offload.rs, flare/, flare-cli/, helios/src/server/metrics.rs):
    • Adds PoolMemoryLimit wrapping MemoryLimit with explicit zero support (--pool-vram-memory, --pool-ram-memory, [memory] pool_vram / pool_ram, rank forwarding).
    • Reserves pinned_bytes.div_ceil(512) + 256 MiB of VRAM per rank before sizing DEVICE_POOL and KV caches to account for cuMemHostRegister_v2 GPU MMU page-table overhead across each channel's host pool and bounded bounce pool (bounce_pool_geometry / max_bounce_pool_bytes, disabling bounce staging when alignment exceeds 32 MiB), agrees DEVICE_POOL size as the rank minimum, and rewrites Execution.buffers views onto DEVICE_POOL to floor(agreed_bytes / row_bytes) leading rows.
    • Exports lock-free per-channel flare_async_transfer_* Prometheus metrics when a core declares async transfer channels.
  • Ignition export contract and governed docs (ignition/preparation/{execution,model,runtime_core}.py, docs/{api,cli-design,core-format-design,runtime-core-design}.md, helios/manifest.md):
    • Exposes AsyncTransferChannel for core export, rejects in-process execution of async transfer channels via a single shared guard, and documents the wire format, load-time sizing/truncation behavior, CLI flags, and Prometheus metrics.
  • Formal verification (verification/helios-lifecycle/AsyncTransfer.{tla,cfg}, helios/src/async_transfer/{lifecycle_tests,kani_proofs}.rs):
    • Models the Idle -> Running -> Draining -> Stopped | FailedDrain lifecycle and memory-release safety invariants in TLA+, checks Rust conformance in check.py, and verifies 5 Kani harnesses covering layout, extent validation, pool alignment, command bounds, and bounce-pool reserve bounds.

Claimed benefit and result

  • Expected capability: Provides the domain-agnostic Helios, Heliopause, and Ignition runtime/export contract required by external tiered weight-offloading recipes (local-inference-lab/hyperflare-recipes#150) without leaking model-specific policy into Helios.
  • Measured verification: All formal models, Kani proofs, Rust crate suites, and live SM120 CUDA 3-tier transfer tests (DISK_TO_HOST, HOST_TO_DEV, DISK_TO_DEV with and without bounce staging, invalid-command rejection, and clean shutdown drain) pass on the rebased branch (d86a686e).
  • No throughput change is claimed for existing cores without Execution.async_transfers.

Supporting evidence and limitations

All checks ran on rebased commit d86a686e (base cb191a93):

  • TLA+ and Rust conformance (python3 verification/helios-lifecycle/check.py --tlc-jar /home/luke/.cache/flare-formal/tla2tools-1.7.4.jar --target-dir /tmp/flare-tla-target):
    • All 10 TLA+ models and 9 conformance suites passed, including AsyncTransfer.tla (314 observed Rust transitions checked, 0 errors).
  • Kani 0.68.0 (cargo-kani on helios --features runtime-core --lib):
    • 5/5 harnesses verified, 0 failures: control_layout_matches_u128_oracle, extent_entry_matches_u128_oracle, resolve_pool_bytes_is_aligned_and_bounded, validate_command_guarantees_bounds_and_alignment_for_all_inputs, and bounce_pool_geometry_never_exceeds_reserved_bound.
  • Rust test suites (cargo test --locked --release):
    • eos: 12 passed, 0 failed.
    • selene --features test-support: 585 lib + 1 integration passed, 0 failed.
    • selene-manager --features test-support: 205 lib + all integration test binaries passed, 0 failed.
    • helios --features runtime-core,server on SM120 GPU 2 (FLARE_RUN_CUDA_TESTS=1): runtime_core::limits:: 2/2 passed, runtime_core::memory:: 24/24 passed (1 ignored), async_transfer:: --include-ignored 10/10 passed (including live_cuda_async_transfer_end_to_end verifying both device and host completion words across DISK_TO_HOST, HOST_TO_DEV, DISK_TO_DEV, and bounce staging plus post-stop active_inflight == 0); full helios --lib passed 1,884 tests (6 failures solely from missing FLARE_TEST_TEMPLATE_DIR).
    • flare: all tests passed.
    • flare-cli: all tests passed.
    • heliopause --lib: 230 passed, 0 failed (6 ignored).
  • Python tests (CUDA_VISIBLE_DEVICES=""):
    • tests/cli/ + tests/preparation/test_transient_retention.py: 153 passed, 0 failed.
    • Full tests/: 2,501 passed, 458 GPU/checkpoint-gated skipped, 3 environment-only failures unrelated to this PR (worktree flare_heliopause source-identity mismatch against main checkout .venv, Triton platform_key format, missing ~/.cache/flare/kernels/inductor).

Material limitations and unrun checks:

Discord: lukealonso

@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 711.
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:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. triage:review Proposed change needs code review; this does not imply merge readiness. and removed triage:design-review Needs a maintainer scope, architecture, or contract decision before implementation or integration. labels Dec 3, 2026
@flare-autobot

Copy link
Copy Markdown
Collaborator

Autobot Review

Full Review · Value Proposition · Case File

Recommendation: Changes Requested

The ABI layout, ring/directory bounds validation, extent authentication, pool arithmetic, and the TLA+/Kani/conformance harness work all check out as described, but four verified Should-Fix defects remain in the new runtime. Merge is also gated on recording the explicit Principle-1 approval for the new Execution.async_transfers captured-graph operation family.

  • Blockers: 1 · Should fix: 5 · Subtract/Simplify: 7 · Nits: 6
Walkthrough
  • New helios/src/async_transfer/ runtime: mapped-host ControlHeader + 64-byte command ring (ring.rs:152-203, 244-261), preemptible scheduler with epoch cancellation and bounce slots (scheduler.rs:432-511, 518-556, 657-710), worker thread with io_uring/pread backend (io_backend.rs), and cuStreamWriteValue64_v2 device completions (worker.rs:822-853).
  • New signed wire surface: Capacity::DEVICE_POOL = 2 (runtime_core.proto:781), Execution.async_transfers = 9 + message AsyncTransfer (:837-862), RankBody.external_extents = 18 (core.proto:176-186), validated in core/schema.rs:647-679 and core/reader.rs:225-230, resolved at load in runtime_core/mod.rs:1501-1562.
  • VRAM/RAM accounting: async_transfer_device_reserve (memory.rs:64-103) is applied before DEVICE_POOL/KV sizing (memory.rs:1113-1137); pool size is the rank minimum (memory.rs:1156-1178) and Execution.buffers views onto it are rewritten to floor(bytes/row_bytes) rows (memory.rs:1202, 1546-1563).
  • Operator knobs: PoolMemoryLimit (limits.rs:128-204), --pool-vram-memory/--pool-ram-memory (cli.rs:1174-1177), config surfaces, rank forwarding.
  • Ignition capture seeding: _seed_auxiliary_workspaces in graph_pool (capture.py:74-96), _seed_library_device_caches for b12x.attention.dsa_indexer lru_cache constants (capture.py:99-146), and retention spanning uncompiled warmups (capture.py:232-238).
  • Python refusal of channels for in-process execution (execution.py:461-488), plus new flare_async_transfer_* metrics (server/metrics.rs:1536-1571).
Merge Risk: High · up to 6916f22
  • A new captured-graph operation family (Execution.async_transfers, field 9, four host-driven opcodes) is exactly what docs/design-review.md:22-26 reserves to prior explicit owner approval, and pr_comments contains only the Autobot case-file notice — no review, no approval line (contrast Add Execution.persistent_workers green-context lifecycle #430).
  • The startup VRAM reserve that is the PR's stated safety claim (memory.rs:64-103, 1113-1137) charges a fixed MAX_BOUNCE_POOL_BYTES while the allocator can register far more (up to 16 × alignment), and none of it is exercised end-to-end (only the arithmetic unit test at memory.rs:2357-2431).
  • helios/src/runtime_core/memory.rs, helios/proto/runtime_core.proto, and ignition/preparation/capture.py are the three busiest files in the change set with several open PRs in flight; the capture-seeding half sits beside open fix(ignition): seed warmup workspaces inside export storage pool #606 on merged Isolate cuBLAS warmup workspaces from CUDA graph capture #331.
Pre-merge checks: ✅ 1 passed · ⚠️ 3 warnings
  • ✅ Security / malicious screen: no credential/exfil surface; extent segments and directories are role-checked (schema.rs:647-679), directory entries validated against real segment lengths on both export (capture.rs:3322) and load (mod.rs:1519-1538).
  • ⚠️ Charter & value fit: the domain-agnostic-primitive shape fits "keep the runtime small and model-agnostic", but the new captured-graph op family has no recorded Principle-1 approval, and no in-tree code emits extent_directory (runtime_core.py:431-438; no writer exists), so the shipped surface is unreachable today.
  • ⚠️ Related / duplicate / conflict check: the capture-seeding half overlaps open fix(ignition): seed warmup workspaces inside export storage pool #606 in the same capture_forwards region on merged Isolate cuBLAS warmup workspaces from CUDA graph capture #331 — informational, reconcile before merge.
  • ⚠️ Tests & verification evidence: TLA+/conformance/Kani wiring is genuinely integrated and commands are disclosed, but no pre-helios,heliopause,ignition,flare: add domain-agnostic AsyncTransfer primitive and runtime-sized device pools #711 core is loaded and served, TP>1 (the motivating shape) is untested, and the DEVICE_POOL/reserve branch is covered only by arithmetic unit tests.

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

Want a frontier second opinion? If these findings look noisy, request a one-time SuperAgent Review on 6916f22 (~3–4 min; re-adjudicates existing findings without re-running discovery).

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

…rimitive and runtime-sized device pools

Captured CUDA graphs cannot issue asynchronous disk I/O or host-to-device
Copy Engine transfers directly, and runtime-sized byte pools for large
offloaded datasets cannot be statically backed during preparation when a
model's external payloads exceed single-GPU VRAM. Adding a domain-agnostic
asynchronous extent-transfer primitive and runtime-sized Capacity::DEVICE_POOL
storage lets captured graphs stream authenticated 4 KiB-aligned core payloads
through pinned host RAM and VRAM without adding model-specific policy or
algorithms to Helios.

This change adds the end-to-end AsyncTransfer primitive across the core
format, Heliopause export, Ignition manifest, Helios runtime, Selene host
memory query, CLI/config surfaces, metrics, and formal verification:

- Signed wire format and core loading (helios/proto/{core,runtime_core}.proto,
  helios/src/core/{schema,reader,protection,export}.rs, helios/src/runtime_core/,
  heliopause/src/export/): adds Capacity::DEVICE_POOL = 2,
  Execution.async_transfers = 9 (message AsyncTransfer), and
  RankBody.external_extents = 18 (Weights-role authenticated extent directory
  with 24-byte little-endian entries and aligned segment slices). Cores
  without async transfer channels remain unchanged and compatible.
- Runtime worker and scheduler (helios/src/async_transfer/): implements a
  mapped-host ControlHeader + 64-byte command ring ABI v1, overflow-free
  command/extent/pool validators, preemptible priority scheduler (Demand /
  Prefetch / Warm + epoch cancellation + bounded bounce slots), Linux
  io_uring / cross-platform pread direct-I/O backend, Copy Engine DMA with
  cuStreamWriteValue64_v2 device completions plus mirrored host completions,
  producer ring-overrun detection, bounded busy-wait backoff, and bounded
  shutdown drain finalized through TransferScheduler::finish_drain.
- Memory accounting and sizing (helios/src/runtime_core/{limits,memory,mod,model}.rs,
  selene/src/offload.rs): introduces PoolMemoryLimit wrapping MemoryLimit
  with zero support (--pool-vram-memory / --pool-ram-memory and config
  equivalents), reserves pinned_bytes.div_ceil(512) + 256 MiB per rank for
  cuMemHostRegister_v2 GPU MMU page tables and worker streams using a shared
  bounce_pool_geometry/max_bounce_pool_bytes bound (disabling bounce staging
  when alignment exceeds 32 MiB), agrees DEVICE_POOL size as the rank
  minimum, and rewrites DEVICE_POOL Execution.buffers views to whole leading
  rows.
- Ignition contract, observability, and documentation
  (ignition/preparation/{execution,model,runtime_core}.py,
  helios/src/server/metrics.rs, docs/{api,cli-design,core-format-design,
  runtime-core-design}.md, helios/manifest.md): adds AsyncTransferChannel
  export wiring, rejects in-process execution of async transfer channels via
  one shared guard, exports per-channel flare_async_transfer_* Prometheus
  metrics, and documents the wire format, sizing rules, CLI flags, and metrics.
- Formal verification (verification/helios-lifecycle/AsyncTransfer.{tla,cfg},
  helios/src/async_transfer/{lifecycle_tests,kani_proofs}.rs): adds TLA+
  lifecycle specification, Rust conformance tests, and 5 Kani proofs covering
  layout, extent entry, pool alignment, command validation, and bounce-pool
  reserve bounds.

Expected benefit: provides the domain-agnostic Helios, Heliopause, and
Ignition runtime/export primitive consumed by external tiered offloading
recipes (local-inference-lab/hyperflare-recipes#150) while preserving
strict preparation/serving separation and backward compatibility for all
existing cores. No serving throughput change is claimed for existing cores.

Validation (rebased onto cb191a9):
- TLA+ + Rust conformance (verification/helios-lifecycle/check.py with
  tla2tools-1.7.4.jar): all 10 models and 9 conformance suites passed
  (314 observed Rust transitions checked against AsyncTransfer.tla).
- Kani 0.68.0 (helios --features runtime-core --lib): 5/5 async_transfer
  harnesses verified with 0 failures (control_layout_matches_u128_oracle,
  extent_entry_matches_u128_oracle, resolve_pool_bytes_is_aligned_and_bounded,
  validate_command_guarantees_bounds_and_alignment_for_all_inputs,
  bounce_pool_geometry_never_exceeds_reserved_bound).
- Rust suites (cargo test --locked --release): eos (12 passed), selene
  (585 lib + 1 integration), selene-manager (205 lib + all integration
  binaries), helios on SM120 GPU 2 with FLARE_RUN_CUDA_TESTS=1
  (runtime_core::limits 2/2, runtime_core::memory 24/24 + 1 ignored,
  async_transfer --include-ignored 10/10 including live CUDA 3-tier
  DISK_TO_HOST / HOST_TO_DEV / DISK_TO_DEV with both device and host
  completion assertions and post-stop active_inflight == 0; full helios
  lib 1884 passed with 6 failures solely from missing FLARE_TEST_TEMPLATE_DIR),
  flare (all passed), flare-cli (all passed), heliopause --lib (230 passed,
  6 ignored).
- Python tests (CUDA_VISIBLE_DEVICES=""): 153 passed in tests/cli/ and
  tests/preparation/test_transient_retention.py; 2501 passed across full
  tests/ (3 unrelated environment failures: worktree heliopause build hash
  mismatch, Triton platform_key, missing ~/.cache/flare/kernels/inductor).

Limitations and unrun checks:
- Introducing Execution.async_transfers as a captured-graph operation
  contract requires recorded Principle 1 owner approval from Luke Alonso
  before merge.
- No in-tree recipe in this repository produces external_extents; the
  companion consumer PR is local-inference-lab/hyperflare-recipes#150.
- Multi-rank TP>1 async transfer execution and loading/serving a
  pre-#711 exported core were not re-run in this test pass; helios
  template-dependent tests require FLARE_TEST_TEMPLATE_DIR.

Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b
Signed-off-by: Luke Alonso <lalonso@gmail.com>
@lukealonso

Copy link
Copy Markdown
Collaborator Author

Rebased onto cb191a93 (d86a686e) and addressed the verified review findings:

  • Bounce-slot rounding/cap and reserve match (worker.rs, memory.rs, kani_proofs.rs): Added shared bounce_pool_geometry and max_bounce_pool_bytes helpers that round up to alignment before applying MAX_BOUNCE_SLOT_BYTES and disable bounce staging ((0, 0)) when the aligned slot exceeds 32 MiB (including alignment > 32 MiB). async_transfer_device_reserve now calls max_bounce_pool_bytes(channel.alignment), backed by a unit test and a new Kani proof (bounce_pool_geometry_never_exceeds_reserved_bound, 5/5 harnesses verified).
  • Drain transition and canceled I/O accounting (io_backend.rs, worker.rs): IoBackend::cancel_and_drain now returns all harvested IoCompletions to the worker so scheduler.complete_io retires in-flight I/O accounting and bounce slots; worker_main now finalizes shutdown through scheduler.finish_drain(io_drained && stream_drained), keeping StoppedHasZeroInflight / CanReleaseExact enforced on the production path (asserted via post-stop active_inflight == 0 in live_cuda_async_transfer_end_to_end).
  • HOST_TO_DEV / DISK_TO_DEV host completion parity (worker.rs): Added EventCompletionAction::HostOnly so cuStreamWriteValue64_v2 writes the device completion word in stream order while the host completion array is mirrored idempotently on event completion without repeating cuStreamWriteValue64_v2. Extended live_cuda_async_transfer_end_to_end to assert both device and host completion words for HOST_TO_DEV, DISK_TO_DEV, and bounce-staged DISK_TO_DEV.
  • Governed documentation (docs/core-format-design.md, docs/api.md, docs/runtime-core-design.md, docs/cli-design.md): Documented RankBody.external_extents and its 24-byte directory entry layout, all 10 flare_async_transfer_* Prometheus metrics, rank-minimum DEVICE_POOL sizing and whole-row Execution.buffers truncation, and the no-op scope of --pool-vram-memory / --pool-ram-memory on cores without async transfer channels.
  • Scope & companion consumer: Split the unrelated ignition/preparation/capture.py / test_transient_retention.py seeding changes out of this PR (eliminating overlap with fix(ignition): seed warmup workspaces inside export storage pool #606) and opened the companion consumer PR local-inference-lab/hyperflare-recipes#150.
  • Simplifications & nits: Collapsed PoolMemoryLimit onto MemoryLimit (limits.rs); replaced dead open_direct_backend with from_direct_files called from runtime_core/mod.rs; dropped the 3 redundant parameters from prepare_async_transfers (mod.rs, model.rs); reused selene::offload::host_pool_budget_and_total instead of duplicating /proc/meminfo parsing (selene/src/offload.rs, memory.rs); removed unused ChannelConfig::max_bg_io/max_bg_dma; eliminated Opcode::CancelEpoch => unreachable!() (ring.rs); fused the two snapshot flat_map passes into one fold (model.rs); added producer ring-overrun detection (ErrorCode::RingOverrun) and in-flight spin backoff (worker.rs); deduplicated the Python in-process refusal helper (execution.py, model.py).

Remaining merge gate: explicit Principle 1 approval for the Execution.async_transfers captured-graph operation contract from project owner Luke Alonso on this thread.

@flare-autobot

@lukealonso lukealonso changed the title helios,heliopause,ignition,flare: add domain-agnostic AsyncTransfer primitive, runtime-sized device pools, and capture cache seeding helios,heliopause,ignition,flare: add domain-agnostic AsyncTransfer primitive and runtime-sized device pools Dec 3, 2026
@lukealonso
lukealonso force-pushed the async-transfer-primitive branch from 6916f22 to d86a686 Compare December 3, 2026 20:56
@lukealonso

Copy link
Copy Markdown
Collaborator Author

@flare-autobot re-review on d86a686

@lukealonso
lukealonso merged commit 45e1c1a into main Dec 3, 2026
3 checks passed
lukealonso added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 3, 2026
Why:
Large mixture-of-experts checkpoints such as GLM-5.3 (42 routed layers,
288 experts, ~159.5 GiB of NVFP4 routed-expert weights) and Qwen3.8
(48 routed layers, 512 experts, ~63.3 GiB of NVFP4 routed-expert weights)
exceed single-GPU SM120/SM121 VRAM when all routed experts reside
permanently on device. Demand-paging misses from pinned host RAM and NVMe
enables single-GPU serving, while concurrent lookahead prefetching hides
PCIe H2D and NVMe transfer latency behind layer execution. Building on
Helios's domain-agnostic AsyncTransfer primitive
(NVIDIA/hyperflare-inference#711), keeping expert slab packing, tier
partitioning, eviction, lookahead prediction, and staging inside shared
recipe components and captured CUDA kernels preserves Helios's separation
from model computation.

What changed:
Previously, glm53 and qwen38 loaded all routed-expert tensors into
persistent device memory during preparation and bound all E experts
directly to b12x PreparedRoutedExperts. Default preparation without
--tiered-moe-offload retains that behavior unchanged.

When --tiered-moe-offload is enabled (validated for TP=1, SM120/SM121,
and --no-mixed-prefill):
- CLI parameters (hyperflare_recipes/parameters.py): adds
  TieredMoeOffloadParameters with --tiered-moe-offload,
  --offload-predictor {auto,learned,direct,none} (default auto),
  --offload-predictor-weights (local path or hf://<repo>/<file>[@<rev>]),
  and --offload-extents-dir, plus resident weight budget adjustment.
- Shared runtime and HF resolution
  (hyperflare_recipes/components/tiered_moe_offload.py): adds
  TieredExpertExtentPacker (streaming 4 KiB-aligned 4-tensor NVFP4 slabs
  into external extent segments with manifest/scale reuse),
  OffloadedLayerScales, TieredMoeRuntime (runtime-sized DEVICE_POOL,
  startup TuningGraph pre-warm, reusable S_active b12x staging buffer,
  strict validate_offload_checkpoint schema checks for
  ShadowRecurDepthAttn and knapsack files, and embed_prefetch),
  resolve_predictor_weights / parse_hf_weights_uri (automatically
  fetching pinned checkpoints from
  local-inference-lab/hyperflare-offload-predictors at revision
  dcde6ca1e9e0a598b4d9ab6b76b0b179a8d30fe0 when auto/learned weights are
  omitted), TieredMoeAttachment, and PreparedTieredRoutedExperts.
- Automatic dispatch (hyperflare_recipes/components/moe.py): routes bound
  OffloadedLayerScales in PreparedRoutedExperts.__new__ to
  PreparedTieredRoutedExperts and rejects unsupported options explicitly.
- CUDA kernels (hyperflare_recipes/components/tiered_moe_kernel/,
  packaged via pyproject.toml): adds tiered_moe_init,
  tiered_moe_demand_and_remap (decode demand paging with ADMIT_THRESHOLD=2
  promotion and non-polluting tiled prefill), tiered_moe_direct_prefetch,
  tiered_moe_predict_shadow_recur_and_issue (shared input projection with
  per-layer LoRA + expert embeddings, cross-layer GRU, 4-head causal
  depth-axis self-attention, 4-block FiLM-SwiGLU trunk, NVMe FiLM-SwiGLU
  block, folded dual-horizon scoring, and calibrated union prefetch),
  tiered_moe_embed_prefetch (early-layer Embed-Reshapers), and
  tiered_moe_wait_and_gather (device and host completion ABI modes plus
  coalesced uint4 staging copy).
- Recipe hooks (glm53/{recipe,weights,moe,stack,bootstrap}.py and
  qwen38/{recipe,moe,decoder,bootstrap}.py): wire TieredMoeOffloadParameters
  (with default_predictor_model="glm53"/"qwen38"), HF resolution in
  prepare(), TieredMoeAttachment, tiered_packer.load_or_ingest,
  num_valid_tokens forwarding, and 2-line embed_prefetch hooks.

Claimed benefit and result:
Enables single-GPU SM120/SM121 preparation and 3-tier predictive MoE
offloading for GLM-5.3 and Qwen3.8 with automatic pinned Hugging Face
predictor downloads, thin recipe hooks, strict checkpoint schema
validation, and zero change to default non-offloaded exports. Measured
component checks verify bit-exact slab packing, 3-tier demand paging and
non-polluting tiled prefill, live Hugging Face checkpoint retrieval, and
memory-safe CUDA execution of demand, ShadowRecurDepthAttn,
Embed-Reshaper, and direct-prefetch kernels. No end-to-end flare run
serving throughput result is claimed by this PR.

Supporting evidence and limitations:
Tested on SM120 (NVIDIA RTX PRO 6000 Blackwell Max-Q) with PYTHONPATH
pointing at NVIDIA/hyperflare-inference#711 (d86a686e):
- CPU contracts and affected recipe tests: 93 passed, 0 failed, 100
  skipped (GPU/checkpoint-gated), including HF URI/download contracts,
  ShadowRecurDepthAttn schema validation, and lazy import checks.
- Live Hugging Face download validation: TieredMoeAttachment.resolve_parameters
  and resolve_predictor_weights downloaded glm53/model.safetensors,
  glm53/knapsack.safetensors, qwen38/model.safetensors, and
  qwen38/knapsack.safetensors from
  local-inference-lab/hyperflare-offload-predictors@dcde6ca1e9e0a598b4d9ab6b76b0b179a8d30fe0
  and validated all 4 files with validate_offload_checkpoint.
- CUDA integration tests under compute-sanitizer --tool memcheck
  --error-exitcode 1 (tests/components/test_tiered_moe_offload_cuda.py):
  5/5 passed, 0 errors across device/host completion ABI modes,
  full-resident fast path, Embed-Reshaper, ShadowRecurDepthAttn layers
  0 and 1, and direct prefetch.
- Existing GPU recipe tests (qwen38/glm53 moe and weight suites): 49
  passed, 0 failed, 96 skipped.
Limitations: requires NVIDIA/hyperflare-inference#711 to merge and
uv.lock to update before CI can resolve AsyncTransferChannel; single-GPU
TP=1 and --no-mixed-prefill only; full-checkpoint export and live flare
run qualification were not re-run on this branch.

Design-Signed-Off-By: Antigravity (Gemini); design-review=6fcc
Signed-off-by: Luke Alonso <lalonso@gmail.com>
lukealonso added a commit to local-inference-lab/hyperflare-recipes that referenced this pull request Dec 3, 2026
Why:
Large mixture-of-experts checkpoints such as GLM-5.3 (42 routed layers,
288 experts, ~159.5 GiB of NVFP4 routed-expert weights) and Qwen3.8
(48 routed layers, 512 experts, ~63.3 GiB of NVFP4 routed-expert weights)
exceed single-GPU SM120/SM121 VRAM when all routed experts reside
permanently on device. Demand-paging misses from pinned host RAM and NVMe
enables single-GPU serving, while concurrent lookahead prefetching hides
PCIe H2D and NVMe transfer latency behind layer execution. Building on
Helios's domain-agnostic AsyncTransfer primitive
(NVIDIA/hyperflare-inference#711), keeping expert slab packing, tier
partitioning, eviction, lookahead prediction, and staging inside shared
recipe components and captured CUDA kernels preserves Helios's separation
from model computation.

What changed:
Previously, glm53 and qwen38 loaded all routed-expert tensors into
persistent device memory during preparation and bound all E experts
directly to b12x PreparedRoutedExperts. Default preparation without
--tiered-moe-offload retains that behavior unchanged.

When --tiered-moe-offload is enabled (validated for TP=1, SM120/SM121,
and --no-mixed-prefill):
- CLI parameters (hyperflare_recipes/parameters.py): adds
  TieredMoeOffloadParameters with --tiered-moe-offload,
  --offload-predictor {auto,learned,direct,none} (default auto),
  --offload-predictor-weights (local path or hf://<repo>/<file>[@<rev>]),
  and --offload-extents-dir, plus resident weight budget adjustment.
- Shared runtime and HF resolution
  (hyperflare_recipes/components/tiered_moe_offload.py): adds
  TieredExpertExtentPacker (streaming 4 KiB-aligned 4-tensor NVFP4 slabs
  into external extent segments with manifest/scale reuse),
  OffloadedLayerScales, TieredMoeRuntime (runtime-sized DEVICE_POOL,
  startup TuningGraph pre-warm, reusable S_active b12x staging buffer,
  strict validate_offload_checkpoint schema checks for
  ShadowRecurDepthAttn and knapsack files, and embed_prefetch),
  resolve_predictor_weights / parse_hf_weights_uri (automatically
  fetching pinned checkpoints from
  local-inference-lab/hyperflare-offload-predictors at revision
  dcde6ca1e9e0a598b4d9ab6b76b0b179a8d30fe0 when auto/learned weights are
  omitted), TieredMoeAttachment, and PreparedTieredRoutedExperts.
- Automatic dispatch (hyperflare_recipes/components/moe.py): routes bound
  OffloadedLayerScales in PreparedRoutedExperts.__new__ to
  PreparedTieredRoutedExperts and rejects unsupported options explicitly.
- CUDA kernels (hyperflare_recipes/components/tiered_moe_kernel/,
  packaged via pyproject.toml): adds tiered_moe_init,
  tiered_moe_demand_and_remap (decode demand paging with ADMIT_THRESHOLD=2
  promotion and non-polluting tiled prefill), tiered_moe_direct_prefetch,
  tiered_moe_predict_shadow_recur_and_issue (shared input projection with
  per-layer LoRA + expert embeddings, cross-layer GRU, 4-head causal
  depth-axis self-attention, 4-block FiLM-SwiGLU trunk, NVMe FiLM-SwiGLU
  block, folded dual-horizon scoring, and calibrated union prefetch),
  tiered_moe_embed_prefetch (early-layer Embed-Reshapers), and
  tiered_moe_wait_and_gather (device and host completion ABI modes plus
  coalesced uint4 staging copy).
- Recipe hooks (glm53/{recipe,weights,moe,stack,bootstrap}.py and
  qwen38/{recipe,moe,decoder,bootstrap}.py): wire TieredMoeOffloadParameters
  (with default_predictor_model="glm53"/"qwen38"), HF resolution in
  prepare(), TieredMoeAttachment, tiered_packer.load_or_ingest,
  num_valid_tokens forwarding, and 2-line embed_prefetch hooks.

Claimed benefit and result:
Enables single-GPU SM120/SM121 preparation and 3-tier predictive MoE
offloading for GLM-5.3 and Qwen3.8 with automatic pinned Hugging Face
predictor downloads, thin recipe hooks, strict checkpoint schema
validation, and zero change to default non-offloaded exports. Measured
component checks verify bit-exact slab packing, 3-tier demand paging and
non-polluting tiled prefill, live Hugging Face checkpoint retrieval, and
memory-safe CUDA execution of demand, ShadowRecurDepthAttn,
Embed-Reshaper, and direct-prefetch kernels. No end-to-end flare run
serving throughput result is claimed by this PR.

Supporting evidence and limitations:
Tested on SM120 (NVIDIA RTX PRO 6000 Blackwell Max-Q) with PYTHONPATH
pointing at NVIDIA/hyperflare-inference#711 (d86a686e):
- CPU contracts and affected recipe tests: 93 passed, 0 failed, 100
  skipped (GPU/checkpoint-gated), including HF URI/download contracts,
  ShadowRecurDepthAttn schema validation, and lazy import checks.
- Live Hugging Face download validation: TieredMoeAttachment.resolve_parameters
  and resolve_predictor_weights downloaded glm53/model.safetensors,
  glm53/knapsack.safetensors, qwen38/model.safetensors, and
  qwen38/knapsack.safetensors from
  local-inference-lab/hyperflare-offload-predictors@dcde6ca1e9e0a598b4d9ab6b76b0b179a8d30fe0
  and validated all 4 files with validate_offload_checkpoint.
- CUDA integration tests under compute-sanitizer --tool memcheck
  --error-exitcode 1 (tests/components/test_tiered_moe_offload_cuda.py):
  5/5 passed, 0 errors across device/host completion ABI modes,
  full-resident fast path, Embed-Reshaper, ShadowRecurDepthAttn layers
  0 and 1, and direct prefetch.
- Existing GPU recipe tests (qwen38/glm53 moe and weight suites): 49
  passed, 0 failed, 96 skipped.
Limitations: requires NVIDIA/hyperflare-inference#711 to merge and
uv.lock to update before CI can resolve AsyncTransferChannel; single-GPU
TP=1 and --no-mixed-prefill only; full-checkpoint export and live flare
run qualification were not re-run on this branch.

Design-Signed-Off-By: Antigravity (Gemini); design-review=6fcc
Signed-off-by: Luke Alonso <lalonso@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:memory Memory budgets, allocation lifetimes, scratch sharing, and capacity. area:preparation Ignition checkpoint loading, tuning, compilation, capture, and export. enhancement New feature or request 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.

2 participants