Recommendation: Changes Requested
Most of the core fixes in this PR are technically solid—the externalized core-signing rewrite (protection.rs/conversion.rs/conversion/edit.rs), stream-ordered granule zeroing (core_storage.py), CUmemAccessDesc ABI fix (peer_storage.py), multi-host ForwardCache relative paths (aot.py), sharded autotune reconciliation (#631, tuning.py), AOT storage region clamping and multi-storage mutation tracking (compilation.py), RankSupervisor lock decoupling (processes.rs/python.rs), and eos::ReadRing::flush lifetime accounting all hold up under direct inspection. However, verification uncovered two concrete blockers—a silent weight-corruption bug in weight_reuse.rs::map_groups whenever an omitted view shares bytes with a retained view (such as tied embed_tokens/lm_head weights under --reuse-weights --no-mtp), and an unmocked torch.cuda.current_stream call in DeviceRegion.grow that breaks the 12 CPU-mocked tests in tests/preparation/test_persistent.py on GPU-less runners (alongside red CI on head e029dc8 and test evidence reported only on origin/main 8da73911).
Merge Risk
Level: Medium
- Silent weight corruption on
--reuse-weights --no-mtpwith shared/tied weights:heliopause/src/export/weight_reuse.rs:576-620subtracts all byte ranges ofprior.views \ current.viewsfrom prior initializers without protecting overlappingcurrent.viewsranges, which can silently drop initializers for retained target weights and leave them zero-initialized at runtime. - Broad multi-subsystem blast radius (27 files across
helios,heliopause,eos, andignition): Touches core signing, cached export capture/I/O/transfer, weight reuse, multi-host tuning/AOT sharing, CUDA VMM zeroing, and GPU KV codec kernels in one PR with red CI on heade029dc8and no live GPU/WDDM/multi-host execution evidence. - Unbenchmarked hot-path export I/O changes: Pass-1 numeric skip (
capture.rs),DirectRingreuse (io.rs), 8 MiB read batching and payload SHA-256 elision (transfer.rs) modify the export pipeline without end-to-end GPU measurements on the PR head.
Walkthrough
- Externalized signed-envelope rewriting (
helios/src/core/{protection.rs,conversion.rs,conversion/edit.rs}): Extractssign_rewritten_envelope[_with_limit]to refresh deploymentbody_digests, read rank bodies throughbody_store, and sign viasign_envelope; updatesinject_dependency_descriptorsandconversion/edit.rsto rewriteflare.body.*external bodies and dropmetadatabeforefs::rename. - Stream-ordered VMM zeroing, ctypes ABI, and GPU KV codec (
ignition/preparation/{core_storage.py,peer_storage.py,kv_codec.py,runtime_core.py,kv_codec_gpu.cu}): SwitchesDeviceRegion.growtocuMemsetD8Asyncontorch.cuda.current_stream(device).cuda_stream, adoptshost_extentfromflare_core_snapshot, fixes_Access.flagstoc_uint32(12-byteCUmemAccessDesc), compiles KV codec cubins forstorage.device, widensgf2_powto[64][32]and 64-bit packet-plan accumulators, and removes the__shared__[64]batch cap. - Heliopause export pipeline, allocator, supervisor, and
eos::ReadRing(heliopause/src/{allocator.rs,processes.rs,python.rs},heliopause/src/export/{binding,capture,core,io,transfer,weight_payload,weight_reuse}.rs,eos/src/ioring.rs): Skipsrequest.numericD2H in Pass 1 whencache_scanis active; reuses oneDirectRingper scan/write worker and uses directpread/pwritefor single jobs; removes redundant payload container hashing and batches transfer reads to 8 MiB; switchesClaimedtoBTreeMapandconvert_preparedtoHashMap; deduplicatesNativeExportStagepayload leases; isolatesRankSupervisor's join handle and detaches the GIL; resolves/validatesPersistentWorker.metrics; relaxesmap_groupsfor omitted views; computes WDDM-awarewindow_host_layout; and updatesReadRing::flushto accountsubmittedbefore returning errors. - Multi-host preparation and AOT lowering (
ignition/preparation/{aot.py,tuning.py,compilation.py},tests/preparation/*.py): Exchanges cache-root-relative POSIX paths inForwardCache._prepare_rankswith path-traversal guards in_resolve_shared_path; runsshare_selectionsandreconcile_selections(with temporary(0, (0,))shard override) for sharded multi-host tuning (#631); groups raw overlaps before per-group clamped alignment in_storage_regions, slices multi-dtype bases beforeaten.view.dtype, and clears onlypending & mutations[node]in_reads_across_mutations.
Pre-merge Checks
- [PASS] Security / malicious screen: No backdoors, credential leaks, or unsafe path traversals;
_resolve_shared_path(aot.py:772-778) rejects absolute paths and.., external bodies retain SHA-256 verification, andtransfer.rsretains per-frame HMAC-SHA256 plusinstall_payload_objectPayloadIddigest verification. - [WARN] Charter & value fit: Correctness fixes (externalized signing, #631 multi-host tuning, stream-0 race,
CUmemAccessDescABI,ReadRingDMA lifetime) align well with charter goals; however, the bundled export-pipeline performance changes lack end-to-end GPU benchmarks required by charter #210 /docs/design-review.mdPrinciple 12. - [PASS] Related / duplicate / conflict check: Cleanly builds on #618 and #593 without reverting or conflicting with
main; addresses #631's core multi-host sharded autotune divergence. - [WARN] Tests & verification evidence: CI is failing on head
e029dc8, all reported test totals were collected onorigin/main(8da73911) rather than the PR head,test_persistent.pybreaks on GPU-less runners due to unmockedtorch.cuda.current_stream, andcapture.rs's widenedcache_scanbranch has no unit test.
Blockers
- Silent weight omission when an omitted view shares bytes with a retained view (
heliopause/src/export/weight_reuse.rs:576-620).map_groupsbuildsomitted_by_allocationfrom everyoldinprior.viewswhose name is absent fromcurrent.views, then subtracts those ranges directly from every prior weight initializer (subtract_ranges(old_start, old_end, excluded)at line 617) without excluding ranges covered by retained views (prior.views ∩ current.views).- Whenever an omitted view aliases or overlaps a retained view's bytes—for example, tied
embed_tokensorlm_headweights shared between target and MTP draft layers under--reuse-weights --no-mtp, or interleaved strided views sharing an allocation—the retained target bytes are silently subtracted out. Ifretained_piecesbecomes empty (line 618), the initializer is skipped altogether; neithermap_groupsnorresolve_weight_payloadchecks that every non-empty span incatalog.groupsis covered byresult, so those retained target weights are silently left zeroed in the exported core. - Fix: Collect
retained_by_allocation(merged intervals ofold in &prior.viewswherecurrent_names.contains(old.name.as_str()) && old.nbytes > 0) and subtractretained_by_allocationfromomitted_by_allocationbefore clippingprevious.initializers. Add a regression test inweight_reuse.rswhere an omitted draft view aliases a retained target view's offset/range, asserting the retained target initializer is preserved intact.
- Unmocked
torch.cuda.current_streaminDeviceRegion.growbreaks CPU-only test suite (ignition/preparation/core_storage.py:619-621,tests/preparation/test_persistent.py:40-72).DeviceRegion.grownow unconditionally executesstream = torch.cuda.current_stream(device).cuda_stream. Thepacked_storagefixture intests/preparation/test_persistent.py:48-72(used by 12 unit tests designed to run on CPU with a fakeMemorydriver stub) does not monkeypatchtorch.cuda.current_stream, so on any GPU-less CI runnertorch.cuda.current_stream(0)fails immediately beforecuMemsetD8Asyncis reached. Additionally,Memory.call(test_persistent.py:40-42) only assertslen(args) == 4without verifying that the stream pointer was actually passed through.- Fix: In
packed_storage(tests/preparation/test_persistent.py:48-72), monkeypatchtorch.cuda.current_streamto return a sentinelSimpleNamespace(cuda_stream=0x1234)(asserting the passeddevice == storage.device), and assertargs[3].value == 0x1234inMemory.call. Re-run the test suite and confirm CI passes on the updated PR head.
Should Fix
- Re-run verification on PR head and satisfy charter #210 evidence for the performance changes (
heliopause/src/export/{capture.rs,io.rs,transfer.rs}).- The PR description reports test runs gathered on
origin/main(8da73911) rather than the PR head (e029dc8), and explicitly notes that the export-pipeline performance changes (capture.rsPass-1 numeric skip,io.rsDirectRingreuse,transfer.rs8 MiB batching and payload hashing skip) were not benchmarked end-to-end on GPUs. In addition,capture.rs:3420-3425has no unit test covering thecache_scanbranch (request.weight_payload.is_some() && request.options.cache.is_some()without--reuse-weights). - Fix: Either (a) add a unit/integration test for the
cache_scanPass-1 skip path and provide before/after export timing measurements on the PR head, or (b) split the unbenchmarked export-pipeline performance work into a follow-up PR with measurements so the urgent correctness fixes (sign_rewritten_envelope, stream-0 zeroing, #631 multi-host tuning/AOT,CUmemAccessDescABI,ReadRing::flush,compilation.py) can land promptly.
- The PR description reports test runs gathered on
Subtract / Simplify
- Delete duplicate
merge_runsinheliopause/src/export/weight_payload.rs:560-583, 1230-1235: With partial-overlap merging (start <= last.1),merge_runsis identical toheliopause/src/export/reachability.rs:12-24(merge_ranges, which also sorts and drops empty spans). Replace lines 561–562 (runs.sort_unstable(); return Ok(merge_runs(runs));) withreturn Ok(super::reachability::merge_ranges(runs));and deletemerge_runsand its redundant test. - Delete dead Linux
transfer_batchinheliopause/src/export/io.rs:914-921: Every remaining Linux caller oftransfer_batch(read_bouncedatio.rs:648andread_atatio.rs:679) passes a 1-element slice, makingIoUring::new+transfer_batch_on_ringatio.rs:919-920unreachable on Linux. Call a single-job helper (transfer_single_directon Linux,transfer_batchon Windows) from those two sites and remove Linuxtransfer_batch. - Deduplicate
stop_flagandmetricsresolution inheliopause/src/export/binding.rs:355-455: Both blocks repeat the same object extraction, non-emptyallocationvalidation, default-0offsetparsing,resolve_mapped_host, alignment check, and JSON re-insertion. Extracting one helper (resolve_host_ref) eliminates ~35 lines. - Delete test-only
window_host_basewrapper inheliopause/src/allocator.rs:269-272: It has zero production callers (only tests atallocator.rs:1414-1433); point those assertions directly atwindow_host_layout(..., 1, None).
Nits
heliopause/src/export/binding.rs:819-855:NativeExportStage::retain_sourcesnow returns the count of newly acquired leases rather than total leases forpaths. Neither production caller uses the return value (ignition/preparation/model_core.py:67,ignition/preparation/host_ranks.py:496), so clarify the docstring (or returnself.leases.lock().len()).eos/src/ioring.rs:154-159: Clamping(submitted as usize).min(self.queued)prevents underflow on driver errors, but on a hypotheticalstatus == 0withsubmitted > self.queuedit would suppress the error; explicitly returningio::ErrorKind::InvalidDatawhensubmitted as usize > self.queued(after updatingin_flight) is cleaner.ignition/preparation/tuning.py:448, 517: Capturerank = dist.get_rank()once at line 448 and reuse it in thefinallyblock instead of re-importingtorch.distributed as distand callingdist.get_rank()again.heliopause/src/export/transfer.rs:25, 650, 665: ExpressBLOCK_BYTESin terms ofsuper::io::BLOCK(e.g.,super::io::BLOCK / 2) or add a one-line comment noting the 8 MiB read batch vs. 4 MiB wire frame split.- PR description wording:
kv_codec_gpu.cu:1635widens the*low_base_ptr + lane_byte_offs[lane_id]offset expression tosize_trather than changing*low_base_ptr's parameter type (which staysconst U *becauseorig_bytesisuint32_t).
Dropped on verification
- Correctness Lens #1 (
compilation.py:185-204"a_endclamp is a no-op"): False. For real PyTorch views,end <= storage.nbytes()already (max(..., end)only protects against 0-byte fake/meta storages); the bug was rounding(end + alignment - 1) // alignment * alignmentpaststorage.nbytes()(e.g., 5 bytes rounded to 8), whichmin(storage_nbytes, ...)genuinely clamps back to 5. Single-dtype regions already have aligned extents and are cast directly at line 535, so the multi-dtype slice guard at line 691 is exact. - Correctness Lens #2 & Dossier #4 (
kv_codec_gpu.cu"partial 64-bit widening truncateschunk_pkt_offs/lane_byte_offs/low_base_out" and "kernel ABI changed / stale cubin risk"): False.orig_bytesisuint32_t(matching the 32-bit GKV1 packet header), so whenevertotal_pkt < orig_bytes, every intermediate offset (pos,low_base,low_bytes) is strictly< orig_bytes <= u32::MAXand cannot wrap; whentotal_pkt >= orig_bytes(the actual 32-bit overflow case on incompressible packets),*low_base_outis set to0uand compact kernels skip or fall back to literal. No__global__parameter types changed,helios/src/offload/transfer/gpu_codec.rsis ABI-compatible, andkv_codec.py:79-81hashessource_bytesinto the cubin filename so stale on-disk cubins auto-invalidate. - Correctness Lens #3 & Dossier #2 (
capture.rs:3420-3425"dropsdata_spansbytes and loses pointer scanning of numeric ranges"): False.write_allocation(capture.rs:1930, 1965) initializesstoredwithreused(retained ∩ skip_numeric) and merges it intodata_spans;Reachability::contents(reachability.rs:241, 289-300) already skipsself.numericviasubtract_ranges, so numeric ranges were never pointer-scanned; and whencache_scanis true, Pass 1 setspersist = falsewhile Pass 2 (WeightDownload+for_each_group_block) downloads directly from GPU memory viasnapshot_spansand applies 64 KiB zero-block elision. - Correctness Lens #4 (
transfer.rs:600-620, 1008-1040"lost senderIdentityre-check and receiver integrity"): False on the sender check and overstated on the receiver.beforeis still stored inidentities(transfer.rs:614) and re-checked both before and after every read batch (transfer.rs:654-661). On the receiver, every fabric frame is authenticated by per-frame HMAC-SHA256,install_payload_object(transfer.rs:747-769) verifies the companion payload slice againstPayloadIdviaadopt_companion/store_slice, andSourceis a private wire struct internal totransfer.rswhosesha256field is only used on non-payload paths (925-948, 1011-1069). - Correctness Lens #5 (
io.rs:828-830"DirectRingforces synchronous single-job I/O on contended path, preventing overlap"): False. Bothtransfer_single_directandtransfer_batch_on_ring(io.rs:952-978) wait for all jobs in the batch before returning; reader/consumer overlap comes from the worker thread andmpsc::sync_channel(self.depth). Forjobs.len() == 1,pread/pwriteavoidsio_uring_enteroverhead without reducing concurrency. - Correctness Lens #8 (
weight_reuse.rs:576-595"accepts renamed/changed views"): Overstated as framed—map_groups(517-552) rejects any renamed or modified view incurrent.views, anddeployment()(367) validatescompatible_for_weight_reuseupfront. Superseded by verified Blocker #1 on the same lines (omitted views aliasing retained views). - Subtraction Lens #2 (
weight_payload.rs:647-685"rewriteClaimed::claimviasubtract_ranges(..., &self.ranges(allocation))"): Dropped because callingself.ranges(allocation)allocates and copies the entireBTreeMapinto aVecon everyclaim(), re-introducing the exact O(V²) regression this PR fixed. - Subtraction Lens #4b (
allocator.rs:353-360"unreachablecheck_fitstail"): Dropped because re-runningaddress_space::check_fitsinsideif let Some(bits)deliberately surfaces the specific GPU VA-width error message instead of the generic fallback error at line 361. - Dossier claim ("
PersistentWorker.metricsrevives a field removed by #430"): Dropped—PersistentWorker.metricsandmetrics_countare active fields inruntime_core.proto(not opened),helios/manifest.md(not opened), andheliosserving code, so resolving/validating them inbinding.rsaligns the exporter with the runtime ABI.