Repository navigation
score: images in /v1/score, image packs with an FP8 store, NVMe tier and read-ahead (stacked on #332) - #397
Conversation
… image passes
/v1/score takes `images` ([{data_base64, format}]) referenced by
<|vision_start|> <|image_pad|>xN <|vision_end|> runs in the prefix, and
optional per-branch `readouts`. The vision tower encodes every image of a
pass in one batch; each stream splices its request's slice of the output.
Image jobs share a pass up to the tower's output window
(ScoreBudget::vision_rows) and score bit-identically to running alone.
Request hardening: total vision rows per pass bounded (the oversized
fallback's bound is now an ensure!), at most MAX_VISION_ITEMS images, image
decodes bounded by permits and refused when the queue is full, video pads
refused in image requests, readout offsets distinct, and text-only
requests skip the image-marker checks (unchanged behaviour). 16-bit
LA/RGB/RGBA PNGs take the high byte as PIL does; 16-bit grey clips.
Vision tower (Qwen ViT, head_dim 72):
- vit_flash_attention_d72: one tensor-core launch over all heads replaces
the per-head GEMM/softmax/GEMM loop (ATLAS_VISION_ATTN_GEMM=1 keeps it);
GPU test against an FP64 reference.
- dense_gemm_bf16_pipelined_epi: bias, tanh-GELU and residual folded into
the GEMM epilogue, one BF16 rounding (ATLAS_VISION_UNFUSED=1 keeps the
separate passes); the single and batched blocks share one fused tail.
These change the vision numerics of every target sharing vision_encoder.cu,
chat included.
d3-ultra-NVFP4 on one Spark against d3's own BF16 runtime: 0/40 flips on
synthetic images, 5/144 near-tie flips on 24 COCO photos (mean KL 0.0089,
unchanged with pre-resized PNGs). 1024x576, one question: 329 ms engine;
1600x900 with 5 questions 2,876 -> 899 ms.
The image path was started in a Devin session.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 90b1982)
…prefill fusions Image packs. A photo's prefix (tokens + images) is a content-addressed pack encoded once; the missing packs of a tick are built together in merged passes (score_pack_build.rs). Unknown pack ids are answered 404 before a pass is merged, so one cannot fail its neighbours. Pack store (ATLAS_SCORE_STORE_GB). Every built pack is kept as FP8 rows in one device allocation (GDN h state per kd row, K/V per token and head, conv window raw), least recently used out first. A built pack is put back from its stored copy, so answers never depend on the store's history. A model the store cannot keep (FP8 KV, non-FP32 SSM state) or no memory for a copy leaves the pack unstored, said once; the build still succeeds. NVMe tier (ATLAS_SCORE_STORE_DIR, ATLAS_SCORE_STORE_DISK_GB). Device-evicted packs are written once to an O_DIRECT record file (exclusive create, 0600, budget reserved, unlinked once open) and read back on a miss. A pack being promoted keeps its records while room is made around it. Read-ahead (ATLAS_SCORE_STORE_READ_AHEAD, default 16 packs). A reader thread reads disk-only packs into pinned host slots ahead of their pass (Model::score_packs_prefetch / score_packs_wait). The scheduler runs the jobs whose packs are ready once at least half the queue is, waiting (at most 500 ms) otherwise, and asks the model with the queue out of its lock. A tick takes no more pack jobs than the model holds. A pack restored from a slot is unpacked in place (the GPU reads the page-locked slot), with no device copy. Generation stamps keep a read of a rewritten pack from being used; packs being read stay on disk; slots hold at most 256 MiB; a failed read is left to its pass. Prefill fusions, bit-identical: vision layer norm at any block size (vision_layer_norm_to), RoPE without the unused V transpose, one warp per gated-norm head, residual norms in 256-thread blocks where the norm module reduces in the 1024-thread order (rms_norm_rows_any_block marker), and K-tiled NVFP4 tokens for the persistent W4A4 GEMM (dl_quant_nvfp4_kt). cuBLASLt ViT GEMMs with fused epilogues behind ATLAS_VISION_LT. Optional kernels only some targets ship are asked for first (GpuBackend::ships_kernel, try_shipped_kernel), so a target without them records no unresolved lookup and its boot gate still passes; the pack store's kernels are checked the same way. ATLAS_SCORE_PACK_ROUNDTRIP: a test hook that round-trips held pack state through FP8/FP16 to measure what storage precision does to answers. Measured on one DGX Spark, d3-ultra NVFP4, 120 COCO photos, 16 requests in flight: re-sorting by a new question 33-35 photos/s from memory; with every pack on disk 25-26 photos/s without read-ahead and 32-34 with it. Answers are bit-identical across all of these. Kernel check: 299 lookups, 0 unresolved. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 68baafe)
AzeezIsh
left a comment
There was a problem hiding this comment.
@data-angel Thanks, the read-ahead and the FP8 store look good. Requesting changes for two things: a vision regression on Qwen3.8-Flash-Next, and red CI. #332 is merged (pair gate there), so this branch's own two commits are now the whole diff.
1. Qwen3.8-Flash-Next vision output changes. The description says the image-path fusions are bit-identical and other targets are unaffected. On our pair they aren't for qwen4_exp's vision tower.
Setup: 2× GB10, TP2/EP2, Qwen3.8-Flash-Next FP4-Local b9ce18a, the rc16 profile with --video-allow-ffmpeg, ATLAS_VISION_LT unset. Fresh builds: main 96b41363d, main + #332 (af1d46eba), and main + #332 + this PR (cb2340c45). Teacher-forced top-20 on 3 images and a video, each sent 3 times:
| Case | main + #332 vs main | main + #332 + #397 vs main |
|---|---|---|
| red (solid image) | 75/75 exact | 0/34 exact, KL mean 5.0e-3, max 0.10, top-1 33/34, first divergence at 33 |
| photo | 255/255 exact | 2/16 exact, KL mean 9.9e-3, top-1 15/16, first divergence at 15 |
| wide | 255/255 exact | 6/41 exact, KL mean 2.5e-3, top-1 41/41 |
| clip.mp4 | 255/255 exact | 1/27 exact, KL mean 1.3e-2, max 0.13, top-1 26/27, first divergence at 26 |
| text (6 cases + 4 generated) | exact | exact |
- It is deterministic. Each binary's r2/r3 repeats match its own r1 exactly, and a second fresh boot of
cb2340c45(separate job) gave the same numbers to every digit. - Generated lengths change, so the position counts differ: 36,765 → 34,599.
- Text-only prompts are unaffected: text KL 0 over 34,245 positions × 2 boots, greedy 8/8 at C1/C8, tools 21/21.
- GLM-5.3-Flash vision is unaffected: KL 0 over 29,488 positions, vision under 2 live decodes 5/5.
- Qwen3.8-27B text on one GB10 (serial and DFlash2) is 8/8 identical. We didn't run 27B vision, so it may drift too.
So some fusion this PR adds runs on the Qwen3.6-architecture ViT that Flash-Next uses (27 blocks, hidden 1152) and changes its bits. Candidates from your table: the flash ViT attention, the any-block layer norm, the RoPE transpose skip, the 256-thread residual norms (if Flash-Next's rms_norm.cu carries the rms_norm_rows_any_block marker), and the K-tiled W4A4 tokens. Could you find which one and either make it exact there or keep it to the score targets? If it's meant as a tolerated drift, it would need to be opt-in. We can re-run the same vision bisect on any head you push.
2. CI workspace jobs fail on this head (not main's baseline):
cargo clippy --tests,cargo test --workspace,cargo llvm-covandBuild mdBook + rustdocall stop atturbojpeg-sys v1.2.0's build script. The newturbojpeg = "1.5.1"dependency inspark-modelbuilds libjpeg-turbo from source (cmake + nasm), and the runner can't. Options: put it behind a feature that CI/default builds don't enable, use a pure-Rust decoder, or link a system libjpeg-turbo. Please also check that its license passesdeny.toml.- The ≤500-line cap. These cross it with no allow-list entry:
prefill_b/score_store.rs(new, 623),scheduler/score.rs(419 → 546),ops/dense_bf16mma_lowp_test_gpu.rs(399 → 531),prefill_b/score.rs(479 → 506).
Generated with Devin
The fused ViT kernels change vision output on every target whose tower links vision_encoder.cu (Qwen3.8-Flash-Next and Qwen3.8-27B included): the all-head flash attention accumulates its softmax over key tiles and rounds P for P·V on tensor cores, and the bias / GELU / residual epilogues round each output to BF16 once. Both are now opt-in together behind ATLAS_VISION_FUSED=1 (ATLAS_VISION_LT still needs it); unset, the tower runs main's kernels. ATLAS_VISION_UNFUSED and ATLAS_VISION_ATTN_GEMM are gone (the default is the unfused path). The RoPE kernel skips its V transpose only for the flash kernel, so only under the opt-in. vision_layer_norm_to stays on by default: a GPU test checks it against vision_layer_norm bit for bit at D 1024 / 1152 / 2048 / 5120, in place and src -> dst, on the qwen3.8-27b and qwen3.8-flash-next kernel builds. Qwen3.8-27B NVFP4 on one GB10, three images, greedy, top-20 logprobs, each sent twice: main 269b533 and this head give identical tokens and logprobs at all 302 positions (KL 0); with ATLAS_VISION_FUSED=1 they differ from the first token (mean KL 8.8e-3 to 1.4e-2), the drift the review measured on Flash-Next. The libjpeg-turbo decoder for /v1/score JPEGs (PIL's pixels) is behind a `pil-jpeg` feature on spark-model and spark-server, off by default: its build script compiles the C library with cmake and nasm, which CI runners lack. Without it JPEGs decode through `image`. The crates are Unlicense OR MIT; the bundled libjpeg-turbo is IJG / BSD-3-Clause / Zlib. Files back under the 500-line cap: score_store.rs's pack parts move to score_store_parts.rs, the scheduler's tick selection to score_tick.rs, the low-precision GEMM bench to dense_bf16mma_lowp_bench_gpu.rs, and the bidirectional staging helper from score.rs to score_pack.rs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@AzeezIsh Thanks. Both are addressed in 1. Vision drift. Two of the fusions caused it, and the description was wrong to call them bit-identical:
Both are now opt-in together behind The other candidates stay on by default:
Measured on one GB10: greedy, top-20 logprobs, three images (a solid red one, a photo, a 1600×400 wide one), each sent twice,
Every build repeats itself exactly. Flash-Next ran on one GB10 with the engine defaults. I didn't run TP2/EP2, the rc16 profile or video, so please re-run your bisect on the pair. 2. CI
Checked locally with the pinned Rust 1.93.1:
One note: the photos/s and latency numbers in the description were measured with the fused kernels. They now need 🤖 Generated with Claude Code |
|
Thanks for the review — pushed c41be77 for items 2 and 3: 2. CI. 3. Line cap. The four files are allow-listed with rationale comments; splits are tracked in #400. 1. Vision regression. Agree it should be exact or scoped. We can't bisect on our side right now — please re-run the same vision bisect on the current head, or tell us and we'll run it on a pair and report. If the culprit is one of the fusions in the table, gating it to the score targets is fine by us; if it's the residual norms, opt-in is fine too. The score-image targets themselves (d3-ultra image tasks) are gated by the accuracy receipt in the PR, and that gate was run with these fusions on. |
|
@AzeezIsh a correction: please disregard my comment of 11-19 23:54. It described This PR's head is
Still outstanding: your Flash-Next vision bisect on the pair (TP2/EP2, rc16, video) against 🤖 Generated with Claude Code |
|
@data-angel Re-gated Merge. One conflict, in Exact, with the vision fusions off (the default):
That covers the single-node half of my 11-19 finding. The pair setup (TP2/EP2, rc16) isn't available tonight, so that leg is still open. Pack scores moved about 20× further from plain. Same probe as #332's gate (job 109, synthetic handbook,
held == pack, merged ×8 == held, and Env budget. This PR adds 9 sparky nightq 190 / 190b · merge 🤖 Generated with Claude Code |
|
Pushed 1. Merge onto
|
|
@data-angel Re-gated First, a correction: you were right about the pack scores.
So the 0.11 shift came in with Everything else is identical to
CI has two red workspace jobs from this branch. Both pass on
The env budget (+4 now, thanks for folding), The pair (TP2/EP2) half of my 11-19 Flash-Next vision bisect can't run any more: the pair is gone. The single-node vision legs above are exact, which is what I can check. sparky nightq 215 · 🤖 Generated with Claude Code |
|
@data-angel I pushed
The workspace jobs pass on 🤖 Generated with Claude Code |
|
@data-angel Gated and merging, second in today's chain (after #411). Sparky job 219, one GB10, fresh worktrees:
So with sparky nightq 219 · 🤖 Generated with Claude Code |
…pseek_v41 Conflicts in five files, each two additions in the same place (Ling-3.2-air from Atlas-Inf#411, DeepSeek-V4.1 here): config.rs and config/dispatch.rs parser imports, the factory loader list and its Supported string, model_type_ships_vanilla_norm_weights, and supports_chunked_mla_impl (DeepSeek-V4.1's early return kept ahead of Atlas-Inf#411's Ling/GLM expression). Both sides kept everywhere.
…ince #397) #397 (merged 2026-12-01) added vit_flash_attention_d72 to the shared qwen3.6-35b-a3b vision_encoder.cu with a raw mma.sync helper. strix-hip's qwen3.6-27b, qwen3.6-35b-a3b and qwen3.8-flash-next targets link that file, so every strix-hip build of main fails ("invalid output constraint '+f' in asm", vision_encoder.cu:560; reproduced on framework at 50fad3f). The AMD branch runs atlas_emu::mma_m16n8k16; every caller drives it with the whole wave. NVIDIA keeps the original asm. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ndows first_run.ps1 serve refused to start) #397's dense_gemm_bf16_pipelined_epi lookup is soft (vit_fused() gates on handle != 0) but undeclared, so every serve without --dangerously-allow-unresolved-kernel-lookups stopped at boot. serve-amd.sh passes that flag; the Windows first_run.ps1 recipe does not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
strix-hip: fix main's AMD build (vision_encoder raw mma.sync since #397)
Summary
A
/v1/scorerequest can carry images, the way d3-ultra's own server takes them: base64 data URLs whose image pads sit in the prefix. Questions about a photo are branches over one encoding of it.The images and the state block before them can form an image pack: a pack (as in #332) whose build also runs the vision tower. A photo asked many questions is encoded once. The missing packs of a tick are built together in shared passes.
The pack store (
ATLAS_SCORE_STORE_GB, opt-in, default0= off) keeps every built pack in one device allocation, least recently used out first:hstate as FP8 rows with a scale per row.A 640x480 photo takes about 50 MB stored, against about 200 MB held. When
ATLAS_SCORE_STORE_GB > 0, a built pack is restored from its stored copy before use, so answers do not depend on the store's eviction history. WhenATLAS_SCORE_STORE_GBis unset or0, the store is a no-op and packs stay in their native held precision without FP8 compression.The NVMe tier (
ATLAS_SCORE_STORE_DIR,ATLAS_SCORE_STORE_DISK_GB) receives packs evicted from device memory, written once. It uses oneO_DIRECTrecord file, created exclusively with mode 0600, its budget reserved, and unlinked once open, as for the KV prefix tier.Read-ahead (configured via optional
<GiB>:<slots>onATLAS_SCORE_STORE_DISK_GB, default 16 packs):Model::score_packs_prefetch/score_packs_wait).Image-path fusions. Two are opt-in because they change vision numerics: the fused ViT attention and the fused GEMM epilogues, both behind
ATLAS_VISION_FUSED=1(ATLAS_VISION_FUSED=ltalso enables cuBLASLt for the ViT GEMMs). The rest are bit-identical and on by default:vit_flash_attention_d72)ATLAS_VISION_FUSED=1ATLAS_VISION_FUSED=1ATLAS_VISION_FUSED=ltvision_layer_norm)The libjpeg-turbo decoder for
/v1/scoreJPEGs is behind thepil-jpegcargo feature, which is off by default. With it, a scoring model sees PIL's pixels. Its build needs cmake and nasm.Other targets are unaffected
GpuBackend::ships_kernel/try_shipped_kernelbefore any lookup, so a target without them records no unresolved lookup and passes its boot gate. The residual-norm block size is resolved at load from a marker kernel,rms_norm_rows_any_block. A model's ownrms_norm.cuwithout it keeps 1024 threads.Measured
d3-ultra NVFP4 on one GB10 with
ATLAS_VISION_FUSED=1andpil-jpeg, 120 COCO photos, one yes/no question each, 16 requests in flight:ATLAS_VISION_FUSED=1. WithATLAS_VISION_FUSED=ltit is 307 ms; that path's numerics differ at the noise level.main269b533bcexactly. Qwen3.8-27B NVFP4 and Qwen3.8-Flash-Next FP4-Local on one GB10, three images, greedy, top-20 logprobs: 302/302 and 310/310 positions identical.--check-kernels, qwen3.8-27b): 299 lookups, 0 unresolved.Tests
pdl): 6 pass, includingpdl_target_kernels_wait_exactly_when_listedwithdl_quant_nvfp4_kt.score,prefill_blocks_are_reserved_with_their_window): pass, includingstore_is_opt_in_by_default,disk_spec_parses_budget_and_optional_read_ahead, and the four reader-thread tests.--bin spark -- score): 42 pass, including the ready-first tick rule and the cap of pack jobs per tick at the held-pack limit.