Explore scratchpad · NVIDIA/hyperflare-inference #723

Raw Markdown for agents: https://autobot.eidonix.com/p/3894127d-98eb-47ae-8301-00431ae36317.md

#1 [high] The change: overview and size

PR #723 (open, ready for review, opened 2026-12-04, head 275b7a5, base main, base commit cc0a49d) by lukealonso (COLLABORATOR). Title: "helios,heliopause,ignition: fleet-wide 2-way codec green contexts, graph SM bounds, and ScratchArena reserve_sms floor". Size per pr_files: 27 files, +1438/-285. Largest: helios/src/runtime_core/persistent_worker.rs (+824/-140), ignition/preparation/runtime_core_pb2.py (+95/-95, regenerated), heliopause/src/export/capture.rs (+86/-0), ignition/preparation/scratch.py (+77/-2), tests/preparation/test_scratch.py (+62), tests/preparation/test_capture_graph_metadata.py (+56), helios/src/runtime_core/mod.rs (+103/-16), helios/manifest.md (+24/-15), docs/prefix-cache-offload.md (+8/-5), proto files core.proto/runtime_core.proto (+4 each).

NOTE: pr_diff with no path returned a much larger diff including files NOT in pr_files (.github/workflows/helios-lifecycle.yml, native-serving.yml, AGENTS.md, docs/TODO.txt, docs/api.md, docs/cli-design.md). Those are almost certainly main-branch drift (the tool diffs against an older base), not part of the PR. The authoritative file list is pr_files. Verified discrepancy worth treating carefully; do not attribute those files to the PR.

Three declared sub-changes:

  1. Backward-compatible proto fields: GraphIndex/Graph uint32 min_compute_sms = 7 and uint32 max_cluster_size = 8 (0 = unspecified); capture side collects them (heliopause capture.rs, ignition capture.py); readers in helios runtime_core + core.
  2. GreenContextPartition generalized from mandatory worker+compute split to optional worker / optional codec / compute (2-way codec+compute, 2-way worker+compute, 3-way).
  3. ignition/preparation/scratch.py ScratchArena gains min_reserve_sms, reserve_sms_floor, require_reserve_sms, resolve_reserve_sms, register_cooperative_plan, register_parallel(reserve_sms=...).

#2 [high] Caveat: pr_diff output is contaminated by base-branch drift

The pr_diff tool (no path arg, and per-path) diffs against a STALE local copy of the base branch: pr_diff includes files that are NOT in pr_files (.github/workflows/helios-lifecycle.yml, native-serving.yml, AGENTS.md, docs/TODO.txt, docs/api.md, docs/cli-design.md) and hunks inside PR files that match already-MERGED PRs. search_history/git fails with "Could not read c513e46a... cannot simplify commit ef38cb93".

Evidence that it is drift, not the PR:

CONCLUSION: trust pr_files counts, not pr_diff hunks. The PR's real delta is the three described sub-changes plus test fixtures.

#3 [high] The change: graph SM-budget manifest fields, capture to enforcement

heliopause/src/export/capture.rs (lines at PR head):

ignition/preparation/capture.py:

ignition/preparation/runtime_core.py:

heliopause/src/export/core.rs:2131-2132 and mod.rs pass through Graph->GraphIndex fields. helios readers: runtime_core/format.rs:226-227 (Graph struct fields), protobuf.rs:586-587 & 1510-1511, describe.rs:543-544 & 789-790 (describe JSON), metadata.rs:381-382.

helios/src/runtime_core/mod.rs enforcement points:

#4 [high] The change: GreenContextPartition 2-way/3-way generalization

Pre-PR (verified on local main): search_code for reserve_codec_partition|fn offload_context|codec_context in helios/src/runtime_core on main => NO MATCHES; ignition/preparation/scratch.py on main has only def register_parallel(self, *plans) at :107.

Post-PR (helios/src/runtime_core/persistent_worker.rs at PR head):

helios/src/runtime_core/mod.rs:

helios/src/runtime_core/model.rs (real delta is 7 lines): :715-717 let reserve_codec_partition = options.prefix_cache.enabled() && options.prefix_cache.compression == crate::offload::KvCompression::Gpu; then NativeResources::initialize_with_options(core, *device, reserve_codec_partition) :726-731 and threaded into prepare_kernels :857-865. So enablement is: prefix cache enabled AND compression == gpu, on every rank — no persistent-worker requirement, and no model-specific branch (charter-aligned).

Pre-PR this was gated differently: #709 (merged 2026-12-03) added reserve_codec_partition "enabled only when options.prefix_cache.enabled() && !model.gpu_codec_cubins.is_empty()" AND only inside the persistent-worker branch (plan_sm_split required worker SMs). PR #723 generalizes it to non-worker cores and drops the cubin condition in favour of compression == Gpu.

#5 [high] The change: ScratchArena reserve_sms floor has zero in-repo callers

ignition/preparation/scratch.py at PR head:

Tests (tests/preparation/test_scratch.py:548-607): floor+biderectional enforcement test and a validation/serial-mode test. Both are pure-CPU (ScratchArena("cpu")), no CUDA required.

USAGE: search_code for register_cooperative_plan|require_reserve_sms|resolve_reserve_sms|min_reserve_sms|reserve_sms_floor across the whole repo returns ONLY ignition/preparation/scratch.py and tests/preparation/test_scratch.py. No in-repo preparation path, recipe, component, or b12x call site passes reserve_sms, and nothing in RECIPES/components consumes resolve_reserve_sms. The repo's own docs still describe only the byte-sizing role: docs/core-design.md:821 "register_parallel(*plans) declares preparation workspaces that must coexist" and docs/preparation-development.md:256 "ScratchArena.register_parallel sizes simultaneous preparation workspaces" — both unchanged by this PR. The PR description says the enforcement is "applied" by the companion recipe PR hyperflare-recipes#157.

#6 [high] Why: #701 (open P1 bug) and merged #709 cover only persistent-worker cores

The problem this PR addresses is the non-persistent-worker half of #701 (open, by ebfio, 2026-12-03, labels bug/performance/priority:P1/triage:investigate): on GB300 SM103 with --lossless-kv-compression gpu (GKV1) the GPU codec ran on rank.execution_context() and collapsed decode from 67.12 tok/s to 0.34–0.61 tok/s while encoding at 6.9–12.4 MB/s, plus a permanent B>=2 hang. Its "Suggested Direction" #1 is literally "bind GKV1 codec streams to ... a dedicated small Green Context partition".

#701 was addressed for persistent-worker cores only by #709 (merged 2026-12-03, by lukealonso): "Reserving a third disjoint SM Green Context partition for GPU codec execution on persistent-worker cores (only when offload and GPU compression are both active)". #709's own text limits the codec partition to cores declaring a PersistentWorker; #723 extends that to standard cores with a 2-way (codec, compute) split, i.e. it is the follow-up for "Standard cores without persistent workers (DeepSeek-V4.1, GLM-5.3, Qwen3.8, Ergo, Gemma)".

Companion open PR #698 (ebfio, 2026-12-02, +65/-53, 1 file helios/src/server/runtime.rs) fixes the cuModuleLoadData startup deadlock of the same bug class. #709 already landed an equivalent reorder plus close_store, so #698 is now largely superseded; #723 does not touch server/runtime.rs at all and therefore neither supersedes nor conflicts with what remains of #698. #698's own note says on SM103 "GKV1 still contends ... because model.rs opens the codec stream on rank.execution_context()" — that residual is exactly what #723 fixes.

Green Context infrastructure lineage: #430 (original-el8, merged 2026-11-23) added Execution.persistent_workers + cuDevSmResourceSplit 2-way split and the #[ignore]d GPU tests; #532 (original-el8, merged 2026-11-26) added the 16-SM PREFERRED_COMPUTE_COSCHEDULED_SMS request with 8-SM fallback (this is the code #723 edits around); #709 (lukealonso, merged 2026-12-03) added the 3-way worker/codec/compute split; #723 generalizes the split to make worker and codec independently optional.

How long wanted: at most ~1 day. #701 opened 2026-12-03 02:18; #709 merged 2026-12-03 20:09; #723 opened 2026-12-04 covering the non-worker remainder. The ScratchArena reserve_sms half has no corresponding issue in the local index at all.

#7 [high] Related work: what #723 adds on top of merged #709, and one doc left stale

Verified by reading #709's diff at origin/main (search_code ref=main: reserve_codec_partition/offload_context/codec_context DO exist in main; search_code on main in helios/src/runtime_core/persistent_worker.rs shows main still has fn plan_sm_split(device_sm: DevSmResource, requested_worker_sms: u32) at :67, GreenContextPartition at :35, PREFERRED_COMPUTE_COSCHEDULED_SMS = 16 at :32).

So what #723 actually changes relative to merged #709:

  1. requested_worker_sms: u32 -> Option<u32>, and the whole worker group becomes optional (green ctx/context/stream created only when worker_index.is_some()). #709's create took the worker unconditionally.
  2. Enablement moves and widens. #709: reserve_codec_partition = prefix cache enabled AND !model.gpu_codec_cubins.is_empty(), used only inside the persistent-worker branch. #723 (helios/src/runtime_core/model.rs :715-717): options.prefix_cache.enabled() && options.prefix_cache.compression == KvCompression::Gpu, threaded into initialize_with_options so the PRIMARY CONTEXT is retained (mod.rs :386) and a green partition is created even on cores with no persistent worker. Dropping the gpu_codec_cubins condition means the reservation is decided before kernels are loaded, i.e. purely from serving options.
  3. Per-graph SM bounds are new: plan_sm_split gains min_compute_sms/max_cluster_size args, SmSplitPlan gains worker_index/codec_index/compute_index/baseline_coscheduled/min_compute_sms, and the 16-CTA preference is suppressed when max_cluster_size already forces >= 16 (:81-83, :195).
  4. mod.rs prepare_graphs gains two new fail-closed checks that did not exist in #709: per-graph min_compute_sms > partition SM count (:960-980) and per-kernel-node cluster dimension vs partition SM count / co-scheduled alignment (:1064-1094, attribute id 4).
  5. Docs: helios/manifest.md (:111-138) now describes 2-way (codec, compute) and per-graph bounds. docs/runtime-core-design.md:654-696 (the normative green-context section, which #709 updated) is NOT in this PR's file list and still describes only "two groups ... when prefix-cache offload does not use GPU compression, or three groups ... when prefix-cache offload is enabled with --lossless-kv-compression gpu" — i.e. it presents the codec partition as existing only alongside a persistent worker. That contradicts the post-PR behaviour (2-way codec+compute on a core with no persistent_workers entry). In #709 the same class of doc gap was a "Should fix" review finding.

#8 [high] Claims and evidence: what is backed, what is unverified

CLAIMS (from PR description) vs evidence found in-tree:

  1. "235 passed / 525 passed / 250 / 247 / 104 passed" — no CI results reproduced here; orientation packet says "CI on the head commit: pending" and the PR has no reviews and no comments at all (pr_comments => "No comments"). All numbers are author-reported and from a single SM120 host (RTX PRO 6000 Blackwell Max-Q, 188 SMs).
  2. The two GPU measurements in the description ("3-way: worker=8 codec=8 compute=172 ... concurrent_coop=138664 (138611.8/s) | gpu_codec_rounds=247" and "2-way: codec=8 compute=180 (cosched=16) | concurrent_coop=73185 | gpu_codec_rounds=126") back ONLY the component-level #[ignore]d tests. Note the 2-way run halves throughput vs the 3-way run (73185 vs 138664 steps/s although the compute partition is LARGER: 180 vs 172 SMs). The two runs used different cooperative kernels/topologies so the comparison is not apples-to-apples, but nothing in the description reconciles it, and no claim is made about it.
  3. The description's headline behavioural claim — "isolates GPU KV-codec execution fleet-wide without model-specific branches" and "rejecting under-provisioned compute partitions or incompatible cluster dimensions at load time rather than deadlocking or silently truncating at replay time" — is NOT measured end-to-end. The description's own Limitations say "Full-checkpoint ignition export + live flare run --lossless-kv-compression gpu serving across multi-GPU cores, SM103/SM121 hardware execution ... were not run locally." So the #701 regression (which was observed on SM103 only) is unverified on the hardware where it was reported.
  4. min_compute_sms capture is unverified end-to-end: the capture path reads b12x._lib.utils.device.track_capture_min_compute_sms() (ignition/preparation/capture.py :78-83), which is new b12x API from the companion flashinfer PR local-inference-lab/flashinfer#217. The pinned flashinfer rev in pyproject.toml:47 is 1441ce862ffbc9d8550fdda7ad90e97ca04f4b8e; if that rev predates #217 the tracker import fails and _track_capture_min_compute_sms silently returns {"min_compute_sms": 0} via the ImportError fallback, so every graph would export 0 and the whole SM-floor half of the PR would be a no-op in practice. Could not resolve the rev offline; worth flagging as the first thing a reviewer checks.
  5. max_cluster_size capture is unsupported-limited: graph_sm_requirements (heliopause/src/export/capture.rs :491-500) raises min_compute_sms to at least max_cluster_size at export, so a graph with a 16-CTA cluster but no b12x floor still gets min_compute_sms >= 16. That means the two new fields are not independent; a reader who only checks max_cluster_size sees a different picture than the loader, which uses min_compute_sms for the SM check (mod.rs :960-980) and max_cluster_size only for co-scheduled alignment.
  6. ScratchArena claim "Turns missing reserve_sms on cooperative plans overlapping concurrent collectives into an immediate preparation-time ValueError" — true of the unit tests (tests/preparation/test_scratch.py:548-607) but with zero in-repo callers (see entry 5) the ValueError only fires once the companion recipe PR local-inference-lab/hyperflare-recipes#157 calls the new API. Until then this half of the PR is inert code.
  7. "Preserves backward compatibility with existing exported cores (min_compute_sms == 0, max_cluster_size == 0)" — supported by the proto comment + 0 = unspecified handling; no fixture loads an old signed core in this PR to prove it (charter line 42 asks exactly for that).
  8. Test hygiene: the two new behaviour tests are #[ignore]d and, unlike the tests #430 added, do NOT check FLARE_RUN_CUDA_TESTS (search_code FLARE_RUN_CUDA_TESTS in persistent_worker.rs => no matches). The description ran them with --ignored. The 2-way test's assertions (persistent_worker.rs:3589-3607) do verify: worker_sm_count == 0, null worker_context/worker_stream, codec_sm_count >= 8, compute_sm_count >= 16, coscheduled >= 8, codec+compute <= total, offload_context() == codec_context, execution_context() == compute_context, offload_context() != context, and CU_LIMIT_STACK_SIZE 4096 on both contexts. It also asserts fail-closed behaviour when min_compute_sms == total_sms (:3550-3572) with the --lossless-kv-compression cpu hint in the message.

#9 [high] People: author lukealonso, prior green-context reviewers/owners, no engagement yet

Author: lukealonso, COLLABORATOR, one of the three charter-named priority contributors ("@voipmonitor, @original-el8, @lukealonso carry extra weight", charter "Respect contributors"). 51 merged PRs and 0 open/closed-unmerged in the last 180 days. Area history: helios/src (36 PRs), docs (31), ignition/preparation (20), tests/preparation (15), flare-cli/src (14).

Their work that this PR builds directly on or reacts to:

Review behaviour: lukealonso has formally reviewed and approved green-context work by others (#430, review APPROVED 2026-11-23 with a "Principle 1 approval for the Execution.persistent_workers captured-graph operation contract"; #532's autobot review was Ready To Merge). They also left substantive inline design objections on #430 (structured vs remainder SM groups; repeated field; bounded drain). That is the same code path #723 now modifies, so their positions there are relevant precedent: they insisted on explicit structured compute groups over cuDevSmResourceSplitByCount remainders, and on bounded drain.

Who else works in these areas: original-el8 (green contexts #430/#532, open #640 rank-0 persistent workers), yatesdr (KV compression #504, selene-manager #612), ebfio (FIRST_TIME_CONTRIBUTOR, filed #701 and PR #698), voipmonitor (ignition scratch/component tuning: #110, #443), kbenkhaled (#664 engram BF16). The orientation packet's "People in these areas: (no commits in these areas in the last 180 days)" is wrong for these files — original-el8 and lukealonso both committed to persistent_worker.rs within that window.

Engagement so far on #723: none. pr_comments returned "No comments"; no reviews; no labels; no CI result on head 275b7a5 at the time of this case file.

#10 [high] Project fit: charter alignment, doc gap, owner-approval gap

CHARTER ALIGNMENT (read_charter):

#11 [high] Reach: who is affected, new fail-closed startup aborts, SM cost, companion dependencies

WHO/WHAT IS AFFECTED

Configuration and defaults (verified by reading the code, not the description):

Compatibility:

Deployment / operator surface:

Documentation touched: docs/prefix-cache-offload.md (+8/-5), helios/manifest.md (+24/-15). Documentation NOT touched but describing the changed behaviour: docs/runtime-core-design.md:654-696 (normative green-context topology), docs/core-design.md:818-825 and docs/preparation-development.md:256 (ScratchArena's documented contract, which says only "sizes simultaneous preparation workspaces" and does not mention reserve_sms).

Dependencies: the capture half depends on unpublished b12x API (track_capture_min_compute_sms) delivered by the companion local-inference-lab/flashinfer#217; the ScratchArena half depends on companion recipe adoption local-inference-lab/hyperflare-recipes#157. Both companions are outside this repository.

#12 [high] Related work: #314 overlap, #640 topology interaction, #698 superseded, no revert

Files touched in the neighbourhood, from items_touching and related_items:

persistent_worker.rs: #723 (this), #314 (open, schopde-nvidia, "Add signed tensor execution for diffusion"), #711 (merged), #709 (merged), #532 (merged), #507 (merged), #430 (merged). scratch.py: #723 (this), #543 (merged, lukealonso, "Remove joint kernel tuning and grouped AOT forward compilation"), #443 (merged, voipmonitor), #110 (merged, voipmonitor).

related_items(723) most-overlapping: #314 (open) 19 files in common — a large open diffusion PR touching the same proto/capture/describe files; a real merge-order interaction (both add proto fields and capture plumbing). #711 (merged) 18 files. #465/#432/#410/#408 (all original-el8, closed) 11-12 files. #720 (merged, lukealonso, external_extents visitors) 7 files. #667, #646, #618, #647 (merged, lukealonso) 5-10 files. #504/#492 (yatesdr) 8 files — the KV compression feature. #664 (kbenkhaled) 8 files. #566, #479 — engram/ignition capture.

Open competing/adjacent PRs on the same mechanism:

Nothing found that competes with, is superseded by, or reverses #723's ScratchArena half — #543 removed joint kernel tuning from the same file and is the closest prior edit.

No revert or "codec green context didn't work" PR/issue found (searched "revert 709 codec green context", "revert lossless kv compression": no matches).

#13 [high] Recent activity: #430 -> #532 -> #709 -> #723 chain, and a reversed review recommendation

Could not read per-commit history for these files: search_history fails with git: error: Could not read c513e46a... fatal: cannot simplify commit ef38cb93..., and the orientation packet's "Recent activity in those areas" section is entirely "(not available)". So the recent-activity picture below is reconstructed from PR metadata instead of commits.

Reconstructed timeline of the areas #723 touches (all 2026):

Relationship to that work: #723 builds directly on #709 (same author, next day) and edits the #430/#532 planner. It reverses none of them: the 2-way worker+compute and 3-way worker+codec+compute behaviours are preserved (tests at persistent_worker.rs :1184-1300 assert the old expectations still hold with the new Option signature). It supersedes #709's model.gpu_codec_cubins.is_empty() gating with a compression == Gpu option check, which is a refinement rather than a reversal.

Note on the stale-base drift in pr_diff: it shows #711's AsyncTransfer/host_vmm/PoolMemoryLimit work inside helios/src/runtime_core/mod.rs and model.rs, plus #658's capture reseal and #664/#708's engram/prompt work. Those are merged on main and are NOT this PR's changes; a reader diffing naively will over-attribute ~700 lines to #723.

#14 [high] Process: ready-for-review, zero reviews, CI pending, 3 separable changes in one PR

PROCESS / STATE at time of case file (2026-12-04):

SIZE, AUTHORITATIVE: 27 files, +1438/-285 per pr_files. Largest single file is helios/src/runtime_core/persistent_worker.rs (+824/-140), 57% of the insertions, and mostly the two new #[ignore]d CUDA tests (the 2-way codec test spans roughly persistent_worker.rs:3295-3792) plus a TestFiles fixture (~66 lines) hoisted for reuse.

The three sub-changes are separable: (a) proto/manifest fields + capture + enforcement — mechanical, and 8 of the touched helios/src/core/* files are pure min_compute_sms: 0, max_cluster_size: 0 struct-literal churn; (b) green-context generalization — the bulk; (c) ScratchArena — 77 lines Python + 62 lines test, independent of (a) and (b). Nothing in the description explains why (c), a preparation-time Python arena change unrelated to Green Contexts, is bundled with a fleet-wide CUDA change; the only link given is that companion recipe PR #157 exercises both. Precedent: yatesdr asked the same on #430 ("Two changes in one PR ... could they be separate PRs, each with its own measured need?").