Repository navigation
qwen4_exp: serve FP4-Local's NVFP4 PLE table from a packed row file (ATLAS_PLE_PACKED_DIR) - #269
Merged
Merged
Conversation
…ow file (Enntity/atlas eb33d8b+ee5992fe+f083f4a0+74f0f2ab) A table whose rows live in two tensors (codes and block scales at unrelated offsets) costs two NVMe reads per row-cache miss when read in place, and the PLE stall on Spark is per-IO latency, not bytes. `ngram_pack` interleaves the planes once into a derived file of fixed-stride rows that `NgramRowCache::open_at` opens as an ordinary contiguous table: one read per miss. Ported as production has it at 9b25f57, split into check/fs/write siblings for the 500-LoC cap with no logic edits: - The header carries the identity (resolved source names, lengths, mtimes, inodes, offsets, geometry, tag) and a CRC32 per 24 MiB chunk; an open re-hashes 16 random chunks (Verify::Full: all) and spot-checks one row per shard against its sources, so a stale or damaged file is rebuilt, never served. Header geometry is bounded on the u64s before anything is allocated. - Builds run under a per-file flock into a create_new temp file, fsynced and renamed; nothing in the packed dir is opened through a symlink, and `PackedTable::open_row_cache` refuses a cache whose fd is not the inode that was validated (`NgramRowCache::backing_file`). - The file name hashes the layout identity only. The real FP4-Local table is pinned to the name production's packer gives it, so tables already packed on disk are reused. crc32fast was already in the lock through flate2. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(ATLAS_PLE_PACKED_DIR) (Enntity/atlas 2d7d1c9+866835fd) FP4-Local stores each PLE shard as `weight` U8 [R, 80] (E2M1) plus `weight_scale` F8_E4M3 [R, 10] at unrelated offsets, so main's row cache reads a miss as two NVMe reads: the code row into the cache, the scale row into its segmented block-scale arena. Per-IO latency is the PLE stall on Spark. `ATLAS_PLE_PACKED_DIR=<dir>` (the switch SparkQwen 0.4.0 sets) packs the two planes once with `spark_storage::ngram_pack` into 96-byte rows (80 codes + 10 scales + 6 pad, 28.8 GB) under `<dir>` and opens that as one contiguous table with no scale arena: one read per miss. Keepalive, fault pool and prefill warm apply unchanged. `ATLAS_PLE_PACKED_VERIFY=full` re-hashes the whole copy on open (default: 16 random chunks). What main already had and keeps: the NVFP4 GPU gather (`batched_embed_nvfp4`, (e2m1 * e4m3) * global in f32 then BF16, the order production's kernel uses), the global scale in `Nvfp4RowGeom`, the deferred `weight_scale` shards, and `ATLAS_PLE_RESIDENT`. So this port adds only: - `batched_embed_nvfp4` takes a slot stride per plane. Split arenas pass dim/2 and dim/group (main's arithmetic, unchanged); interleaved rows pass the row stride for both, with the scale plane just past the codes (`Nvfp4RowGeom::gather_planes`). Resident path and microtest updated. - `check_packed_stride` accepts exactly two pairings: codes beside a scale arena, or interleaved rows without one. - The loader packs only when the table is NVFP4 and the variable is set and non-empty; unset, the split read is byte for byte main's, cache sizing included (`slot_bytes` replaces `scale_stride` with the same value). `ATLAS_PLE_CACHE_GB` counts 96 B per interleaved slot. `ATLAS_PLE_RESIDENT=1` still wins and warns that the dir is ignored. - Unlike production, unset does not default to `<HF hub cache>/atlas-ple`. Not a startup-parity setting: both layouts serve the same bytes through the same decode, so ranks that differ only differ in read latency. Tests: production's NVFP4 golden fixture (nine FP4-Local rows dequantized with flashinfer's oracle) now holds main's host decoder to the oracle bit for bit through the interleaved layout, and shows weight_scale_2 multiplies. The GPU test (ignored) packs golden rows among junk rows, faults them through the O_DIRECT cache (a 4 KiB-straddling row included) and gathers them with the interleaved strides. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ot holds (Enntity/atlas 1ff172a) The line sized the table and the slot arena off `head_dim * elem` and `head_dim * 2`: for NVFP4 that counted the 80 code bytes only (25.6 GB, no scales), and for F8_E4M3 it doubled the arena. It now reports the stored columns and the bytes one slot pins (`slot_bytes`: 90 split, 96 packed, `head_dim * elem` otherwise) and sizes both from that. Log text only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #220.
What
ATLAS_PLE_PACKED_DIR=<dir>serves FP4-Local's NVFP4 per-layer-embedding n-gram table through one packed row file on NVMe. Each 96-byte row holds the codes followed by the scales, so a cold miss is a single read instead of one read in each split arena. Ported from SparkQwen's engine (eb33d8b, 2d7d1c9, 866835f, ee5992f, f083f4a, 74f0f2a, 1ff172a).spark_storage::ngram_pack(split intongram_pack/{check,fs,write}.rsfor the cap):O_NOFOLLOWopens,create_newtemp files and a flock;open_row_cache;ATLAS_PLE_PACKED_VERIFY=fullfor a full verify.batched_embed_nvfp4takes a per-plane slot stride. Split arenas pass the old strides, so main's arithmetic is unchanged.check_packed_strideaccepts only the two valid pairings.ATLAS_PLE_RESIDENT=1still wins and warns that the packed dir is ignored.Why
SparkQwen 0.4.0 serves the table this way; main read it split. The file name and identity match production's. On the pair, main reused the
/atlas-ple/ngram-nvfp4g16-5a2bf6d19253ea51.binthat 0.4.0 had packed, without repacking 29 GB.Benchmarks
Fingerprint (every number below). ennspark03/04, two GB10s at TP=EP=2 over RoCE, 2026-10-29. Checkpoint
nvidia/Qwen3.8-Flash-Next-FP4-Local. Served by the SparkQwen launcher, profile8x32k(--speculative --num-drafts=7 --max-num-seqs=8 --max-seq-len=32768 --max-prefill-tokens=16384 --kv-cache-dtype=bf16 --gpu-memory-utilization=0.88 --enable-prefix-caching), Strict and Spark modes.Baseline: SparkQwen 0.4.0, engine
Enntity/atlas9b25f57, imageatlas-sparkqwen:3e0d9e7e4b29.Candidate:
Enntity/atlasenntity-stack/sq-integcf4200e = Atlas-Inf main a12bffa plus this PR series, imageatlas-sparkqwen:cc103bd6cc92.Harness: SparkQwen
bench/sq_bench.py: streamed, temperature 0,reasoning_effortlow; decode = 384-token prose/code/JSON, 3 reps; cold TTFT at 2K/8K/16K/28K, 2 reps; aggregate decode at C1–C8, 256 tokens per stream, 2 reps; warm 8K/20K conversations. Medians per cell. Plusgreedy_eq.py(8 prompts, 320 tokens, temp 0) andlp_dump.py(echo prompt logprobs at 1K/6K/20K tokens).Baseline and candidate arms interleaved on the same pair in one session.
One box and one harness, so these are observations under this fingerprint, not cross-validated claims.
No isolated A/B. The arm only affects cold PLE misses, and it ran inside the series.
The load log shows the reuse:
read through packed ... (96 B rows, one NVMe read per miss).Golden test: nine real FP4-Local rows through pack and cache match the flashinfer oracle bit for bit.
Whole series vs SparkQwen 0.4.0 (arms
q-040-*/q-fix-*):For reference, Atlas-Inf main c998a49 with the same launcher measured −9..−12% at C1, −15% at C2, −21..−25% at C4 and +21% cold TTFT against 0.4.0 (2026-10-29, same pair and harness).
Default. Opt-in, set by a path. The measurement that would flip it on: cold-miss PLE latency, split vs packed, on an NVMe-backed run with the table not resident.
Tests
ngram_packsuite: 15 tests, plus the ignored verify-cost bench.fmt,clippy,docand the spark-storage and spark-model tests pass.nvfp4_packed_gather_matches_the_golden_through_pack_and_cache), and the pull-request gates.Authorship
AI-authored (Claude Code), ported from SparkQwen's AI-authored engine. No human-written code.
🤖 Generated with Claude Code