Recommendation: Changes Requested
The core of this PR — a fleet-wide 2-way (codec, compute) Green Context split for non-worker cores, gated on options.prefix_cache.compression == KvCompression::Gpu (helios/src/runtime_core/model.rs:718-733) rather than on model identity — is at the right layer, is model-agnostic, and is a defensible residual of priority:P1 #701. The manifest field additions are additive and plumbed end to end, and the load-time SM/cluster validation is genuinely fail-closed. But one verified code defect defeats the PR's own headline invariant: compute_coscheduled_alignment is laundered through .max(...) (persistent_worker.rs:455-457), which makes half of the guard at :490-496 unsatisfiable and feeds a fabricated alignment into the per-node cluster check at mod.rs:1087-1094, so a driver-downgraded partition is accepted with a 16-CTA cluster validation it cannot honour. Four smaller verified issues (a fabricated min_compute_sms >= 1 that voids the documented 0 = unspecified sentinel, a silent ImportError → 0 fallback on the external API the whole SM-floor gate depends on, an inverted min() floor aggregation, and a stale normative design doc) round out the request.
Merge Risk
Level: High
- The blocking defect is in the exact code path the PR exists to harden, and it silently accepts a partition the PR claims to reject — the failure surfaces later as a replay-time cluster-launch fault on hardware the author did not test (SM103).
- The SM-floor half is a silent no-op unless the pinned
flashinfer-pythonrev already exportstrack_capture_min_compute_sms;pyproject.toml:47is unchanged by this PR and still pins rev1441ce86…. - Every rank with prefix-cache offload +
--lossless-kv-compression gpunow takes the primary-context/Green-Context path and can refuse to load (mod.rs:386-396,persistent_worker.rs:137-170,mod.rs:964-980,mod.rs:1079-1094), permanently withholding one aligned codec partition from compute (~8 SMs, ≈4.3% of a 188-SM SM120 card).
Walkthrough
- Manifest SM bounds.
Graph/GraphIndexgainuint32 min_compute_sms = 7anduint32 max_cluster_size = 8, documented0 = unspecified(helios/proto/core.proto:251-254,helios/proto/runtime_core.proto:750-753); decode and pass-through informat.rs:219-228,protobuf.rs:583-600and:1507-1520,describe.rs:543-545, plus struct-literal churn inhelios/src/core/*. - Capture side.
heliopause/src/export/capture.rs:463-500parsesCU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION(id 4) as three little-endian u32s withchecked_mul, folds max cluster size into the declared floor, and writes both intowire::GraphIndexat:3438-3449. Python capture wraps each graph in_track_capture_min_compute_sms()(ignition/preparation/capture.py:232-245);runtime_core.py:296-305validates and attaches it to all three graph handle shapes. - Green contexts.
requested_worker_sms: u32 → Option<u32>;plan_sm_split(device_sm, Option<u32>, reserve_codec_partition, min_compute_sms, max_cluster_size)builds an optional worker group, an optional one-minimal-partition codec group, and a backfill compute group (persistent_worker.rs:85-223);GreenContextPartitiongainscodec_green_ctx/codec_context/codec_sm_countwith null-guarded teardown (:556-595);offload_context()returns the codec context when present, else the base context (mod.rs:1511-1516), andmodel.rs:1065now uses it instead ofexecution_context(). - Load-time validation.
prepare_kernelsaggregatesmax(min_compute_sms)andmax(max_cluster_size)across non-worker graphs (mod.rs:795-808) and sizes the compute partition from both;prepare_graphsrejectsgraph.min_compute_sms > partition SMswith the--lossless-kv-compression cpuhint (:964-980) and rejects kernel cluster dimensions exceeding the partition SM count or co-scheduled alignment (:1067-1096). ScratchArenaaddsmin_reserve_sms,reserve_sms_floor,require_reserve_sms,resolve_reserve_sms,register_cooperative_plan, andregister_parallel(..., reserve_sms=)with bidirectional checks (ignition/preparation/scratch.py:59-188);docs/prefix-cache-offload.md:59-66andhelios/manifest.md:111-135document the new topology.
Pre-merge Checks
- [PASS] Security / malicious screen: No prompt injection, no credential or permission handling, no new network surface; PR body and code contain nothing addressed to reviewers.
- [PASS] Charter & value fit: Enablement keys on a serving option, not a model name (
model.rs:718-719), satisfying "keep the runtime small and model-agnostic"; driven by open priority:P1 #701, not speculative. The unapprovedScratchArenasurface is a should-fix, not a charter violation. - [WARN] Related / duplicate / conflict check: No textual conflict with #698 or #640; a real semantic interaction exists with open #640 (rank 0 with a worker + gpu compression gets a 3-way split while peer ranks without a worker get 2-way, so
compute_sm_countstays asymmetric), unmentioned in the description but not a defect in this diff. - [WARN] Tests & verification evidence: Substantive Rust unit tests (
plan_sm_splitmatrix,graph_sm_requirements, two#[ignore]d SM120 CUDA tests asserting null worker context/stream,codec_sm_count >= 8,offload_context() == codec_context, and 4096 limits on both contexts) and Python tests exist, and limitations are disclosed — but there is no old-core load/serve compatibility check (AGENTS.md:435-448,docs/verification.md:32-33), noignition export+ live serve, and no SM103/SM121 run for an SM103-observed bug.
Blockers
-
compute_coscheduled_alignmentis fabricated, which makes half of the create-time guard unsatisfiable and lets a downgraded partition pass the per-node cluster check.helios/src/runtime_core/persistent_worker.rs:454-457:partition.compute_coscheduled_alignment = actual_compute_sm .sm_coscheduled_alignment .max(group_params[compute_index].coscheduled_sm_count);group_params[compute_index].coscheduled_sm_countis set torequired_compute_coscheduled(:189) or toPREFERRED_COMPUTE_COSCHEDULED_SMS = 16, and the latter branch is only entered whenrequired_compute_coscheduled < 16(:195-200). Thereforegroup_params[compute].coscheduled_sm_count >= required_compute_coscheduledalways, so the second disjunct at:490-496(partition.compute_coscheduled_alignment < required_compute_coscheduled) can never be true. The first disjunct (actual_compute_sm.sm_coscheduled_alignment < baseline_coscheduled) is live, but only catches a drop below the baseline alignment, never a drop below the required alignment derived frommax_cluster_size— exactly the case the guard's message ("compute green context partition lost required co-scheduled SM alignment") exists for.The fabrication propagates:
prepare_graphsreadsSome(partition.compute_coscheduled_alignment)(helios/src/runtime_core/mod.rs:958) and compares it per attribute at:1087-1094. Withmin_sm_partition_size = 8,sm_coscheduled_alignment = 8and one graph declaringmax_cluster_size = 16,required_compute_coscheduled = 16; if the driver downgrades the request to an 8-SM-aligned compute resource,:490(8 < 8) and:491(max(8,16)=16 < 16) both evaluate false, the partition is accepted, and a 16-CTA cluster node then satisfiescluster_size > alignment=16 > 16= false. The PR's stated invariant ("no fallback belowmax_cluster_size") is silently defeated, and the diagnostic printed by the new tests (:3037-3040,:3592-3595) cannot distinguish requested from actual alignment.mainrecorded the driver's real value (persistent_worker.rs:265atmain:partition.compute_coscheduled_alignment = actual_compute_sm.sm_coscheduled_alignment;), so this is a regression introduced here.Fix: stop laundering the value and compare once against the real output:
partition.compute_coscheduled_alignment = actual_compute_sm.sm_coscheduled_alignment; if actual_compute_sm.sm_coscheduled_alignment < required_compute_coscheduled { return Err(invalid(format!( "compute green context partition returned co-scheduled alignment {}, below required {}", actual_compute_sm.sm_coscheduled_alignment, required_compute_coscheduled ))); }baseline_coscheduled <= required_compute_coscheduledholds by construction at:108-114, so one comparison covers both.
Should Fix
heliopausereportsmin_compute_sms >= 1andmax_cluster_size >= 1for every exported graph, voiding the documented0 = unspecifiedsentinel.heliopause/src/export/capture.rs:465-472returnsOk(1)when attribute 4 is absent, and:491-499setsmin_compute_sms = declared.min(max_cluster_size). A plain decode graph with no clustered kernels and no b12x floor therefore serialises(1, 1), so a reader can never distinguish "no floor declared" from a real 1-SM floor, nor a genuine 1-SM floor from a 16-CTA cluster's implicit 16-SM floor — contradicting the proto comment the description cites for backward compatibility (helios/proto/core.proto:251-254). The.max()fold additionally double-counts cluster size into the SM floor, andpersistent_worker.rs:108-114consumesmax_cluster_sizeindependently anyway, so the fold buys nothing. The new unit test locks the wrong behaviour in (capture.rs:5671:assert_eq!(graph_sm_requirements(&nodes[..1], 0)?, (1, 1));). Fix: return0when the attribute is absent, drop the fold (let min_compute_sms = declared_min_compute_sms;), and update the test to(0, 0)/(128, 0).- The load-time SM-floor gate silently becomes a no-op if the pinned b12x lacks the new API.
ignition/preparation/capture.py:78-83returnsnullcontext({"min_compute_sms": 0})onImportError, and this PR changes no pin (pyproject.toml:47still pinsflashinfer-pythonto rev1441ce862ffbc9d8550fdda7ad90e97ca04f4b8e;pyproject.tomlis not inpr_files). On a rev withouttrack_capture_min_compute_sms, every graph exports floor0and the advertised rejection atmod.rs:964-980/persistent_worker.rs:137-170never fires — a silent substitution of execution behaviour, whichAGENTS.md:182-193prohibits. The companion test also importsrecord_min_compute_smsat module top (tests/preparation/test_capture_graph_metadata.py:599), so it errors rather than skips on an older pin. Fix: bump/verify the pin to a rev containing the API, and make the missing tracker a hard failure (or an explicit, named skip) instead of0. register_cooperative_planaggregates the reservation floor withmin(), so a re-registration can silently weaken it.ignition/preparation/scratch.py:163-164:self._cooperative_plans[key] = reserve_sms if prev is None else min(prev, reserve_sms). The guard at:158computesrequired = max(self._min_reserve_sms, self._parallel_reserve_sms.get(key, 0))and never includesprev, so a lowering re-registration always passes. Concretely:register_cooperative_plan(p, reserve_sms=8)records 8;register_cooperative_plan(p, reserve_sms=4)passes the guard (required == 0) and replaces 8 withmin(8, 4) = 4; a correctly annotatedregister_parallel(p, q, reserve_sms=6)then raises. A floor must be monotone; every other aggregate in the class usesmax(:135,:186-187). Not exercised bytests/preparation/test_scratch.py:548-584. Fix:self._cooperative_plans[key] = max(prev or 0, reserve_sms).docs/runtime-core-design.md:654-696now contradicts the shipped behaviour. The section — which #709 itself rewrote — is scoped to "When a single-rank core declares an entry inExecution.persistent_workers" and lists only "two groups … or three groups … when prefix-cache offload is enabled with--lossless-kv-compression gpu". The PR makes a 2-way(codec, compute)split with no worker entry the shipped default for every non-worker core (model.rs:718-733,mod.rs:386-396), a topology that document says does not exist.docs/prefix-cache-offload.md:59-66andhelios/manifest.md:111-135were updated; this file was not, andAGENTS.md:228names it as the required doc for Protobuf/core-loading changes. Also stale: theGraphrow atdocs/core-format-design.md:222, which enumerates the record's fields and now omits the two fields Helios reads at load. Fix: update both.- The public single-rank loader hardcodes
reserve_codec_partition = false, so codec isolation and both new bounds are skipped on that path.mod.rs:335(prepare_kernels(..., None, false)— the explicitfalseis added by this PR) andmod.rs:342-344(initialize→initialize_with_options(.., false)), reached fromNativeResources::load(:208),load_any(:232),load_selected(:269) andPayloadAuthorizedCore::load(protection.rs:2836). For a codec-enabled non-worker core loaded there,primary_contextisfalse(:386),green_partitionstaysNone(:793), every graph instantiates onself.context(:962),offload_context()falls back to the base context (:1511-1516), and neithermin_compute_sms(:964-980) nor the cluster check (:1067-1096) is applied — silently. The main serving path is correct (model.rs:729-733,:859-867), and no production caller of theload_preparedpath was found (onlyevent_tests.rs:19,helios/tests/tools/test_{fixed_,}runtime_core.rs, and in-module tests), which is why this is not a blocker. Fix: thread the flag (or aLoadOptions/KvCompressionargument) throughload_prepared/initialize/PayloadAuthorizedCore::load, or fail closed when a core needs codec SMs and the flag is absent.
Subtract / Simplify
resolve_reserve_sms(..., plan=...)is provably a no-op — delete the kwarg and_parallel_reserve_sms.ignition/preparation/scratch.py:137-146:floor = self.reserve_sms_floorismax(self._min_reserve_sms, self._max_parallel_reserve_sms), and every_parallel_reserve_sms[key]is assignedmax(..., reserve_sms)in lockstep with_max_parallel_reserve_sms = max(..., reserve_sms)(:186-187), soper_plan <= _max_parallel_reserve_sms <= flooralways andmax(floor, per_plan) == floor. The body reduces toreturn max(requested, self.reserve_sms_floor). The test that appears to cover it (tests/preparation/test_scratch.py:559) cannot distinguish the branch becauseregister_parallel(plan_a, plan_b, reserve_sms=4)at:556already raised the arena-wide max to 4.- Split out or drop the whole
ScratchArenasurface until it has a consumer.register_cooperative_plan,require_reserve_sms,resolve_reserve_sms,reserve_sms_floor, andmin_reserve_smsappear only inignition/preparation/scratch.py:59-188andtests/preparation/test_scratch.py:548-607; no recipe, component, or preparation path calls them, anddocs/core-design.md:821/docs/preparation-development.md:256still describeregister_parallelas byte sizing only.AGENTS.md:167-169("Hypothetical future consumers … do not establish a need") and:188-193("Do not present scaffolding or partially wired features as supported") apply directly, and 139 lines of it ride with a CUDA fix. - The cluster-dimension decode is written twice, with a magic
4on only one side. Export uses a named constant and helper (capture.rs:462-489); load re-implements the identical parse with a bare literal athelios/src/runtime_core/mod.rs:1067-1078— same attribute id, same three-u32 layout, samemax(1)product, same overflow message. Move one decode next to thewire::Attributetype and call it from both. - Duplicated Green Context API guard.
mod.rs:387-396rejects the missing-driver case beforepersistent_worker::createcan run, so theok_or_elseatpersistent_worker.rs:255-261with the same message is unreachable from the load path. Keep one. - Two identical passes over
core.graphs.mod.rs:795-808walks the graph list twice, once per field; onefold((0, 0), ..)or aCore::graph_sm_requirements()returning(u32, u32)(mirroring the identically shaped export-side helper) collapses them. (Option<u32>, bool)encodes an unrepresentable-but-checked state.persistent_worker.rs:85-91and:247-254both take five positionals, forcing the reject check at:96-100, theSome(0)check at:101-105, and theunreachable!()arm at:157. APartitionRequestenum (Worker(u32) | Codec | WorkerAndCodec(u32)) makes all three illegal states unrepresentable and collapses two arguments into one along theinitialize_with_options → prepare_kernels → createpath.
Nits
mod.rs:1079-1086fails a graph whose decodedcluster_size > avail_sms, butmin_compute_sms = declared.max(max_cluster_size)(capture.rs:498) means the earlier check at:964-980already fires for any core this PR's exporter produces; the per-node SM comparison is reachable only for legacy cores with floor0. A comment (or a single field comparison againstgraph.max_cluster_size) would say so."; use --lossless-kv-compression cpu"is spelled out at five sites (mod.rs:394,:972,persistent_worker.rs:259,:348,:480) and substring-matched in three tests (persistent_worker.rs:1251,:1283,:3569); oneconstwould keep them consistent.ScratchArena("cpu", overlap=False, min_reserve_sms=4)validates and then discards the argument (scratch.py:59-63vs:116-117), asymmetric withrequire_reserve_sms, which raises in serial mode (:126-127). Reject a nonzeromin_reserve_smswhenoverlapis false.release_preparation()clears the plan dicts but leaves_min_reserve_sms/_max_parallel_reserve_sms, soreserve_sms_floorsurvives release (scratch.py:231-235); harmless but half-reset.RecordedExportGraph.min_compute_sms(runtime_core.py:184-188) is a second storage channel populated only by tests (test_capture_graph_metadata.py:637); production uses the_flare_min_compute_smsattribute (capture.py:245).
Dropped on verification
- "Graph-contract owner approval is missing" — dropped.
docs/design-review.md:22-26gates approval on a new operation contract; these are two scalar metadata fields on an existingGraph/GraphIndexrecord with unchanged node/edge/parameter encoding, which the same clause allows as a shape/capacity variant.pr_filesconfirmscore.protois exactly +4/−0 andruntime_core.proto+4/−0. - "
cuDevResourceGenerateDeschandles leak on every failure path" — dropped as a defect claim.create()'s cleanup atpersistent_worker.rs:545-552destroys streams and green contexts but not descs; however nocuDevResourceDescDestroybinding exists inhelios/src/runtime_core/driver.rsbefore or after this PR, so this is a pre-existing driver-surface gap, not a regression introduced here. - "
max_cluster_sizeis never captured or plumbed from Python" — false.heliopause/src/export/capture.rs:3438-3439derives it from the exported graph's own kernel node attributes, which is authoritative; a Python-declared value would be redundant. - "
resolve_reserve_smsignoring cooperative declarations is a Major fail-open" — downgraded out. The docstring matches the behaviour ("at leastrequestedand any active overlap SM floor") and there is no in-repo consumer; the no-op body is filed as a subtraction instead. pr_diffover-attribution (host_vmm,async_transfers,Capacity::DEVICE_POOL,EngramTable.Encoding.BF16,EngramHash.Method.IDENTITY,pool_vram_limit) is stale-base drift from already-merged #711/#658/#708, not content of this PR; every finding above is reconciled againstpr_filesand the actual per-file deltas.- "The change reverses #532's
split_sm_groupsdeletion recommendation" — dropped. That was a design opinion in a prior review, not a recorded invariant, and the extension is coherence-preserving. - "Should have run TLA+/
check.py" — not applicable. This PR touches no admission, fence, generation, cancellation, speculation-accounting, compaction/snapshot-alias, offload-aggregation, readiness, or rank-coordination path; green-context creation/teardown are resource-lifetime paths. - "Missing Kani/mutation testing" — dropped from findings. The new arithmetic guards have direct unit coverage for both accept and reject (
persistent_worker.rs:3550-3571,capture.rs:5633-5673);docs/verification.md:21-23permits a contained edit with adequate existing coverage to stand without new machinery. The old-core compatibility gap is real and is stated under Pre-merge Checks rather than as a code finding. - Open #640 interaction, the raw
CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION = 4literal, and#[ignore]withoutFLARE_RUN_CUDA_TESTSgating — reviewed and dropped as non-defects: #640 has no textual conflict and its own review already owns that hazard; the literal sits beside the pre-existing raw-idKERNEL_ATTRIBUTESlist (capture.rs:462); the ignore strings name the requirement and the tests were run explicitly with--ignored. - No prompt-injection content was found in the PR description, comments, or changed code; nothing in the reviewed material attempted to direct my actions.