Repository navigation
Open
Description
Status (updated 2026-10-01 20:10Z)
State: fix in draft #148. Cause (a) is verified on strix; cause (b) is waiting on a Flash-Next shutdown run.
- Exit race: fixed on main (spark-server: join the scheduler before exit so teardown can't race HIP's static destructors (#106) #123 via HIP train (Strix Linux + Windows): #79 #93 #94 #101 #104 #107 #123 #124 #131).
- (a)
SsmStatePoolview frees, every model: teardown: free SSM pool bases, not layer views; stop double-freeing store tensors after the MoE transpose (#122) #148ba4c71548on strix job 139 (27B) wentteardown reported a failure1 → 0 andsweep: cuMemFree failed282 → 0. - (b) MoE transpose vs
WeightStore, Flash-Next:- On main, 147,373 sweep failures, from routed and shared expert frees.
- Strix Halo Windows: Flash-Next port on main + MoE prefill transpose (2k TTFT ~2x) (supersedes #54) #80 alone leaves 144 (GB10 job 658): the shared expert, 3 BF16 frees × 48 layers.
- teardown: free SSM pool bases, not layer views; stop double-freeing store tensors after the MoE transpose (#122) #148 marks those frees in the store. The post-Strix Halo Windows: Flash-Next port on main + MoE prefill transpose (2k TTFT ~2x) (supersedes #54) #80 resolution is branch
fix/teardown-sweep-views-on80@c51e86a8c.
- Next: a Flash-Next boot + SIGINT on
c51e86a8c(winbox after plan m, or GB10 when reiner returns). Expect 0 / 0. Then teardown: free SSM pool bases, not layer views; stop double-freeing store tensors after the MoE transpose (#122) #148 rebases onto main after Strix Halo Windows: Flash-Next port on main + MoE prefill transpose (2k TTFT ~2x) (supersedes #54) #80 merges.
Atlas version / docker tag
main at df051b35 (source build, ATLAS_TARGET_MODEL=qwen3.8-flash-next ATLAS_TARGET_QUANT=nvfp4)
Model
RadixArk/Qwen3.8-Flash-Next-NVFP4 (qwen4_exp)
Hardware
1× GB10 (DGX Spark), single-GPU
Launch command
spark serve /path/to/radixark-fn-nvfp4 --port 8890 --kernel-target qwen3.8-flash-next \
--max-seq-len 8192 --kv-cache-dtype bf16 --gpu-memory-utilization 0.93 \
--max-num-seqs 2 --max-batch-size 2
# then: three short greedy chat requests, then SIGTERMExpected behaviour
On SIGTERM the server drains, Scheduler stopped follows a clean model.teardown(), and the process exits after that. Teardown frees what the model owns, with no invalid frees.
Actual behaviour
Two separate problems. Both reproduce on every run.
1. The process exits without waiting for teardown.
- After
serve()returns (Shutdown complete),mainreturns without joining the scheduler thread, somodel.teardown()races process exit. - In four plain runs:
- two exited with nothing logged after
Shutdown complete; - two logged a teardown about 100 ms later with a sweep of only 2,151 allocations and no failures. That teardown was cut short by the exiting process: a complete one takes about 2.3 s (below).
- two exited with nothing logged after
- So a normal shutdown never shows teardown's real result.
13:19:02.680874Z INFO spark::tui::shutdown: Shutdown requested (SIGTERM) — draining in-flight requests
13:19:02.680995Z INFO spark::tui::shutdown: Drain complete — no active requests
13:19:02.681023Z INFO spark::main_modules::serve_router: Shutdown complete
<process exit; no teardown or "Scheduler stopped" line>
2. When teardown does finish, it fails: about 147,400 invalid frees.
- With a local-only 3 s pause added at the end of
main(not committed), teardown always completes. It logs:
13:34:14.471716Z INFO spark::main_modules::serve_router: Shutdown complete
13:34:15.823055Z WARN spark_runtime::cuda_backend: sweep: cuMemFree failed for 0xfffa3dec8000: status 1
… 147,444 such lines …
13:34:16.768984Z WARN spark_model::model::types: teardown swept 149595 allocation(s) that no ModelResource released — they are reclaimed, but each one is memory whose owner is unaccounted for
13:34:16.768989Z ERROR spark::scheduler: model teardown reported a failure: ssm state pool: cuMemFree_v2 failed: status 1, ptr DevicePtr(0xffd785d00000); pointer restored to backend cleanup ledger
13:34:16.768995Z INFO spark::scheduler: Scheduler stopped
- The counts were identical across 3 runs: 149,595 swept, 147,444 failed with status 1 (invalid value).
- Nearly everything the sweep finds is already invalid. Status 1 from
cuMemFreemeans the pointer was already freed or isn't the base of an allocation. Teardownrecords only its first error (ssm state pool), so failures from later steps (for example the weight store) are not reported.
Additional context
- Why it matters: in-process hot-swap relies on
teardown()returning the model's memory. A teardown that frees invalid pointers can also free live memory if an address has been reused, and a shutdown that exits first hides all of it. - Found while testing spark-model: don't free WeightStore-owned GDN projections in the BF16 loader #121, the double free of store-owned GDN projections in the BF16 loader.
- With spark-model: don't free WeightStore-owned GDN projections in the BF16 loader #121, the failed-free count drops from 147,444 to 147,406 (−38, deterministic across 3 runs each); everything else is unchanged.
- So spark-model: don't free WeightStore-owned GDN projections in the BF16 loader #121 addresses a small part of this. Details in spark-model: don't free WeightStore-owned GDN projections in the BF16 loader #121 (comment).
- Not root-caused. 147,444 is close to 512 experts × 48 layers × 6 (147,456). That suggests the MoE unified-layout transpose, which logs "originals freed", but it has not been confirmed.
- Where the first failing step lives:
SsmStatePool::releasefrees each pointer of its per-layer pools (h_state_pools,conv_state_pools, …); the first of those fails with status 1. - Logs: the full serve logs are about 25 MB each, mostly the sweep lines. We can attach them, or run a bisect or narrower repro if that helps.
Metadata
Metadata
Assignees
Labels
No labels
Activity
AzeezIsh commentedon Sep 28, 2026
Both halves are covered by integration train #129: the exit race is #123 (join the scheduler before exit) and the invalid frees are #121 (
WeightStorealiases go throughreclaim). This issue closes when #129 lands, after its GB10 clean-shutdown check.AzeezIsh commentedon Sep 28, 2026
Update: the fixes now ride separate per-deployment trains. #121 (the invalid frees) is in #132 (GB10), and #123 (the exit race) is in #131 (HIP). I'll close this once both have landed and the GB10 clean-shutdown scan passes.
andrew-vogulkin commentedon Sep 28, 2026
@AzeezIsh thanks for routing these. One correction before this closes: #121 covers only a small part of the invalid frees.
From the GB10 before/after on #121 (#121 (comment)): Flash-Next NVFP4,
mainvsmain+ #121, 3 runs each. Counts were identical across runs.sweep: cuMemFree failed … status 1teardown swept N allocation(s)ssm state pool: cuMemFree_v2 failed: status 1ssm state poolfailure that teardown reports first, remain with spark-model: don't free WeightStore-owned GDN projections in the BF16 loader #121 applied.So once #121 and #123 land, part 2 of this issue is still open: Flash-Next NVFP4 teardown hits ~147k invalid frees and reports a failure.
Could this stay open, or be split into its own issue, until the GB10 clean-shutdown scan passes with both fixes in? We can run that scan on a train build if useful.
AzeezIsh commentedon Sep 29, 2026
Correction: the "0 invalid frees" results I reported for #132 (
625zzz3) and for #121 proved nothing. Main never reaches model teardown, so the teardown sweep that produces these warnings never ran.Reiner
639compared mainb03dc7363(which has #121) with the HIP train at56b3d6a05(main plus #123), on the same 4 models:sweep: cuMemFree failedlinesWhat this shows:
cuMemFreeon pointers the backend still has registered, and those return status 1 (invalid value). So they were already freed, or they aren't allocation bases (likely per-tensor pointers into a slab).This issue stays open for the sweep double-frees. It's a teardown-only bug: the process is exiting anyway, and the pre-exit output is unaffected.
AzeezIsh commentedon Sep 29, 2026
Diagnosis so far (main
b2814e06e, reiner653)1. Confirmed: the
SsmStatePoolteardown frees offset views. This produces the oneERROR model teardown reported a failure: ssm state pool: cuMemFree_v2 failed: status 1on every model.alloc_layer_pools(model/ssm_pool.rs:147) allocates one contiguous block and returnsbase.offset(l * bytes)per layer.SsmStatePool::releasethen callsgpu.freeon every entry of all six pools. Only layer 0 is a real allocation, so every other free returns status 1, andfree()puts each rejected pointer back on the ledger, where the sweep fails on it again.The Marconi snapshot pool already handles this correctly:
ssm_snapshot_teardown.rsfreesh_blob_baseandconv_blob_base, never the views. The fix is the same shape: keep the block base (or acontiguousflag) and free per layer only on the fallback path.2. Not yet located: Flash-Next's ~147k sweep failures.
147,374 is about 48 layers × 256 experts × 12 per-expert tensors. So these are per-expert allocations that are still on the ledger but are no longer valid allocations: they were either freed through a path that bypasses
GpuBackend::free/forget_alloc, or they are views that were restored to the ledger.WeightStore::releaseis not the cause, since it reported no error. Candidates to check next are the qwen4_exp MoE transpose orchestrator, which re-lays out expert weights, andWeightStore::reclaim.Impact: at process exit, memory is reclaimed either way, so nothing leaks. The cost is a false ERROR on every shutdown and the noise from 147k warnings. It is not a runtime correctness issue.
AzeezIsh commentedon Oct 1, 2026
Root-caused. Fix in draft #148 (off main
be435875c, unit-tested, not yet run on GB10).Two independent sources:
SsmStatePool::releasefrees offset views. The 09-29 diagnosis was right. On strix, the 27B log has 282 failures = 6 MTP pool families × 47 non-base layers, with uniform address strides. That is every 27B failure. The pool now frees its real allocations only.WeightStore. Phase B/D of the transpose free each expert's original weights, which are store tensors, andWeightStore::releasefrees them again. 48 layers × 512 experts × 6 tensors = 147,456.release_poolskeeps only the first error, and that was always the SSM pool's, so the store's errors were never visible.Expected after #148: 0
sweep: cuMemFree failedlines and nomodel teardown reported a failure. Needs a GB10 Flash-Next shutdown run; reiner was unreachable at 06:40Z.teardown: reclaim, not free, the BF16 store sources quantized at load (…
teardown: reclaim the other two store tensors freed raw at load (#122)
Merge pull request #148 from Atlas-Inf/fix/teardown-sweep-views
teardown: free SSM pool bases, not layer views; skip store tensors th…
maplepaladin73 commentedon Oct 20, 2026
Clean-shutdown check on current main: 0 invalid frees, and teardown completes before exit.
This is the boot + SIGTERM run the status block was still waiting for, done on our GB10s.
Build: main
e29809db(includes #80, #131 and #148), built with the SparkQwen Dockerfile forqwen3.8-flash-next/nvfp4. Checkpoint:nvidia/Qwen3.8-Flash-Next-NVFP4. The original report used the RadixArk NVFP4 pack; this is the sameqwen4_exparchitecture.Each run: boot, three short greedy chat requests, then
docker stop(SIGTERM, 120 s grace).--max-seq-len 8192 --kv-cache-dtype bf16 --max-num-seqs 2 --max-batch-size 2, util 0.90Shutdown complete→scheduler joined; model torn downsweep: cuMemFree failedmodel teardown reported a failureteardown swept N allocation(s)(WARN, reclaimed)So both halves of the issue look fixed on GB10:
Scheduler stoppedandscheduler joined; model torn downappear before exit, about 5 s afterShutdown completeat TP=1.Two things left, if you want them tracked (neither is a failure):
ModelResourcereleased. They are reclaimed without error. The WARN text says each is memory with no accounted owner.EP worker stopped (rank 1)and thenbackend drop reclaimed 114040 allocation(s) that no owner released, with 0 free failures. The worker never runs model teardown, so all of its model memory goes through the backend drop.The full server logs from all three runs are available if useful.