Recommendation: Changes Requested
The 2-way (codec, compute) Green Context generalization is a well-scoped, model-agnostic continuation of #709 / #701, and its plan_sm_split arithmetic, cluster-dimension 3D product checks, proto field numbering, and ScratchArena weakest-link (min) reservation tracking are sound. However, two verified blockers must be resolved before merge: (1) the PR depends on unpinned b12x APIs from companion local-inference-lab/flashinfer#217, which will break the new test_capture_graph_metadata.py test on the pinned revision and silently turn min_compute_sms capture into a no-op via except ImportError; and (2) GreenContextPartition::create launders actual_compute_sm.sm_coscheduled_alignment with .max(group_params[compute_index].coscheduled_sm_count), rendering the post-creation alignment guard unconditionally dead and masking driver downgrades in load-time cluster validation. One normative-doc contradiction (docs/runtime-core-design.md) should also be updated alongside the code.
Merge Risk
Level: Medium
- Unpinned external dependency (
pyproject.toml:47): Clean checkouts and CI pinned toflashinfer-pythonrev1441ce86(from#707/ FlashInfer#213) lackb12x._lib.utils.device.{track_capture_min_compute_sms, record_min_compute_sms}, breaking the new unit test at import time and silently zeroingmin_compute_smsduring capture. - Fleet-wide behavioral change on
--lossless-kv-compression gpu: Every rank of every core (including standard non-worker and multi-rank cores) now retains the primary CUDA context, reserves one aligned codec partition (e.g., 8 SMs on SM103/SM120), and enforces fail-closed load checks for Green Context API availability,min_compute_sms, and kernel cluster dimensions. - Hardware coverage gap: The motivating bug (
#701) was observed on SM103 under live multi-request serving, whereas validation consists of#[ignore]d SM120 component tests without fullignition export+flare run --lossless-kv-compression gpuor SM103/SM121 execution (disclosed in the PR's Limitations).
Walkthrough
- Per-graph SM-budget manifest fields (
helios/proto/{core,runtime_core}.proto,heliopause/src/export/{mod,capture,core}.rs,ignition/preparation/{capture,runtime_core,runtime_core_pb2}.py,helios/src/runtime_core/{format,protobuf,metadata,describe,protection,selection}.rs,helios/src/core/*.rs): Adds additive proto3 fieldsuint32 min_compute_sms = 7anduint32 max_cluster_size = 8(0 = unspecified) onGraphandGraphIndex, wrapscapture_forwardsinb12x._lib.utils.device.track_capture_min_compute_sms(), and computes per-graph(min_compute_sms, max_cluster_size)fromCU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION(4) merged with the declared floor inheliopause/src/export/capture.rs:463-500, 3438-3449. - 2-way
(codec, compute)and 3-way(worker, codec, compute)Green Contexts (helios/src/runtime_core/{persistent_worker,mod,model}.rs): Generalizesplan_sm_splitandGreenContextPartition::createfromu32toOption<u32>worker SMs withmin_compute_sms/max_cluster_sizebounds and no fallback belowmax_cluster_size; addsNativeResources::initialize_with_optionsinvoked frommodel.rs:718-733whenever offload +KvCompression::Gpuis active; enforces per-graphmin_compute_smsand per-node cluster size / co-scheduled alignment inprepare_graphs(mod.rs:943-980, 1067-1096); guards nullworker_context/worker_streamon setup and teardown. ScratchArenacooperative SM reservation contract (ignition/preparation/scratch.py,tests/preparation/test_scratch.py): Addsmin_reserve_sms,reserve_sms_floor,require_reserve_sms,resolve_reserve_sms,register_cooperative_plan, andregister_parallel(..., reserve_sms=)with bidirectional fail-closed validation for companionhyperflare-recipes#157.- Docs & tests (
docs/prefix-cache-offload.md,helios/manifest.md,helios/src/runtime_core/persistent_worker.rs,heliopause/src/export/capture.rs,tests/preparation/{test_scratch,test_capture_graph_metadata}.py): Updates offload and manifest docs for the 2-way(codec, compute)topology and adds CPU unit tests plus an#[ignore]d SM120 2-way GPU codec concurrency test.
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt-injection or instruction-like content; kernel attribute buffer length is validated to 64 bytes (
helios/src/runtime_core/format.rs:592) before indexingbytes[0..12](mod.rs:1068-1070);Discord: lukealonsopresent. - [WARN] Charter & value fit: Core change is a model-agnostic, root-cause completion of P1
#701, and the four-part PR description + limitations are complete; however, relying on unpinnedlocal-inference-lab/flashinfer#217with a silentImportError -> 0fallback violates explicit pinning and fail-closed error handling (AGENTS.md:184-186), anddocs/runtime-core-design.md:654-696is left contradicting the new topology. - [PASS] Related / duplicate / conflict check: Genuinely additive over merged
#709(which covered persistent-worker cores only); note semantic interaction with open#640(rank 0 worker+codec 3-way vs peer rank 2-way yields asymmetriccompute_sm_countacross ranks) and textual overlap with open#314on proto/capture files (informational only). - [WARN] Tests & verification evidence: Substantial CPU suites and SM120
#[ignore]d CUDA tests reported, buttest_capture_forwards_records_min_compute_sms_and_emits_only_when_nonzeroimports an unpinnedb12xsymbol (test_capture_graph_metadata.py:599), no legacy wire-bytes decode test for omitted fields 7/8 was added, and SM103 / end-to-endflare run --lossless-kv-compression gpuremains unrun (disclosed).
Blockers
-
Unpinned
flashinfer#217dependency breaks the new Python test on pinned checkouts and silently disablesmin_compute_smscapture (pyproject.toml:47,ignition/preparation/capture.py:78-83,tests/preparation/test_capture_graph_metadata.py:599)pyproject.toml:47is unchanged and still pinsflashinfer-pythontorev = "1441ce862ffbc9d8550fdda7ad90e97ca04f4b8e"(landed in#707for FlashInfer#213), which predates companionlocal-inference-lab/flashinfer#217.tests/preparation/test_capture_graph_metadata.py:599unconditionally runsfrom b12x._lib.utils.device import record_min_compute_sms, which will fail withImportErroron the pinned revision.ignition/preparation/capture.py:78-83wrapsfrom b12x._lib.utils.device import track_capture_min_compute_smsinexcept ImportError: return nullcontext({"min_compute_sms": 0}), silently degrading exportedmin_compute_smsfloors to0on the pinned revision instead of failing closed (AGENTS.md:184-186).- Fix: Merge
local-inference-lab/flashinfer#217, bumppyproject.toml:47to pin the merged commit, and remove the silentexcept ImportErrorfallback inignition/preparation/capture.py:78-83(or raise an explicitRuntimeError/ImportErroridentifying the requiredflashinfer-pythonrevision).
-
compute_coscheduled_alignmentis overwritten with.max(group_params[compute_index].coscheduled_sm_count), making the post-creation alignment guard dead and defeating load-time cluster validation on driver downgrade (helios/src/runtime_core/persistent_worker.rs:359-369,:455-457,:490-496;helios/src/runtime_core/mod.rs:958,:1087-1094)- At
persistent_worker.rs:359-362,group_params[compute_index].coscheduled_sm_count < required_compute_coscheduledalready returnsErr, andgroup_paramsis never modified afterward (whilecompute_split.sm_coscheduled_alignmentis only checked againstbaseline_coscheduled, notrequired_compute_coscheduled). - At
:455-457,partition.compute_coscheduled_alignmentis assignedactual_compute_sm.sm_coscheduled_alignment.max(group_params[compute_index].coscheduled_sm_count). Becausegroup_params[compute_index].coscheduled_sm_count >= required_compute_coscheduledis already guaranteed after:360, the checkpartition.compute_coscheduled_alignment < required_compute_coscheduledat:491is unconditionally dead code. - Downstream,
prepare_graphs(mod.rs:958,:1087-1094) validates kernelcluster_size <= partition.compute_coscheduled_alignment. In#532on SM103,cuGreenCtxGetDevResourcereportedactual_compute_sm.sm_coscheduled_alignment == 16directly without.max(...). Taking.max(group_params[compute_index].coscheduled_sm_count)masks any case where the driver returns a lower actual alignment (e.g.,8when16was required formax_cluster_size = 16), silently passing oversized 16-CTA cluster nodes through load-time validation and printing the requested rather than actual alignment in test output (:3782). - Fix: Assign
partition.compute_coscheduled_alignment = actual_compute_sm.sm_coscheduled_alignmentdirectly, and checkcompute_split.sm_coscheduled_alignment < required_compute_coscheduled(:359) andactual_compute_sm.sm_coscheduled_alignment < required_compute_coscheduled(:490). (If SM120's driver genuinely reports8inactual_compute_sm.sm_coscheduled_alignmenteven when a 16-SM co-scheduled group was granted, verify whether SM120 actually honors 16-CTA clusters in that partition and remove the dead:491check rather than laundering the reported alignment through.max().)
- At
Should Fix
- Update contradicted normative design docs (
docs/runtime-core-design.md:654-696,docs/core-format-design.md:222)docs/runtime-core-design.md:654-696still scopes Green Context partitioning solely to single-rank cores declaringExecution.persistent_workersand enumerates only 2-way(worker, compute)and 3-way(worker, codec, compute)topologies, contradicting this PR's fleet-wide 2-way(codec, compute)split for standard and multi-rank cores and omitting the newmin_compute_sms/max_cluster_sizeload-time validation.docs/core-format-design.md:222lists theGraphrecord fields without the new optionalmin_compute_smsandmax_cluster_sizebounds.- Fix: Update
docs/runtime-core-design.md:654-696to cover all three partition topologies (including non-worker and multi-rank cores under--lossless-kv-compression gpu) and the SM-floor/cluster checks, and addmin_compute_sms/max_cluster_sizeto theGraphrow indocs/core-format-design.md:222.
Subtract / Simplify
- Drop the no-op
plan=branch inScratchArena.resolve_reserve_smsand deduplicate the 5× validation check (ignition/preparation/scratch.py:62-63,:122-123,:137-146,:150-151,:174-175): Every write toself._parallel_reserve_sms[key]also updatesself._max_parallel_reserve_smsviamax(:186-187), andself.reserve_sms_floorreturnsmax(self._min_reserve_sms, self._max_parallel_reserve_sms)(:118). Thus_parallel_reserve_sms.get(id(plan), 0) <= self.reserve_sms_flooralways holds, making lines:144-145a provable no-op (keep_parallel_reserve_smsitself, asregister_cooperative_planuses it at:158for per-plan checks). Also extract a single_validate_reserve_sms(value, name="reserve_sms")helper for the five identicaltype(...) is not int or < 0checks. - Replace
(Option<u32>, bool)with an enum inplan_sm_split/GreenContextPartition::create(helios/src/runtime_core/persistent_worker.rs:85-105,:157,:247-254): APartitionRequestenum (Worker(NonZeroU32),Codec,WorkerAndCodec(NonZeroU32)) makes(None, false)and(Some(0), _)unrepresentable, removes two error checks (:96-105) andunreachable!()(:157), and collapses two separate arguments threaded throughmod.rs. - Deduplicate cluster-dimension attribute parsing (
heliopause/src/export/capture.rs:463-489andhelios/src/runtime_core/mod.rs:1067-1078): Both sites parseCU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION(4) with identical 12-byte(cx, cy, cz)unpacking,.max(1)product, and overflow error, withmod.rs:1067using bare literal4. Share one named constant/helper. - Collapse duplicate
core.graphsfolds and repeated CPU-fallback hint (helios/src/runtime_core/mod.rs:795-808,:394,:972;persistent_worker.rs:259,:348,:480): Compute(min_compute_sms, max_cluster_size)in a singlefoldovercore.graphs, and share aconst CPU_CODEC_HINT: &str = "; use --lossless-kv-compression cpu";. - Drop unused
RecordedExportGraph(..., min_compute_sms=...)dual channel (ignition/preparation/runtime_core.py:184-188,:299-301):capture.py:244-245always attaches_flare_min_compute_smsdirectly on the returned graph, so the constructor kwarg is only used bytests/preparation/test_capture_graph_metadata.py:637-644.
Nits
ignition/preparation/scratch.py:231-235:release_preparation()clears_parallel_reserve_smsand_cooperative_plansbut leaves_min_reserve_smsand_max_parallel_reserve_smsintact, soarena.reserve_sms_floorstill returns the old floor after release (reset both to0or guardreserve_sms_floorwithself._require_active()).helios/manifest.md:146: still says "destroys both green contexts" next to the updated 2-way/3-way wording on lines114-135-> "destroys all created green contexts".docs/core-design.md:821anddocs/preparation-development.md:256: still describeScratchArena.register_parallelas workspace sizing only.helios/proto/{core,runtime_core}.proto&heliopause/src/export/capture.rs:465-500: note in the proto comment or PR description that newly exported graphs with unclustered kernel nodes emit(min_compute_sms=1, max_cluster_size=1)and foldmax_cluster_sizeintomin_compute_sms, while0represents legacy/unspecified or kernel-free graphs.helios/src/runtime_core/protobuf.rs: add a small wire-decode test confirming serializedGraphIndex/payload::Graphbytes omitting fields 7 and 8 decode to(0, 0).
Dropped on verification
- "
register_cooperative_planusesmin(prev, reserve_sms)instead ofmax, weakening the floor" (ignition/preparation/scratch.py:163-164): Disproved._cooperative_plans[key]tracks the guaranteed SM headroom provided by a plan's cooperative kernels (checked viadeclared < requiredat:131and:179). When multiple cooperative ops register on one plan (e.g., 8 and 4), the safe headroom across all ops is the weakest linkmin(8, 4) = 4; changing tomaxwould mask under-reserved kernels and allow deadlocks. - "
resolve_reserve_smsignores_cooperative_plans" (ignition/preparation/scratch.py:137-146): Disproved.resolve_reserve_smscomputes the required overlap floor before a cooperative plan registers its reservation; reading_cooperative_planswould conflate prior voluntary reservations with overlap demand. - "
cuDevResourceGenerateDeschandles leak on partial failure inGreenContextPartition::create" (helios/src/runtime_core/persistent_worker.rs:370-392): Disproved. The CUDA Driver API has no destroy/free function forCUdevResourceDesc(neither incuda.h(not opened) nor indriver.rs:173-193); descriptors are never destroyed on the success path either. - "
NativeResources::load_prepared/PayloadAuthorizedCore::loadhardcodereserve_codec_partition = false, skipping codec isolation" (helios/src/runtime_core/mod.rs:335,:342-344): Disproved. Those entry points are standalone single-rank raw core loaders with noLoadOptionsand no prefix-cache offload or GPU codec; persistent-worker cores still initialize green contexts (wants_worker.is_some()), and serving with offload flows throughNativeModel::load_agreeing(model.rs:718-734,:859-867), which passesreserve_codec_partitionon every rank including payload cores. - "
min_reserve_smsaccepted and ignored whenoverlap=Falseis a bug" (ignition/preparation/scratch.py:59-63,:116-117): Intentionally designed and pinned bytests/preparation/test_scratch.py:588-591so callers can passScratchArena(device, overlap=cfg.overlap, min_reserve_sms=4)without branching. - "
_parallel_reserve_smshas no other reader and can be deleted": Disproved.register_cooperative_planreadsself._parallel_reserve_sms.get(key, 0)atignition/preparation/scratch.py:158for per-plan checks (only the lookup insideresolve_reserve_sms:144-145is a no-op). - "
model.rsgating change allows cores withoutgpu_moduleto reserve codec SMs": Disproved.helios/src/runtime_core/model.rs:663-669rejects any core lacking an embedded GPU codec module whencompression == KvCompression::Gpubefore line718is reached (and#709commite899a4fealready made that cleanup). - "Unapproved captured-graph op-family addition and missing Kani harness gate violation": Disproved. Additive scalar metadata fields (
min_compute_sms,max_cluster_size,0 = unspecified) onGraph/GraphIndexdo not add a captured-graph operation family (docs/design-review.md:22-25), and no Kani harnesses exist forpersistent_worker.rsorheliopause(#[kani::proof]covers onlyasync_transfer,model, andoutput/tagged). - "
ScratchArenaviolates Charter 'hypothetical future consumer' rule": Overstated. In Flare's multi-repo layout (docs/design-review.md:42-46),ignition/preparation/*is the library consumed bylocal-inference-lab/hyperflare-recipes(matching#709'scodec_layoutprecedent), andhyperflare-recipes#157is an active companion PR. - "Recording
(1, 1)for unclustered kernels ingraph_sm_requirementsis a defect" (heliopause/src/export/capture.rs:465-500): Explicitly tested (capture.rs:5671) and behaviorally identical to(0, 0)at load time (coscheduled >= 2,avail_sms >= 1); downgraded to a documentation Nit. - "Stale-base
pr_diffhunks (AsyncTransfer,ExternalExtentTable,Capacity::DEVICE_POOL,Engram*,.github/workflows/*)": Artifacts of stale diff base already merged onmain; reconciled againstpr_files(27 files, +1438/−285).