Recommendation: Changes Requested
The three fixes are real root-cause fixes and the riskiest inverse-guard hypotheses are all disproved by the callee definitions (packed::permits(None) == false, MpSide::world() == 1 for single-host TP≥2, descriptor still used after the new guard). One verified code defect remains — the new codec Green Context never receives the core's recorded CUDA context limits/cache configuration while the two sibling green contexts do — plus two normative documents that the PR leaves contradicting or incomplete about behavior it changes. No blocker, no hot-path regression, no wire/format change.
Merge Risk
Level: Medium
- New CUDA scheduling path (3-way
cuDevSmResourceSplit, context selection for codec kernels and offload DMA) whose headline evidence is an#[ignore]d component test on SM120; SM103/B>=2end-to-end is explicitly unrun (#698,#701). - New hard startup-abort path: devices that fit the pre-existing 2-way split but not 3 partitions now fail to start under
gpucompression (persistent_worker.rs:104-113); declared in the description, remedy names--lossless-kv-compression cpu. - Pool policy relaxation reverses the condition introduced by merged #612 (
yatesdr), and the PR overlaps open #698 (same startup-ordering fix) and #694 (claims.rs).
Walkthrough
ignition/preparation/contract.py:CodecEncoding(IntEnum)(11 ids, block bytes, 4-byte alignment only forFLOAT32_MATRIX_128),_validate_codec_encoding(:208),default_field_encoding(:232), andcodec_layout(..., state_buffer=None)that skipsCONTINUATION_STATE(:264), resolves the row buffer (:280), sorts + bounds-checks row regions (:284-298) and rejects duplicate buffers (:299-305).selene-manager/src/pool/{store_bridge,claims,core,lookup}.rs: packed put/PinAck/claim/lookup permission now keyed on session shape (ranks.is_some()) or slice-layoutworld() > 1;core.rs:641-651negotiatescodec = Nonefor multi-process while keepingoffered_codecfor reconnect.helios/src/runtime_core/persistent_worker.rs:plan_sm_split(..., reserve_codec_partition)emits worker + optional codec + backfill compute groups withcodec_index/compute_index;GreenContextPartitiongainscodec_green_ctx/codec_context/codec_sm_count, created at:284-311/:355-396and destroyed at:451-475.helios/src/runtime_core/{mod,model,memory}.rs:offload_context()(mod.rs:1416-1421) =codec_contextelse the rank base context;prepare_offloaduses it (model.rs:969); poolregistration_contextbecomesranks[0].context(memory.rs:1010); teardown recognizescodec_context(mod.rs:1641).helios/src/server/runtime.rs:crate::offload::open(:683) now precedesRankExecutor::new(:699); freefn close_store(:1172) called on all three early-error paths (:706,:719,:783) witherror.get_or_insertpreserving the original error.docs/prefix-cache-offload.md: documents the third partition, pre-workercuModuleLoadData, and single-host TP≥2 vs multi-process packed rules.
Pre-merge Checks
- [PASS] Security / malicious screen: No injection or instruction-like content;
cuda.rs:471keepsHOST_REGISTER_PORTABLEso the base-context registration stays visible from the codec context; theDiscord: lukealonsoline is required metadata (design-review principle 17). - [PASS] Charter & value fit: Root-cause fix per layer, no per-model branches, no new flags/dependencies, no
.proto/wire/format change (packed v4 and raw v3 bytes untouched); description carries all four required parts plus a limitations section. - [WARN] Related / duplicate / conflict check: Open #698 duplicates the
runtime.rsstartup-ordering fix this PR also implements (its review asked for exactly thisclose_storeownership work); #612'sworld >= 2guard is narrowed; #694 editsclaims.rsadjacently. The diff also carriesPrompt::preserve_message_anchor(runtime.rs:47-52,:288) that this PR does not describe. - [WARN] Tests & verification evidence: TLA+ 8 models + conformance and Layer-1
--releasesuites reported (not independently reproducible here); the new 3-way CUDA test is#[ignore]d and single-host SM120 component-level, while SM103flare run --lossless-kv-compression gpuatB>=2was not run — correctly disclosed, not claimed as measured.
Blockers
None.
Should Fix
- The new codec context never receives the core's recorded CUDA context limits and cache configuration.
helios/src/runtime_core/mod.rs:767-786appliesapply_context_settingsto the primary context (:768) and topartition.worker_context(:783) andpartition.compute_context(:784) only;codec_contextis created atpersistent_worker.rs:388-396and from this PR onward runs every GPU codec kernel and every offload DMA stream (mod.rs:1410-1421→model.rs:969). The repo's own model is that these settings are not inherited by green contexts — hence the two explicit calls — and the pre-existing test asserts exactly that for the worker/compute pair (persistent_worker.rs:2218-2243, comment "verify recorded CUDA context limits propagate into both Green Contexts", assertingCU_LIMIT_STACK_SIZEon both). Result: the samekv_codec_gpukernels run with the core's declared limits/cache config on a non-persistent-worker core and with driver defaults on a persistent-worker core undergpucompression — a core-shape-dependent divergence in kernel-visible context state. Fix: inside theif let Some(worker)arm, beforeself.green_partition = Some(partition), addif !partition.codec_context.is_null() { apply_context_settings(&driver, partition.codec_context, &core.context)?; }, and extend the assertion in the existing green-context test to the codec context (the new#[ignore]d test can assert it too). docs/runtime-core-design.md:642-672now contradicts the shipped load/teardown path and was not updated. The normative core-loading spec still says SMs are partitioned "into two explicit structured SM resource groups" (:648-651), that the recorded limits/cache are applied "to the primary context and both green contexts" (:651-652), and that teardown destroys "worker and compute streams, executables, modules, mappings, green contexts" (:668-672). The implementation is now 2-or-3 groups with acodec_context, and the third context is the one whose teardown is newly special-cased (mod.rs:1641) — exactly the invariant a future teardown edit would need to know. Onlydocs/prefix-cache-offload.mdwas changed. Fix: update that section for the 2-way vs 3-way split,codec_contextexistence/teardown, and which contexts host offload and codec work.selene-manager/PROTOCOL.mddoes not state the new multi-process raw-only rule. §13.x atPROTOCOL.md:1050-1060still only says every process of an instance offers identical capabilities and that "Instance holdings may be raw or packed", with no statement that a session withranksnegotiates raw-only (core.rs:641-651), that packedPutBeginis refused for it (store_bridge.rs:412), or that packed holdings/offers are excluded for a multi-process requester or source (claims.rs:637-642,:922-929,lookup.rs:217-228) while raw v3 stays claimable. AGENTS.md:233 makes this file the governing doc for Selene-manager changes. Fix: add the negotiation and exclusion rule beside the revision-4 envelope section, and state that single-host TP≥2 (single-process,world == 1) remains packed-capable.
Subtract / Simplify
helios/src/runtime_core/persistent_worker.rs:2615adds another full copy of thestruct TestFiles/impl Filesfixture already present earlier in the same file (e.g.:1285); hoist one#[cfg(test)]fixture instead of adding a fifth.helios/src/runtime_core/model.rs:820-821:reserve_codec_partition = options.prefix_cache.enabled() && !model.gpu_codec_cubins.is_empty()reduces tooptions.prefix_cache.compression == KvCompression::Gpu(verified:gpu_codec_cubinsis non-empty only underKvCompression::Gpu,model.rs:629-658, andenabled()is implied). Writing it directly removes the positionalfalseatmod.rs:334and removes the ambiguity the review raised aboutcpu-mode cores.selene-manager: the requester-side conjuncts atclaims.rs:640(!requester_mp) andlookup.rs:226(session.ranks.is_none()) re-verify the invariantcore.rs:646already establishes (codec = Nonewhenranks.is_some()); only the source side needs a gate. Collapsing all three sites (claims.rs:637-642,claims.rs:922-929,lookup.rs:217-228) into onefn packed_caps(&self, sid: u64, source_mp: bool)also removes the third, divergent formulation inget_answer.persistent_worker.rs:94-113: thealigned_codec = 0sentinel makesaligned_worker.checked_add(0)dead whenreserve_codec_partitionis false and duplicates the six-line error message;Option<u32>plus one interpolated message halves that block.
Nits
_validate_codec_encoding(contract.py:209,:215,:217) rejectsnumpy.int32/int64scalars viaisinstance(value, int), so an external recipe that returned a numpy scalar from itsfield_encodingcallback (accepted before this PR) now fails export with a misleading "must be an integer" message. Acceptingnumbers.Integral(keeping theboolrejection) would preserve behavior.contract.py:259-260: thestate_buffertype check sits after therow_regionsearly return, so it is unreachable for a pool with no row regions;contract.py:281/289bounds-checkpool.layout.row_bytes, an attribute no producer in this repository defines (only the test fixtures do).contract.py:299: seedingseen_bufferswithrow_buffer(defaulting to the literal"state_pool",:280) conflates "the row buffer has this name" with "a page region duplicates it"; harmless today because Helios reservesstate_poolfor the continuation pool (model.rs:515,memory.rs:1234), but the guard's intent would be clearer withseen_buffers = set()and an explicit row-buffer comparison.claims.rs:922-929gates only on the requester side; correctness today rests onmanager_claimalways constructingMpSide::whole(claims.rs:878) soclaim.mp.src.layout.world() == 1. Fine now, fragile if that invariant moves.persistent_worker.rs:104-113fails startup rather than falling back to the 2-way split on devices where 2-way fits and 3-way does not (e.g. 16 SMs, 8-alignment, 8 worker SMs). Declared in the description with thecpuremedy; worth a note in the error text thatgpuis unavailable rather than lost.- The diff carries undescribed
Prompt::preserve_message_anchorplumbing (server/runtime.rs:47-52,:288,event_tests.rs,phase_tests.rs); rebasing onto currentmainshould drop it and roughly halve the visible+2032.
Dropped on verification
- "
cpu-mode core can embedgpu_codec_cubinsand would reserve an unused codec partition." Disproved:model.rs:629-658populatesgpu_codec_cubinsonly underKvCompression::Gpuand returnsVec::new()otherwise, soreserve_codec_partition(model.rs:820-821) is false foroff/cpuand the 2-way split is preserved. - "
permits_holding/permits_offerwithNonecaps might allow everything (inverted guard)." Disproved by callee:selene/src/shared/packed.rs:50-67—permits(None) == false,permits_holding(None, packed=true, _) == false, while raw v3 still passes via(!packed && profiles.is_empty()). The new gating excludes all-literal v4 and keeps raw v3, as claimed. - "Single-host TP≥2 is still broken because some
world()check sees the rank count." Disproved:selene-manager/src/pool/mp.rs:147issession.ranks.as_ref().map_or(1, |r| r.world)andMpSide::whole(:114-121) collapses single-process layouts, soworld() == 1for single-host TP≥2 and the newPinAckgate atclaims.rs:1181accepts it. - "
get_answer's missing source term is exploitable." Unreachable today:get_answerreturns early unlessclaim.manager.is_some()(claims.rs:914), and manager claims always getMpSide::whole(claims.rs:878), i.e. source world 1. Kept only as a Nit about duplicated predicates. - "Moving
offload::openbeforeRankExecutor::newleaves a stale current context." Harmless: every subsequent consumer re-binds —execution/transport.rs:623-624callsStream::open, whosebind(helios/src/cuda.rs:740-756) issuescuCtxSetCurrentand validates the device; the store's own streams bind explicitly inopen_lowest_priority(cuda.rs:785-786). - "
close_storecan double-close or a failed runtime can report Ready." Disproved by ordering: each early-error path returns beforeworker.attach_store(store)(runtime.rs:797), and each sendsready_txafter the drain (:707,:721,:785). - "Base-context registration while streams bind the codec context is a registration mismatch." Disproved:
register_hostusesHOST_REGISTER_PORTABLE(helios/src/cuda.rs:449-472), whose whole purpose is visibility across contexts in the process. - "
descriptorbecomes dead instore_bridge.rsafter the guard rewrite." Disproved: still consumed byStoreCommand::PutBeginatstore_bridge.rs:452. - "The duplicate-buffer guard rejects a legitimate paged plane named
state_pool." Not a supportable recipe: Helios requires a continuation pool buffer named exactlystate_pool(model.rs:509-516) and special-cases that name when resizing (memory.rs:1234), andcodec_layout.rs:108builds the plane and row plans separately, so a page field namedstate_poolcould not validate against the plane set anyway. - "3-way split hard-fail on small-SM devices is a defect." Declared behavior in the description ("Devices lacking enough SMs for three partitions fail cleanly with an error recommending
--lossless-kv-compression cpu"); arithmetic re-checked at 16/20/24/48/188 SMs — no subtraction underflow,aligned_codec >= min_partition >= coscheduled >= 2so no zero-SM partition, and the compute group usessm_count = 0+CU_DEV_SM_RESOURCE_GROUP_BACKFILLso ranges cannot overlap. Kept as a Nit only. - "The new CUDA test hardcodes host VA
0xc20_0000_0000and repeats the pre-existing VA fragility." Cited line not verified in the read window; dropped rather than asserted. - "
gpu_codec.rsvisibility wideningpub(super) → pub(crate)is a production-boundary loosening." Diff shows+1/−1but the exact line was not opened; not carried as a finding. - Inherited base drift (#697/#689) inflating the diff. Directionally supported (
preserve_message_anchoris present and undescribed), butsearch_historycould not be exercised here; reported as a rebase Nit, not a code finding. - Positively verified as correct (no finding): the 11-id/block-byte/alignment mirror against
selene/src/shared/codec_layout.rs:17-32andcodec.rs:611-657; thesorted(row_regions, key=offset)fix againstPlan::new's non-overlap requirement (codec.rs:556-582);default_field_encoding's conservativeBYTESfallback;destroy_green_contexts/release_reservations_and_contextcodec handling (persistent_worker.rs:451-475,mod.rs:1636-1645); and the absence of a per-candidate allocation or new O(N) work on thelookuphot path (the three hash probes sit afterwalk_chain).