Repository navigation
score: knowledge packs, encoded once and read by every request (stacked on #331) - #332
Conversation
|
@data-angel I tested this on one GB10 (sparky) as a local test merge onto main Works as described:
One discrepancy, and it's why I haven't merged. The description says that with packs off, existing score passes change only in a bit-identical attention kernel. That's not what I measured:
My guess is Two ways to resolve it:
Either is fine with me; I'll merge once one of them is in. Receipts: |
The split entry's rule fired for any score stream with more than 4,096 keys and at least 4 keys a row, pack or not, so a plain score request over a long state took the split kernel and moved by about one bf16 ulp in attention: with packs off, probs differed from main past ~4K keys (Atlas-Inf#332 review). Each stream now carries a pack-reader mark (BatchedAttnMetadata pack_streams, staged only for a pass that carries a pack). The host picks the split entry only when a pack-reading stream meets the length rule, and the kernel splits only those streams. Every other stream, and every pass without a pack, takes the unsplit arithmetic. The decision stays per stream, so a merged pass still scores each request as alone. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@AzeezIsh thanks, your guess was right. I took your first option: only a stream that reads a knowledge pack can take The change. The score pass carries a per-stream pack mask, and both the host tile plan ( GB10 check (2026-11-17, one GB10, d3-ultra NVFP4 W4A4, the serve flags from the PR's receipts,
I've updated the description: the split rule now says it applies to pack streams only, and the test plan includes this run. Receipts (JSONs, diffs, serve lines, binary hashes) are kept on our Spark; I can attach them if you want them. |
demo/watch.html: a film read live. Each frame the page can get answered is asked ten questions in one request: emotion and action as distributions, the setting, how many people, how tense, and five yes/no flags. Bars, a stacked emotion river over the last 30 s of film, a strip of moments at film time, and the frame the answers are about in the corner (they trail it by about half a second). 3.0-3.7 frames/s with 2 in flight on one DGX Spark. The film is Tears of Steel (Blender Foundation, CC BY 3.0): demo/videos/fetch.py downloads it and cuts it to its story. record.py --take watch records it in the installed Chrome, which keeps the live pace while recording. "remember": false in /v1/systemone (a SparkScore extension): images asked once, such as video frames, are read without being kept as an image pack. demo/serve.py answers single byte ranges for static files, so a video seeks; demo/out/ stays unreachable for HEAD as well as GET. ./start.sh and install/serve.py take the photo library settings: STORE_GB (the image pack store in device memory; Atlas's memory budget drops to 0.70 to make room), STORE_DIR and STORE_DISK_GB (its NVMe tier). demo/IMAGES.md runs the image demos from one ./start.sh line. install/atlas-source.json: Enntity/atlas sparkscore/score-images 68baafe3c (image packs, the pack store with NVMe tier and read-ahead, the image prefill fusions; stacked on the knowledge packs proposed as Atlas-Inf/atlas#332). Tests: test_install_serve.py (store settings), remember=false through the server and the backend, byte ranges, HEAD of demo/out/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A /v1/score request can continue a knowledge pack: a token block (a policy, a handbook) placed before its prefix at positions [0, P). The model encodes the pack once in a score pass of its own (prefix_bidir: one bidirectional block that reads nothing after it) and holds its K/V blocks and the SSM state and conv window after it, one retained sequence per pack. A request on the pack is planned at positions shifted by P and never recomputes it: - the streams that read the pack directly share its whole KV blocks by reference count and copy its partial last block; - their entry SSM state and conv window are the pack's, read in place through the score pass's pointer tables (no state copy); a layer without the single-launch scan or conv1d copies the pack's state in first; - branches share their head's blocks and fork from it as before. Server: "pack": [ids] or "pack_id" on /v1/score; the response carries "pack_id" and "pack": "built" | "held"; an id no longer held answers 404. --score-packs N (default 0, off) bounds the packs held (least recently used evicted first, after a new one is built). Each pack keeps one SSM slot, so the scheduler admits that many fewer sequences and a tick re-reads its stream budget after building packs. d3-ultra W4A4 on one DGX Spark, 40 tickets x 3 questions on a 1,179-token handbook: rules 35/35 as with the handbook in the state; p50 173.8 ms against 537.8 ms in the state and 168.9 ms with no handbook. At 12K pack tokens: 280 ms against 5.45 s. Merged pack passes score exactly as alone. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit f926d0f)
…a cluster Score streams are short (a ~240-row state, ~20-row branches), so their full-attention layers ran the BR=32 kernel (4 warps, QK on two, one CTA an SM) at ~10 TFLOPS however long the keys: a 12K-token pack cost ~110 ms. Score passes now run new rows128 entries at every length: - `_gqa`: a tile's 128 rows are one KV head's six query heads over ~21 stream rows, sharing every K/V tile, so short streams fill tiles. Per row the arithmetic is the per-head kernels', so the output is bit-identical. - `_gqa_split2`: 2-CTA clusters. A stream with more than 4,096 keys and at least 4 keys a row (a pack under a short state) splits each tile's KV range across the pair, combined through distributed shared memory, no global workspace; any other stream in the pass gives each rank whole tiles, computed exactly as `_gqa`. The rule reads the stream alone, so a merged pass scores as each request alone. Split rows are within one bf16 ulp of the unsplit kernel, with the same error against fp64. Microbench, d3 geometry on one GB10, attention over 16 layers: 1.2K pack 16.6 -> 5.1 ms, 12K pack 143 -> 32 ms, 12K x 8 merged 1040 -> 212 ms; no pack 3.8 -> 1.5 ms; a 2,450-token state (per-head rows128 today) 51.9 -> 44.9 ms. Four-CTA clusters (13% slower at eight merged) and a 2K-key threshold (splits a p90 request's branches, +5%) were rejected. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 3a6881f)
A paged prefill chunk's seq_len buffer held its total plus at most 8 attention-piece extents, so any chunk wider than 32,768 rows failed with "exceeds 8 attention pieces". A knowledge pack is encoded in one pass, which capped packs at ~32K tokens. The cap now derives from PREFILL_MAX_ROWS (262,144): 64 pieces of 4,096 rows plus the top-k split, 65 extents (264 bytes per sequence). Only GLM paged attention reads the extents; every other path reads the total. d3-ultra NVFP4 on one GB10, 7-rule handbook, 81,920-row arena: packs of 35,956 and 48,320 tokens score 35/35 rule cases at p50 234 and 283 ms. Wider packs now stop at the 65,520-row chunk clamp (CUDA grid-Y) and a 53,187-row score pass. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 6ac85be)
The split entry's rule fired for any score stream with more than 4,096 keys and at least 4 keys a row, pack or not, so a plain score request over a long state took the split kernel and moved by about one bf16 ulp in attention: with packs off, probs differed from main past ~4K keys (Atlas-Inf#332 review). Each stream now carries a pack-reader mark (BatchedAttnMetadata pack_streams, staged only for a pass that carries a pack). The host picks the split entry only when a pack-reading stream meets the length rule, and the kernel splits only those streams. Every other stream, and every pass without a pack, takes the unsplit arithmetic. The decision stays per stream, so a merged pass still scores each request as alone. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> (cherry picked from commit afd71f4)
afd71f4 to
4a40e3d
Compare
|
@data-angel Pair gate for #332: passed. Merging after this comment. #397 found something; details there. #332 changes shared prefill code ( GLM-5.3-Flash FP4-Local, 2× GB10 (SparkGLM 0.3.2 4x1m spark, 2 boots per arm,
Qwen3.8-Flash-Next FP4-Local, 2× GB10 (8x32k spark, 2 boots per arm,
Qwen3.8-27B NVFP4, one GB10 (sparky, #333's exact profile at 8 sequences, greedy_eq 8 prompts × 320 tokens):
CI matches main's baseline: the env budget, PR benchmark gate and cargo deny jobs fail on main as well, and every workspace job passed. Generated with Devin |
Brings the branch up to main (76 commits: Inkling 2 Mini Atlas-Inf#401/Atlas-Inf#404/Atlas-Inf#410, Atlas-Inf#332 and the rest). Nine conflicts, each two additions in the same place, resolved as unions: the config parser imports and the dispatch list, kv_only_prefix_cache_is_safe (deepseek_v41 and inkling2_loop both false), the factory loaders and its supported-model list, the aux-state model list, the PDL module doc, the tokenizer modules, tool_call_ids_in_template (main's matches! for Inkling, this branch's `!= ChatEncoding::Jinja`, since ChatEncoding is now Jinja | Deepseek(dialect)), and tool_defaults.toml. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…, NVMe tier and read-ahead score: images in /v1/score, image packs with an FP8 store, NVMe tier and read-ahead (stacked on #332)
Summary
A
/v1/scorerequest can now continue a knowledge pack: a token block (a policy, a handbook) placed before itsprefix at positions
[0, P). The model encodes the pack once and holds its K/V and its SSM state and conv window.Later requests read the pack instead of recomputing it.
Under
prefix_bidir, the pack is one bidirectional block that never reads the request's state, while the state readsit. Without packs, a decision model such as
vllm-sr/d3-ultrahas to carry the knowledge inside its bidirectionalstate block. That block reads the request, so no prefix cache can reuse it: every request pays for the whole handbook.
d3-ultra W4A4 on one GB10, 40 tickets × 3 questions, p50 at the client:
The model is not retrained. Every override rule the knowledge carries is still applied: 35/35 and 128/128 rule cases,
the same as with the knowledge in the state, and 6/35 with no knowledge. A short pack can be faster than no knowledge,
because d3's system prompt moves into the pack.
Packs are off by default (
--score-packs 0). With packs off, the only change on existing score passes is theattention kernel below, whose output is bit-identical. No
ATLAS_*variables are added.What's in it
Knowledge packs (
f926d0fe6)spark-server/src/api/score.rs):"pack": [ids]or"pack_id": "<16 hex>"on/v1/score; sending both is a 400."pack_id"and"pack": "built" | "held".--score-packsgets 422.spark-model/.../prefill_b/score_pack.rs):hash collision is an error, never a wrong pack.
so a failed build keeps every held pack.
score_plan.rs): a request on a pack is planned at positions shifted by P.block.
(no state copy). A layer without the single-launch scan or conv1d copies the pack's state in first.
score_capacity.rs,serve_load.rs): each held pack keeps one SSM slot.--score-packsfewer sequences, and startup refuses--score-packs >= --max-batch-size.Score attention tiles (
3a6881fd4,rows128.rs,prefill_paged_rows128.cu)Score streams are short: a ~240-row state and ~20-row branches. Their full-attention layers ran the BR=32 kernel at
~10 TFLOPS however long the keys, so a 12K-token pack cost ~110 ms. Score passes now run two new rows128 entries:
_gqa: a tile's 128 rows are one KV head's six query heads over ~21 stream rows, so they share every K/V tileand short streams fill tiles. The per-row arithmetic is the per-head kernel's, so the output is bit-identical.
_gqa_split2: 2-CTA clusters, for a stream that reads a knowledge pack and has more than 4,096 keys and atleast 4 keys per row (a pack under a short state). A stream that reads no pack never splits, however long its
state (
afd71f444): the pass carries a per-stream pack mask, and the host tile plan and the kernel both read it.no global workspace.
_gqa.pack streams split: before
afd71f444a long ordinary state split too and moved packs-off scores by up toone ulp in attention (the review on this PR).
Microbenchmark, d3 geometry on one GB10, attention over 16 layers:
Rejected:
Packs past 32K tokens (
6ac85beb4,layer/prefill_pieces.rs)A pack is encoded in one prefill pass, and paged prefill runs attention in pieces of
PREFILL_ATTENTION_ROWS(4,096)rows. A chunk's
seq_lenbuffer held 8 sub-chunk extents, so a pack over 32K tokens failed with "exceeds 8 attentionpieces". The buffer is now sized from a native-context chunk (
PREFILL_MAX_ROWS= 262,144: 64 pieces plus the top-ksplit). That costs 228 more bytes per chunk buffer (264 instead of 36); nothing else changes, and only GLM paged attention reads the
extents.
Same handbook and rules as above, padded with filler, d3-ultra W4A4 on one GB10, p50 at the client:
Past about 53K tokens a pack no longer fits one score pass (53,187 rows here), and it is refused with 422 as before.
Longer packs would need a pack built across several passes, which this PR does not do.
Determinism
Test plan
Without a GPU (the pinned 1.93.1 toolchain on aarch64, from a
git archiveof the head,ATLAS_SKIP_BUILD=1):cargo fmt --all -- --check,typos,bash scripts/check-license-headers.shcargo clippy --workspace --testswith no warnings, andcargo doc --no-deps -D warningsforspark-modelandspark-servera_pack_is_tokens_or_an_id_never_both);with no tail copy;
long_pack_under_a_short_state_splits,short_packs_and_long_states_do_not_split);an_unknown_pack_error_is_its_own_kind, among others);a_native_context_chunk_fits_the_extent_buffer).On a GB10 (DGX Spark),
vllm-sr/d3-ultraNVFP4 W4A4, at this code:(rules4); mean KL against the BF16 reference is 0.0151 and 0.0379. For scale, W4A4 against BF16 on d3's 49-question
oracle is 0.0148.
6ac85beb4.a non-hex id, out-of-vocab pack ids) are unit-tested.
afd71f444(2026-11-17, one GB10, d3-ultra NVFP4 W4A4, the serve flags of thereceipts above):
/v1/scoreon 1,250- and 14,990-token states of seeded random tokens (causal andprefix_bidir, 6 branches, each request sent 3 times) is bit-identical to this branch's base on main (score: one-pass prefill-only scoring (/v1/score) and W4A4 dense 27B prefill kernels for GB10 #331 asmerged,
d0aeac3f8) with--score-packs 0and with--score-packs 2. The previous head(
6ac85beb4) differed from main by up to 0.031 (causal) and 0.065 (prefix_bidir) on the 14,990-token state.A 12K-token pack scores exactly as at
6ac85beb4(solo, by id, and merged), so the pack path is unchanged.cargo test --releaseforrows128(4),score_plan(7) and the server'sscoretests (28) pass on the GB10.--pull-request-gatesuites. Chat serving is unchanged, and with packs off score passes changeonly in the bit-identical attention kernel (checked against main, above).
Receipts and scripts: https://github.com/Enntity/sparkscore/tree/main/results/2026-11-08-knowledge-packs. The
write-up: https://github.com/Enntity/sparkscore/blob/main/docs/paperlets/knowledge-packs.md
Notes for reviewers
crates/**/*.rsfiles over 500 lines are all on the file-size allow-list. The one new file,score_pack.rs, is351 lines.
traits/model.rs):Modelgainsscore_pack, which defaults to unsupported, and the scorerequest struct gains
pack: Option<u64>.is fine for a single-tenant server; a multi-tenant deployment would want the id keyed.
Authorship
Written with Claude Code (Claude Opus 5.5), directed and reviewed by Jason McCartney.
CLA
🤖 Generated with Claude Code