Repository navigation
Open host prefix store before RankExecutor::new() to avoid cuModuleLoadData deadlock with persistent GPU workers - #698
Conversation
Move offload store opening ahead of executor construction and close the store and executor in LIFO order on every early failure path, preserving ownership of drained resources. This lets GPU KV-compressed cores reach server startup without the persistent-worker startup deadlock. Other runtime GKV1 contention remains outside this change. Validation: cargo test -p flare-helios --features runtime-core on Hades Linux aarch64: 1243 passed, 0 failed, 37 ignored. Existing GB300 before/after hardware evidence is supplied in the PR description; no fresh GPU startup reproduction was run for this submission. Signed-off-by: Eduardo Fonseca <ebf@ebf.io> Design-Signed-Off-By: Iris; design-review=2e5b Signed-off-by: Iris (Eduardo's coding agent)
|
A case file has been opened for 698. Future reviews will auto-run 90 minutes after code updates are pushed.
|
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: Changes RequestedThe core startup reorder—opening the host prefix store before
Walkthrough
Merge Risk: Medium · up to
|
Reuse the worker's drain-aware store close logic for executor and scheduler startup failure paths. Retain the host store when executor drain or store close fails or unwinds, and preserve the first startup error. Validation on Hades Linux aarch64: FLARE_TEST_TEMPLATE_DIR=/tmp/flare-test-templates-pr698 cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server 1897 passed, 0 failed, 84 ignored. The gated muse_spark fixture was unavailable; its only consumer is ignored. No fresh GB300 GKV1 startup reproduction was run. Signed-off-by: Eduardo Fonseca <ebf@ebf.io> Design-Signed-Off-By: Iris; design-review=2e5b Signed-off-by: Iris (Eduardo's coding agent)
…Helios Green Contexts (#709) * Unblock lossless KV compression across Ignition, selene-manager, and Helios Green Contexts Why End-to-end lossless KV checkpoint compression (`--lossless-kv-compression cpu` using `ZKV1/v1/64-pivots` and `--lossless-kv-compression gpu` using `GKV1/v2/64-pivots-rans32`) fails at three independent gates: 1. Ignition contract authoring (`ignition/preparation/contract.py`): `selene/src/shared/codec_layout.rs` defines 11 field encodings with strict block-byte divisibility and alignment rules (`selene/src/shared/codec.rs`), yet `contract.codec_layout` exposed no typed enum or validation, hardcoded `buffer="state_pool"`, and iterated every entry in `regions` without skipping `CONTINUATION_STATE`. Recipes that place `CONTINUATION_STATE` inside `regions` either hit `KeyError("state_pool")` or emitted duplicate overlapping `state_pool` fields rejected by Selene `Plan::new`. 2. Shared pooling in `selene-manager` (`selene-manager/src/pool/`): `selene` supports packed v4 pooling for single-host multi-GPU tensor-parallel instances (`TP>=2`), and `selene-manager` distinguishes multi-process sessions from single-process sessions by `session.ranks.is_some()` (set when `OpenSession.rank_secret` is nonempty). However, `store_bridge.rs` (`PutBegin`) and `claims.rs` (`PinAck` grant) checked `descriptor.ranks.len() >= 2`, rejecting every single-host TP>=2 packed put and peer export. Conversely, `core.rs`, `lookup.rs`, and `claims.rs` did not negotiate raw-only or exclude packed records (including all-literal v4 records) for true multi-process sessions. 3. GPU codec execution on persistent-worker cores (`helios/src/runtime_core/`, `helios/src/server/runtime.rs`): On cores that partition the GPU with CUDA Green Contexts for a resident persistent worker, two hazards occur under `--lossless-kv-compression gpu`: - `Runtime::start` constructed `RankExecutor::new` (launching the persistent worker graph) before calling `crate::offload::open`, which invokes `cuModuleLoadData` to load `kv_codec_gpu.cubin`. Calling `cuModuleLoadData` while a persistent worker kernel is resident deadlocks inside the CUDA driver (#698). - `NativeModel::prepare_offload` passed `rank.execution_context()` (the compute green context) to `GpuRankCodec`. Launching batched GPU codec kernels on either the compute green context or the device primary context (which overlaps 100% of compute SMs) contends with full-grid cooperative compute kernels, collapsing decode throughput and hanging multi-request batches (#701). What changed 1. Ignition (`ignition/preparation/contract.py`, `tests/preparation/test_codec_layout.py`): - Before: `codec_layout(pool, regions, buffers, *, field_encoding=None)` accepted arbitrary untyped integers, hardcoded `"state_pool"`, and treated every `regions` item as a paged plane. - After: Added `CodecEncoding(IntEnum)` matching all 11 Selene IDs with `block_bytes` and `offset_alignment` properties, added export-time validation (`_validate_codec_encoding`) checking integer type, valid ID, positive block-multiple length, and 4-byte matrix offset alignment, added conservative `default_field_encoding(name, dtype, shape)`, and updated `codec_layout` (with optional `state_buffer=None`) to skip `CONTINUATION_STATE` regions, resolve the row buffer from `CONTINUATION_STATE` or `state_buffer`, sort and bounds-check row regions, and reject duplicate or conflicting buffers. Calling `codec_layout` with `field_encoding=None` continues to return `None`. 2. `selene-manager` (`selene-manager/src/pool/{core,store_bridge,lookup,claims}.rs`, `selene-manager/tests/packed.rs`, `selene-manager/tests/support/pool.rs`): - Before: `store_bridge.rs` and `claims.rs` gated packed puts and peer exports on `descriptor.ranks.len() >= 2`; `core.rs` echoed negotiated codec capabilities to multi-process sessions, and `lookup.rs`/`claims.rs` did not filter packed holdings by multi-process requester or source. - After: `store_bridge.rs` gates packed `PutBegin` on `self.sessions[&sid].ranks.is_some()`, and `claims.rs` gates packed peer `PinAck` grants on `claim.mp.req.layout.world() > 1 || claim.mp.src.layout.world() > 1`. `core.rs` keeps `offered_codec` for `RankAttach` and reconnect consistency checks while negotiating `codec = None` when `ranks.is_some()`. `lookup.rs` and `claims.rs` (`claim_begin` and `get_answer`) pass `None` codec capabilities to `permits_holding`/`permits_offer` whenever requester or source is multi-process, excluding all packed records (including all-literal v4 records) while leaving raw v3 records accessible. 3. Helios Green Contexts & startup drain (`helios/src/runtime_core/{persistent_worker,mod,model,memory}.rs`, `helios/src/server/runtime.rs`, `helios/src/server/runtime/phase_tests.rs`, `docs/prefix-cache-offload.md`): - Before: `GreenContextPartition` split the device into two partitions (`worker` + `compute`); `model.rs` passed `rank.execution_context()` to `prepare_offload`, `memory.rs` passed `self.ranks[0].execution_context()` as pool `registration_context`, and `server/runtime.rs` opened the host prefix store after `RankExecutor::new` started the persistent worker. - After: `plan_sm_split` and `GreenContextPartition::create` accept `reserve_codec_partition: bool` (enabled only when `options.prefix_cache.enabled() && !model.gpu_codec_cubins.is_empty()`). When enabled, `cuDevSmResourceSplit` creates three disjoint structured SM partitions (`worker`, one minimal aligned `codec` partition, and `compute` backfill preserving 16-CTA co-scheduling alignment with baseline fallback); devices too small for three partitions return an error recommending `--lossless-kv-compression cpu`. When compression is `off` or `cpu`, the existing 2-way split is unchanged (0 SMs lost). Added `NativeResources::offload_context()` returning `codec_context` when present and `self.context` otherwise, updated `model.rs` (`prepare_offload`) to use `offload_context()`, updated `memory.rs` (`registration_context`) to use `self.ranks[0].context`, and updated teardown to handle `codec_green_ctx`. In `helios/src/server/runtime.rs`, moved `crate::offload::open(...)` ahead of `RankExecutor::new(...)` (after the `binding.sharded()` guard) and extracted `fn close_store(...)` preserving `ManuallyDrop` slab retention on drain errors, panics, or undrained executors across all three early startup error paths before signaling readiness failure. Claimed benefit and result - Ignition exposes a validated, `CONTINUATION_STATE`-safe `codec_layout` helper so companion recipe repositories can emit valid `ModelContract.cache.codec_layout` across all model families. - Single-host TP>=2 instances can store, recover, and peer-export packed v4 checkpoints through `selene-manager` over SHM and TCP while multi-process sessions stay raw-only. - On a persistent-worker core with `--lossless-kv-compression gpu`, loading `kv_codec_gpu.cubin` completes before persistent-worker launch and GPU codec kernels run on physically disjoint SMs. Measured in a component SM120 CUDA concurrency test on an NVIDIA RTX PRO 6000 Blackwell (188 SMs, 3-way split 8 worker + 8 codec + 172 compute): concurrent cooperative compute sustained 135,922.6 steps/s (baseline 7.6 us/step, 136,046 steps in 1.0 s, zero hangs) alongside 251 bit-exact 1.06 MiB `GKV1` encode+decode rounds (266.4 MiB/s combined encode+decode, 5.98x ratio). Whole-model SM103 serving speedup and multi-request B>=2 throughput are expected results pending SM103 qualification. Supporting evidence and limitations - SM120 CUDA test (`CUDA_VISIBLE_DEVICES=6`, RTX PRO 6000 Blackwell): `persistent_worker::tests::cuda_green_context_three_way_gpu_codec_runs_concurrently_with_persistent_worker_and_cooperative_compute` passed with real `ignition/preparation/kv_codec_gpu.cu` cubin. - Python + CUDA tests (`FLARE_RUN_CUDA_TESTS=1 CUDA_VISIBLE_DEVICES=6` on `tests/preparation/test_codec_layout.py`, `tests/preparation/test_core_boundary.py`, `tests/test_kv_codec.py`, `tests/cli`): 163 passed, 0 skipped. - Rust test suites (`--locked --release`): - `eos`: 12 passed. - `selene --features test-support`: 553 passed. - `selene-manager --features test-support`: 408 passed, 1 ignored (including 12/12 in `tests/packed.rs` covering single-host TP2 packed put, TP2 peer DRAM packed export over SHM/TCP, and multi-process TP2 exclusion). - `helios --features runtime-core,server --lib`: 1,835 passed, 48 ignored (including all 20 targeted `persistent_worker`, `codec_layout_tests`, and `close_store` tests; 6 chat-template tests failed because `FLARE_TEST_TEMPLATE_DIR` was unset). - `flare`: 255 passed (247 lib + 7 `packed_canonical_download` + 1 `reference_workflows`; 2 localhost `hub::tests::` flaked under parallel load and passed cleanly on re-run). - `flare-cli`: 246 passed, 3 ignored. - TLA+ formal verification (`verification/helios-lifecycle/check.py` with `tla2tools-1.7.4.jar`): all 8 TLA+ models and Rust conformance checks passed with 0 errors. - Limitations / unrun checks: Live SM103 Parallax `flare run` with exported cores at `B>=2` was not run (no SM103 hardware or exported model checkpoints on this host). Helios chat-template tests requiring `FLARE_TEST_TEMPLATE_DIR` were not run. Existing `persistent_worker::tests::cuda_*` tests with hardcoded `0x800_0000_0000` fixed VA collide with CUDA UVA placement on this 16-GPU host and were not modified. Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b * Apply PR #709 review fixes for codec context settings, normative docs, and helpers Why - `NativeResources::prepare_kernels` applied recorded CUDA context limits and cache configuration to the primary, worker, and compute Green Contexts, but omitted `partition.codec_context`. Under `--lossless-kv-compression gpu`, `kv_codec_gpu` kernels and offload DMA streams ran with driver defaults on persistent-worker cores rather than the core's recorded context settings. - Two normative specifications contradicted or omitted behavior changed in this branch: `docs/runtime-core-design.md` still specified a two-group Green Context split and two-context settings/teardown, and `selene-manager/PROTOCOL.md` did not specify that single-process sessions (including single-host `TP >= 2`) remain packed-capable while multi-process sessions negotiate raw-only and exclude packed holdings/offers. - Secondary review items identified duplicated `selene-manager` capability gating (including an implicit source-world assumption in `get_answer`), `numbers.Integral` scalar rejection in `ignition.preparation.contract`, unreachable `state_buffer` validation when `row_regions` is empty, an implicit `row_buffer` collision check, a `0` sentinel in `plan_sm_split`, and a duplicated `TestFiles` fixture in `persistent_worker.rs`. What changed - Helios (`helios/src/runtime_core/{mod,model,persistent_worker}.rs`): - After storing `self.green_partition = Some(partition)`, call `apply_context_settings(&driver, codec_context, &core.context)?` whenever `codec_context` is non-null. - Assert recorded `CU_LIMIT_STACK_SIZE` (`4096`) on `worker_context`, `compute_context`, and `codec_context` in the 3-way SM120 CUDA test. - Compute `reserve_codec_partition` directly from `options.prefix_cache.enabled() && options.prefix_cache.compression == KvCompression::Gpu`. - Use `Option<u32>` for `aligned_codec` in `plan_sm_split` and clarify the small-SM error message. - Hoist a single `TestFiles` fixture in `persistent_worker::tests`. - `selene-manager` (`selene-manager/src/pool/{core,lookup,claims}.rs`): - Extracted `packed_caps(&self.sessions, requester_sid, multi_process)` and routed `lookup.rs`, `claims.rs::claim_begin`, and `claims.rs::get_answer` through it, checking both `claim.mp.req.layout.world() > 1` and `claim.mp.src.layout.world() > 1` in `get_answer`. - Ignition (`ignition/preparation/contract.py`, `tests/preparation/test_codec_layout.py`): - Accepted `numbers.Integral` (still rejecting `bool`) for codec encodings, offsets, and lengths. - Validated `state_buffer` before the empty `row_regions` early return and separated continuation-buffer collision checks from duplicate paged buffer checks, with unit tests covering all three. - Normative docs (`docs/runtime-core-design.md`, `selene-manager/PROTOCOL.md`): - Documented the 2-way vs 3-way Green Context split, context settings and teardown for `codec_context`, pre-worker `offload::open`, and the single-process vs multi-process revision-4 packed rules. Verification - SM120 CUDA (`CUDA_VISIBLE_DEVICES=6`, RTX PRO 6000 Blackwell): `cuda_green_context_three_way_gpu_codec_runs_concurrently_with_persistent_worker_and_cooperative_compute` passed (`worker=8, codec=8, compute=172` SMs; `CU_LIMIT_STACK_SIZE=4096` verified on all three Green Contexts; concurrent cooperative compute `134,996.0 steps/s` alongside 250 bit-exact `GKV1` encode+decode rounds, `265.5 MiB/s`, `5.98x`). - Rust (`--locked --release`): - `selene-manager --features test-support`: full suite passed (including 12/12 in `tests/packed.rs`). - `helios --features runtime-core,server --lib`: `persistent_worker::tests` (9 passed), `runtime::phase_tests` (129 passed), `codec_layout_tests` (6 passed). - `RUSTFLAGS="-D warnings" cargo check --locked --all-targets` passed with 0 warnings on `selene-manager` and `helios`. - Python: `pytest tests/preparation/test_codec_layout.py tests/preparation/test_core_boundary.py` (12 passed). Design-Signed-Off-By: Antigravity (Gemini 3.1 Pro); design-review=2e5b Signed-off-by: Luke Alonso <lalonso@gmail.com>
Autobot ReviewFull Review · Value Proposition · Case File Recommendation: CloseCommit
Walkthrough
Merge Risk: Low · up to
|
Summary
When serving any core that combines a
PersistentWorkerwith--lossless-kv-compression gpu(GKV1),flare rundeadlocks indefinitely insideStart server(GPU pegged at100%SM,flare-offload-0pegged at100%CPU, HTTP server never binds):helios/src/runtime_core/mod.rsdefers loading the embeddedkv_codec_gpucubin duringPrepare kernelssooffload::open()loads it lazily only when GPU compression is enabled.helios/src/server/runtime.rs,RankExecutor::new(manifest, peers)runs beforecrate::offload::open(...)and callscontrol.start()?, launching the persistent GPU worker kernel on the device context (100%SM untilcontrol.stop()).crate::offload::open(...)spawnsflare-offload-0, which callsGpuRankCodec::new→cuModuleLoadData()on the same CUDA context.libcuda.so.1!cuModuleLoadData()spins waiting for active kernels on the context to quiesce — which can never happen whileflare-modelis blocked waiting forflare-offload-0to finish opening andcontrol.stop()has not been called.Confirmed directly via
gdbon the wedgedflare-offload-0thread on a DGX Station GB300 (SM103, CUDA 13.2):Changes
helios/src/server/runtime.rs:crate::offload::open(prepared, gpu_cubins, copy_gate)ahead ofRankExecutor::new(manifest, peers)soGpuRankCodec::newloadskv_codec_gpuviacuModuleLoadData()while the GPU is idle, before any persistent worker kernel launches.manifest.offloadand its CUDA contexts are already prepared prior toRankExecutor::new, andRankExecutor::newonly checksoffloadmetadata (not the taken payload).storeopens (store.close()directly ifRankExecutor::newfails;executor.close()first, thenstore.close()only whenshutdown.drained, matchingWorker::close_store()).runtime.rs:executor.close()beforeworker.close_store()).Verification
--lossless-kv-compression gpu(GKV1) and a localselene-managerpool:Start serverhung indefinitely (>400s, GB300100% SM / 0% MEM,flare-offload-0stuck incuModuleLoadData()).Start servercompletes cleanly in0.6s,GKV1GPU codec loads and compresses checkpoints (1.239–1.259×lossless on FP8 MLA KV,0CRC/verification failures), andSIGTERMshutdown (drain_on_shutdown) completes cleanly in3.6swith zerocuModuleUnloaddeadlock.GKV1still contends with cooperative decode graphs at runtime becausemodel.rsopens the codec stream onrank.execution_context()— a separate runtime issue independent of this startup-ordering deadlock fix.)cargo test -p helios --features runtime-coreSubmission validation
On Hades Linux aarch64 (kernel 6.17.0-1029-nvidia-64k), using the current package name:
The existing GB300 before/after evidence above is retained from the supplied reproduction. No fresh GPU startup reproduction was run for this submission.
Discord: ebfio