Skip to content

Faster cold start: parallel kernel module load, pinned weight upload, tokenizer under the weight read (Qwen3.8-27B 9.1–11.1 s → 7.3–8.1 s on one DGX Spark) - #398

Merged
AzeezIsh merged 4 commits into
Atlas-Inf:mainfrom
Enntity:upstream/fast-start-20261119
Nov 25, 2026

Conversation

@data-angel

Copy link
Copy Markdown
Contributor

Summary

Engine cold start for Qwen3.8-27B on one DGX Spark falls from 9.1–11.1 s to 7.3–8.1 s to ready, with no output change. Three independent commits:

  • atlas-core: load kernel modules on eight threads. Each blob is loaded twice (cudarc and raw driver), and each load is a JIT or a JIT-cache lookup. Serially, the target's 220 blobs took ~1 s; threaded, CUDA init goes 0.97 → 0.68 s. The calling thread still has the context bound afterwards (AtlasCudaBackend::new reads it back), maps are built in blob order, and the first failing blob stops the other loaders.
  • spark-runtime: upload plain tensors through pinned staging workers. The fast loader used to hand every tensor to one copier thread, which copied from pageable memory and drained the stream before the next. That loaded 18.8 GB in 3.05 s (6.2 GB/s), against ~10.5 GB/s of O_DIRECT reads from the same files.
    • Now plain tensors are allocated in order on the calling thread while 16 workers pread 16 MiB pieces into their own page-locked buffers and copy them on their own streams: 2.5–2.7 s.
    • CSF scale parts, F16 converts and tensors whose allocation fails keep the copier path and its managed-memory fallback.
    • Linux only; other platforms are unchanged.
    • direct_io's pread loop is factored into aligned_window + pread_window so both paths share it.
  • spark-server: run tokenizer parses under the weight read.
    • The tokenizer phase (chat tokenizer, four whole-vocabulary decode passes, tool markers, XGrammar engine: ~1.2 s on a 248K vocabulary) ran after the model was built.
    • The vocab cap parsed tokenizer.json again (~0.3 s) between the weights and the KV config.
    • Rank 0 now starts both on threads before the weight load. The early tokenizer result is used only if every input it read (EOS list, effective vocab size, model type, thinking support, template fields, ServeArgs) still equals what the serial path sees at phase 8. Otherwise the phase runs in place, exactly as before.

Measured (one DGX Spark, Qwen3.8-27B NVFP4, DFlash2)

Measured on Enntity's q27/conc branch (this series as Enntity#34), not on this branch. Setup: SparkQwen 0.7.0 27B image with the binary swapped, checkpoint evicted from the page cache before each start.

Before After
Launch to ready, cold 9.1–11.1 s 7.3–8.1 s
Fast loader, 18.8 GB 3.05 s 2.5–2.7 s
CUDA init (220 modules) 0.97 s 0.68 s
  • Digest of every resident tensor's bytes from fast_load_bench: identical old vs new (b4b9ae18a3bd270d).
  • Four greedy chat prompts (code, prose, JSON, thinking on): text and logprobs byte-identical old vs new.
  • KV pool not reduced: 21.8–22.5 GB new vs 21.1–21.7 GB old.

Tests

On this branch (main 269b533bc plus the three commits), in a Rust 1.93.1 container on GB10:

  • cargo fmt --all -- --check, ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests and scripts/check-license-headers.sh: clean.
  • cargo test -p spark-runtime --lib fast_weights: 30 passed.
    • New: pinned_upload_tests.rs (pieces cover each tensor once; every tensor lands byte for byte with and without aligned windows, including one larger than a piece and one ending at EOF; a read past EOF fails; nothing to upload is a no-op; an unallocated tensor is left to the caller).
    • New: a csf_load_tests case where one allocation fails and the tensor still lands.
  • cargo test -p spark-server --bin spark tokenizer_prep: 5 passed (the early phase equals the in-place phase; a vocab capped in between still agrees; changed inputs and a failed phase resolve in place; the early vocab cap equals the phase's).
  • cargo build --release -p spark-server for qwen3.8-27b.

Notes for reviewers

  • Shared code: AtlasRegistry::init runs for every CUDA model, and the fast loader for every safetensors load.
  • What's left is allocation: cuMemAlloc on GB10 runs at ~25 GB/s however many threads call it. A 27B serve allocates ~94 GB at startup (weights, layer build, KV, SSM pools, drafter context), so allocation, not the ~1.8 s disk read, is now the floor. Overlapping pool allocation with the weight read would need KV sizing moved earlier; not attempted here.
  • Tried and dropped: two staging buffers per worker measured slower (2.7–2.9 s).

🤖 Generated with Claude Code

data-angel and others added 3 commits November 19, 2026 07:09
Each of a target's PTX blobs is loaded twice (cudarc and raw driver), and
each load is a JIT or a JIT-cache lookup. Serially, Qwen3.8-27B's 220
blobs took ~1 s of every engine start on GB10; on eight threads the
backend is up ~0.3 s sooner. The calling thread still gets the context
bound (AtlasCudaBackend::new reads it back), the maps are built in blob
order, and the first failing blob stops the other loaders.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fast loader handed every tensor to one copier thread that copied it
from pageable memory and drained the stream before the next. On GB10 that
loaded Qwen3.8-27B's 18.8 GB in 3.05 s (6.2 GB/s) against ~10.5 GB/s of
O_DIRECT reads from the same files.

Plain tensors are now allocated in tensor order on the calling thread
while 16 workers pread 16 MiB pieces into their own page-locked buffers
and copy them on their own streams: 2.5-2.7 s, with a digest of every
resident tensor's bytes identical to the old loader. CSF scale parts, F16
converts and tensors whose allocation fails keep the copier path and its
managed-memory fallback. Linux only. Swept 4-32 workers and 8-64 MiB
pieces; two buffers per worker measured slower (2.7-2.9 s).

direct_io's pread loop is factored into aligned_window + pread_window so
both paths share it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tokenizer phase (chat tokenizer, four whole-vocabulary decode passes,
tool markers, XGrammar engine: ~1.2 s on Qwen3.8's 248K vocabulary) ran
after the model was built, and the vocab cap parsed tokenizer.json again
(~0.3 s) between the weights and the KV config. Both are CPU work that
read none of the GPU phases.

Rank 0 now starts the tokenizer phase on a thread before the weight load
and uses its result at phase 8 only if every input it read (EOS list,
vocab size after the tokenizer cap, model type, thinking support,
template fields, ServeArgs) still equals the serial path's; otherwise it
resolves in place as before. The vocab-size parse runs on a thread too.

Qwen3.8-27B on one Spark with this and the two loader changes: ready in
7.3-8.1 s from a cold page cache against 9.1-11.1 s, with greedy outputs
and logprobs identical to the old binary.

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

Copy link
Copy Markdown
Contributor

@data-angel I verified #398 on Atlas-Inf main 269b533, since the PR's numbers were taken on Enntity q27/conc. The integration head was 4094faf59 (main plus this PR, merged --no-ff).

GB10 (sparky, native qwen3.8-27b builds; binary sha256 97a4be59… main / bc7a76c1… integ)

  • Checkpoint nvidia/Qwen3.8-27B-NVFP4-QAD @ cd46ab5, served with the qwen3.8-27b-nvfp4-dflash2-exact recipe flags (DFlash2, 64 seqs, 262K).
  • The page cache was dropped before every start. Time is from launch to the first 200 from /health, polled every 0.1 s.
start 1 2 3 4 mean
main 14.42 s 14.51 13.93 14.53 14.35
+ #398 13.32 s 12.84 12.87 12.32 12.84 (−1.5 s, −10.5%)
  • Prompt logprobs (lp_dump: 1.5K, 6K and 20K prompts, 26,912 tokens): zero drift. The 160-token greedy continuation is identical.
  • greedy_eq at C1: 8/8 identical.
  • KV pool not reduced: 26.7k–28.1k blocks on both builds. That is boot-to-boot noise of about ±650 blocks, the same in both arms.
  • 0 ERROR/panic lines.
  • The gain is smaller than the 1.8–3 s on q27/conc. My guess is that time-to-ready here is dominated by something this PR doesn't touch, such as the allocation floor you mention. I haven't profiled it.

Linux HIP (framework, gfx1151, strix-hip builds 2649e854… / 2bebd521…, nvidia/Qwen3.8-27B-NVFP4 through serve-amd.sh)

  • The uploader is gated on cfg!(target_os = "linux"), not on CUDA, so Linux HIP takes the pinned path too. The comment above it says "Linux (CUDA, O_DIRECT) only".
  • It boots with no "pinned upload unavailable" fallback.
  • Greedy short, code and 2K answers are byte-identical, with zero logprob drift (242 tokens). 0 errors, 0 panics, clean shutdown.
  • That job polled readiness every 5 s, so it can't resolve start time on HIP. I'm not making a speed claim there.
  • Suggestion: either make the comment say Linux, CUDA and HIP, or gate the uploader on !cfg!(atlas_hip) if HIP wasn't meant to take it. It works either way.

From my side this is ready. I'm carrying it in integ/sparkqwen-27b-qad, alongside the recipe work that moves Atlas's 27B to the QAD checkpoint, following SparkQwen#47.

sparky nightq jobs 150b/151b · framework qctl 466-f344-hip-398 · 2026-11-21

Linux HIP builds take the pinned path as well (cfg!(target_os = "linux")),
and serve identically there; the comment said CUDA only.

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

Copy link
Copy Markdown
Contributor Author

@AzeezIsh thanks for checking it on main and on HIP.

  • HIP on the pinned path: that's fine by us, since it boots and serves identically there. I kept the target_os = "linux" gate and corrected the comment to say Linux (CUDA and HIP). That's 24094e9a9, which changes only the comment, so your receipts on 4094faf59 still hold for the code.
  • The smaller gain: your main baseline (14.4 s) is 3 to 5 s slower than q27/conc's before this PR (9.1 to 11.1 s), so most of main's time to ready is spent somewhere this PR doesn't touch. One fixed cost we measured on q27/conc is the KV pool allocation: cuMemAlloc at about 25 GB/s over about 94 GB, roughly 3.8 s. That is the floor I mentioned. I haven't profiled main's boot either, so I can't say where the rest of the gap goes.

🤖 Generated with Claude Code

@AzeezIsh

Copy link
Copy Markdown
Contributor

Queued in train #422 (integ/train-gb10-20261125b, stacked on #421), merged --no-ff. GB10 gate is sparky job 189; results will be posted on #422.

🤖 Generated with Claude Code

@AzeezIsh

Copy link
Copy Markdown
Contributor

GB10 gate of train #422 is green; results are on #422 (closure_attestation passes on one-model builds; 0 test failures; cold start −1.54 s; outputs identical). Merge follows #421.

🤖 Generated with Claude Code

@AzeezIsh
AzeezIsh merged commit 350fc38 into Atlas-Inf:main Nov 25, 2026
1 check failed
AzeezIsh added a commit that referenced this pull request Nov 25, 2026
…t cold start (#398)

GB10 (sparky 189): closure_attestation passes on one-model inkling-2-mini and qwen3.8-27b builds; full suite 6,829/0; Qwen3.8-27B lp_dump max|d| 0 and greedy C1/C8 8/8 vs #421; Inkling greedy 8/8; cold start 13.79 -> 12.25 s (-1.54 s). AMD (DevLab 45651124584): strix-hip builds with #420's build.rs, Strict/Spark --check, Spark C1 42.7 / C8 84.1. Follow-ups: c4108fd (rustdoc private link), c73fa30 (fast_weights_parity temp-dir race).
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.

2 participants