Skip to content

fast weights: read shards on eight threads, decode CSF scales at upload - #308

Merged
AzeezIsh merged 1 commit into
Atlas-Inf:mainfrom
Enntity:fix/csf-upload-decode
Nov 1, 2026
Merged

AzeezIsh merged 1 commit into
Atlas-Inf:mainfrom
Enntity:fix/csf-upload-decode

Conversation

@data-angel

Copy link
Copy Markdown
Contributor

Summary

On main, an FP4-Local checkpoint takes about twice as long to boot as SparkQwen 0.4.0. In Strict mode on two DGX Sparks, the server was live 54.3 s after start, against 26.8 s for 0.4.0. Most of that gap is one shard reader waiting on one read at a time, plus materialize fetching 73,728 CSF streams and 876 native MXFP8 tensors after the load. This PR gets the same boot to 30.0 s.

  • ShardReaders: eight readers per shard, holding at most 16 tensors and 1 GiB ahead of the copier, handed over in tensor order. Dropping it stops and joins them, so an upload that fails mid-shard leaves no reader on a closed descriptor.
  • CsfAssembler: the fast loader no longer defers CSF streams. It gathers each pair, in either order and across shards, and uploads only the decoded weight_scale, through the existing modelopt_codec. A stream without its partner, or a scale both plain and compressed, fails the load.
  • deferred_modules: native MXFP8 modules load through the shard path, and materialize checks them where they sit. Only what it expands stays deferred.

pack_slab keeps working and reserves nothing for streams. materialize still decodes streams another loader left resident. The readers port Enntity/atlas f4d95a1.

Part of #220.

Test plan

  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 cargo clippy --locked --workspace --tests -- -Dwarnings, CI's env. Not --all-features, which stops on objc2 on Linux.
  • python3 scripts/check_spdx.py, which is what CI runs. scripts/check-license-headers.sh needs Docker and did not run in my container. All new files carry the header.
  • typos: not run, not installed here.
  • spark-runtime --lib fast_weights: 21 passed. spark-model --lib modelopt_local: 11 passed. The workspace suite was not run.
  • Added tests: pairs across shards in either order, a lone stream, a scale both plain and compressed, tensors past the read-ahead, slab contents, reader order, a failed read, and dropping the readers midway.
  • Real model and hardware: two DGX Sparks, TP2, 2026-11-01, results below.

The gates above ran on this commit merged into main 575db42e1. The hardware results did not: they ran on b8a330647, which is this commit and #303 on 8c2b67218. Main has since taken #159, #306 and #307, which are not in any number below.

Fingerprint. Qwen3.8-Flash-Next-FP4-Local, 8x32k profile, Strict mode unless noted, one boot per arm. 0.4.0 is 9b25f57596d1; "no loader" is cecf6539e (8c2b67218 with #303). Arms were interleaved in an order that balances drift. sq_bench cells, temperature 0, 256 tokens per stream at C4 and C8. Each value is the mean of per-boot means. P values are two-sided exact permutation tests over boots. Run tags r5-* and r6-* on our box.

Boot, Strict 0.4.0 (4 boots) No loader (3 boots) This PR (7 boots)
Start to Server live, s 26.8 54.3 30.0

Boot is about 3 s slower than 0.4.0 here. I have not split that gap in Strict.

Strict 0.4.0 (4 boots) This PR (4 boots) Change p
C4 tok/s 130.9 130.7 -0.2% 0.66
C8 tok/s 192.2 190.2 -1.0% 0.14
Cold 2K TTFT, s 0.735 0.700 -4.8% 0.03
Cold 8K TTFT, s 1.998 2.007 +0.5% 0.06
Cold 16K TTFT, s 3.927 3.965 +1.0% 0.03
Cold 28K TTFT, s 6.903 6.960 +0.8% 0.03

p = 0.03 is the lowest 4 against 4 can reach.

Strict, same engine No loader (3 boots) This PR (3 boots) Change p
C4 tok/s 131.0 129.9 -0.9% 0.10
C8 tok/s 191.5 190.2 -0.7% 0.10
Cold 2K TTFT, s 0.699 0.694 -0.7% 0.10
Cold 8K TTFT, s 2.000 1.998 -0.1% 0.60
Cold 16K TTFT, s 3.953 3.948 -0.1% 0.50
Cold 28K TTFT, s 6.946 6.943 0.0% 0.90

p = 0.10 is the lowest 3 against 3 can reach.

Output against 0.4.0, on the same b8a330647 engine, in earlier arms on the same day: greedy 8/8, prompt logprobs zero delta, tools 7/7, agentic 20/20, vision 14/14, in Spark and Strict. On 4x1m, greedy and logprobs match earlier runs and tools pass. 8x262k booted and passed pre-flight.

Notes for reviewers

  • Possible cost at C4 and C8. With and without this PR, the boots do not overlap at C4 or C8, a gap of about 0.7-0.9%. Three boots each cannot prove it, and C4 shows no gap against 0.4.0 in the other set. I have not found a mechanism: 9b25f57596d1 also uploads each decoded scale on its own allocation. Treat it as observed, not established. If your bench shows it, I want to know.
  • The cold gaps are not from this PR. The cold 16K and 28K gaps against 0.4.0 stay with or without the loader, so they belong to 8c2b67218.
  • Boot times come from rank0.log. My earlier 10 s health poll rounded these to 32 s, 32 s and 63 s and hid the 3 s gap, so use the figures above.
  • host_decode_modules keeps its meaning. ffn.rs uses it as the FP4-Local test. deferred_modules is the new, narrower set that serve_phases/weights.rs hands the loader.
  • Thread count. Readers are fixed at 8 per shard, as in the source commit.
  • glm: native prefill and FP4-Local for dual DGX Spark (#199 by @Mango-kid, rebased onto main + #198) #242: CsfAssembler keeps the call shapes of the assembler in the SparkQwen stack, so a later merge with the GLM stack stays small. I have not merged glm: native prefill and FP4-Local for dual DGX Spark (#199 by @Mango-kid, rebased onto main + #198) #242's head against this.

Authorship

AI-authored (Claude Code). No human-written code.

🤖 Generated with Claude Code

A FP4-Local checkpoint holds 73,728 CSF streams and 876 native MXFP8
tensors that `materialize` fetched one read at a time after the load, on
top of a single shard reader waiting on one read at a time.

- `ShardReaders`: eight readers per shard, at most 16 tensors and 1 GiB
  past the next one ahead of the copier, handed over in tensor order.
  Dropping it stops and joins them, so an upload that fails mid-shard
  leaves no reader on a closed descriptor.
- `CsfAssembler`: the fast loader no longer defers CSF streams. It gathers
  each pair, in either order and across shards, and uploads only the
  decoded `weight_scale` through the existing codec. A stream without its
  partner, or a scale both plain and compressed, fails the load.
- `deferred_modules`: native MXFP8 modules load through the shard path.
  `materialize` checks them where they sit instead of reading them back.
  Only what it expands stays deferred.

`pack_slab` keeps working and reserves nothing for streams. `materialize`
still decodes streams another loader left resident.

The readers port Enntity/atlas f4d95a1 (AGPL-3.0-only).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@data-angel
data-angel requested a review from AzeezIsh as a code owner November 1, 2026 18:02
@AzeezIsh

AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

I pre-gated this exact head (2d866fc58) from Enntity before the PR existed, against main 8c2b67218 with both built fresh on reiner + spark2. Receipts are in reiner's ~/code/night1027/out/dap-csf-2d866fc58/.

  • KL logit drift: exactly 0.
    • 34,245 of 34,245 positions in each of 2 spark-config boots (teacher-forced top-20 on 6 text cases, plus 4 generated chat cases).
    • 36,765 of 36,765 on rc16 with 3 images and a video.
    • Main against itself is also 0.
  • Boot to ready (armctl up, both ranks, spark config, interleaved boots): main 99 / 99 s, this PR 84 / 69 s, n=2 each. That's our wrapper's wall time, which includes warm-up, so it reads higher than your live-at numbers.
  • Bench: every cell is inside main's run-to-run range.
    • C1 59.74 vs 59.73, C2 91.81 vs 92.03, C4 142.07 vs 142.33.
    • Decode code/json/prose 92.52 / 70.94 / 60.86 vs 92.81 / 71.37 / 60.92.
    • TTFT at 2K/8K/16K/28K is equal.
  • rc16: greedy C1 and C8 8/8 identical, tools 21/21.

Main has moved since (#303, #159, #306, #307). My sentinel runs found KL 0 between each of those main heads, and none of them touch the weight-load path. I'll merge once CI is green.

@AzeezIsh
AzeezIsh merged commit 88010ba into Atlas-Inf:main Nov 1, 2026
25 of 26 checks passed
data-angel added a commit to Enntity/atlas that referenced this pull request Nov 1, 2026
The tree keeps its CSF assembler, which handles both encodings and checks
each scale against its weight, and takes Atlas-Inf#308's shard readers. Its tests get
a weight for every scale and an exception that decodes positive.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh

AzeezIsh commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

@data-angel This PR has a small decode slowdown on Qwen3.8-Flash-Next. Logits are unchanged.

A/B on reiner + spark2: main before (575db42e1) vs after this PR (88010baee), both built fresh, on 0.4.0's 8x32k spark config. 3 fresh boots per arm, interleaved, running sq_bench decode + conc. Receipts are in reiner's ~/code/night1027/out/decab-308/. Medians, before vs after:

cell before after change n
decode code 93.18 [92.47–93.49] 92.18 [91.31–92.64] −1.07% 9 / 9
decode json 71.66 [71.32–72.08] 70.91 [70.27–71.25] −1.05%, ranges disjoint 9 / 9
decode prose 61.59 [61.23–61.89] 60.76 [60.43–61.03] −1.35%, ranges disjoint 9 / 9
C1 60.48 59.64 −1.38% 6 / 6
C2 92.33 91.66 −0.73% 6 / 6
C4 142.62 141.82 −0.55% 6 / 6
boot to ready 104 / 99 / 99 s 79 / 74 / 74 s

Three independent runs agree on direction:

  • my pre-gate of this head, against 8c2b67218, saw about −0.3 to −0.6% on decode;
  • the main sentinel run, against 575db42e1, saw −0.6 to −2.0%;
  • this dedicated A/B saw −1.1 to −1.35%.

KL is exactly 0 throughout, so the numerics are identical. That points at where the weights or scales land in memory rather than at the math. The two suspects are native MXFP8 modules now loading through the shard path, and CSF scales decoded at upload. I'm bisecting the two halves on the pair next. If you already know which of the three parts changes placement for decode-path tensors, say so and I'll test that first.

@AzeezIsh

AzeezIsh commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Bisect result: it's the native MXFP8 modules going through the shard slab. Main 9571227 (M) against two bisect-only variants, all built fresh. 0.4.0's 8x32k spark config, 3 fresh boots per arm interleaved M/U/D, n=9 per decode cell and n=6 per concurrency cell. Receipts are in reiner's ~/code/night1027/out/bisab-308/.

  • U: CSF streams deferred to materialize again (is_host_decoded returns true for is_csf_stream), bisect/308-no-uploaddecode.
  • D: native MXFP8 modules deferred to materialize again (deferred_modules without the native retain), bisect/308-no-deferred.
cell M (main) U D
decode code 92.36 92.55 (+0.21%) 93.28 (+1.00%)
decode json 71.11 71.19 (+0.11%) 71.57 (+0.65%)
decode prose 61.00 61.14 (+0.23%) 61.31 (+0.51%)
C1 59.72 59.89 (+0.28%) 60.27 (+0.91%)
C2 90.91 91.85 (+1.03%) 92.23 (+1.46%)
C4 141.25 142.54 (+0.92%) 143.16 (+1.35%)
boot (s) 74 / 74 / 74 79 / 84 / 84 79 / 74 / 79

KL is 0 for U and for D against M.

D recovers most of the -1.1 to -1.35% and keeps nearly all of the boot win. U is within noise on decode, though C2 and C4 move by about 1%. My reading is that the native MXFP8 modules (qwen4_exp's shared experts and MXFP8 projections) decode slower from their place inside the shard slab than from materialize's own allocations. It could be alignment or page size, since the slab packs at interior offsets. That's a hypothesis I haven't verified.

Two possible fixes:

  1. Keep the natives deferred to materialize, which is D. It's simple and proven here, and costs about 0–5 s of boot.
  2. Give those tensors their own allocations, or 2 MiB alignment inside the slab.

I'll open a small PR doing (1) and gate it, unless you'd rather do (2).

AzeezIsh added a commit that referenced this pull request Nov 2, 2026
…lab (#308 decode regression)

Pair A/B vs main (3 boots/arm): decode +0.7..1.1%, C1/C2/C4 +0.5..0.8%, KL 0, boot neutral. CI green except the PR benchmark gate.
@maplepaladin73

Copy link
Copy Markdown
Contributor

Hardware check of this PR's loader (and #314's decode-regression fix) on main 9c451913, Qwen3.8-Flash-Next-FP4-Local, TP2 on two DGX Sparks — the serving stack from the PR's test plan, but on the SparkQwen 8x262k live profile (prefix caching on, MTP depth 7, max_prefill_tokens=16384), so boot includes a 262K KV pool build.

Arms (interleaved same-day, one arm each): this PR's stack at main 9c451913 (image built fresh from the repo's engine + SparkQwen install tree) vs the running deploy image, which is Atlas-Inf main 5d8f87ac (2026-10-31, before #308).

main 9c451913 (this PR + #314 + later) main 5d8f87ac (pre-#308 deploy)
Boot, container start → "Server live", s 24.4 69.4
decode code tok/s 56.9 31.5
decode JSON tok/s 63.9 35.1
decode prose tok/s 55.8 30.3
C1 / C2 / C4 / C8 tok/s 35.2 / 63.4 / 90.1 / 134.1 25.9 / 44.5 / 75.2 / 36.6*
cold TTFT 2K / 8K / 16K / 28K, s 0.17 / 0.17 / 0.18 / 0.22 0.70 / 1.97 / 2.05 / 3.26
warm-turn TTFT 8K / 20K, s 0.13 / 0.18 0.21 / 0.31

* the C8 cell on the pre-#308 arm hit what looks like a scheduling stall (25 s wall); treat it as suspect.

Read: at this tip the loader work is a large win on this profile — boot 24 s vs 69 s, and decode/TTFT/warm numbers all ahead. That's more boot gain than the PR's own 30.0 s vs 54.3 s, likely because the 8x262k profile builds a much bigger KV pool than the 8x32k Strict arm in the test plan, so the shard-read time saved is larger here. The decode numbers are in line with #314 having recovered the slab-offset regression (we did not observe the −1% decode the raw #308 tip had, though this is a different profile and single-arm).

Caveats: one arm each, not the PR's 3-boot interleaved A/B; the base here is the live deploy image (main 5d8f87ac, which also predates #159/#306/#307), not 0.4.0; and this profile runs --disable-tool-grammar=true with thinking default low. Greedy smoke (17×23) and a tool-call probe pass on both images; no engine errors. Outputs were not compared token-for-token here — the Qwen-side KL gate posted above already covers logits at the tested heads.

@data-angel
data-angel deleted the fix/csf-upload-decode branch November 3, 2026 05:07
vcruz305 pushed a commit to vcruz305/atlas that referenced this pull request Nov 11, 2026
Atlas-Inf#308 let the fast loader upload native MXFP8 modules through the shard path,
so they sat at interior offsets of a shard slab. On Qwen3.8-Flash-Next
(qwen4_exp, two DGX Sparks) that cost about 1% of decode. Bisected on the
pair, 3 fresh boots per arm, n=9: deferring the natives to `materialize`
again (its own allocation per module) recovered decode +0.5..1.0% and
C1/C2/C4 +0.9..1.5%, with identical logits (KL 0) and nearly all of the
boot win kept. Deferring the CSF streams again recovered nothing.

`deferred_modules` is `host_decode_modules` again; `materialize`'s
native-upload path is unchanged.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants