Skip to content

qwen4_exp: serve FP4-Local's NVFP4 PLE table from a packed row file (ATLAS_PLE_PACKED_DIR) - #269

Merged
AzeezIsh merged 3 commits into
Atlas-Inf:mainfrom
Enntity:sq-pr/ple
Oct 30, 2026
Merged

AzeezIsh merged 3 commits into
Atlas-Inf:mainfrom
Enntity:sq-pr/ple

Conversation

@data-angel

Copy link
Copy Markdown
Contributor

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 into ngram_pack/{check,fs,write}.rs for the cap):
    • per-chunk CRC32s, verified on open;
    • an mtime/inode identity;
    • a bounded header;
    • O_NOFOLLOW opens, create_new temp files and a flock;
    • the validated-inode check through open_row_cache;
    • ATLAS_PLE_PACKED_VERIFY=full for a full verify.
  • Gather: batched_embed_nvfp4 takes a per-plane slot stride. Split arenas pass the old strides, so main's arithmetic is unchanged. check_packed_stride accepts only the two valid pairings.
  • Precedence: ATLAS_PLE_RESIDENT=1 still wins and warns that the packed dir is ignored.
  • Unset or empty keeps main's split read byte for byte, including cache sizing.
  • Not in startup parity: both layouts serve identical bytes.

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.bin that 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, profile 8x32k (--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/atlas 9b25f57, image atlas-sparkqwen:3e0d9e7e4b29.

  • Candidate: Enntity/atlas enntity-stack/sq-integ cf4200e = Atlas-Inf main a12bffa plus this PR series, image atlas-sparkqwen:cc103bd6cc92.

  • Harness: SparkQwen bench/sq_bench.py: streamed, temperature 0, reasoning_effort low; 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. Plus greedy_eq.py (8 prompts, 320 tokens, temp 0) and lp_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-*):

Strict 0.4.0 Strict main+series Spark 0.4.0 Spark main+series
greedy text, 8 prompts 8/8 identical 8/8 identical
prompt logprobs (1K/6K/20K) max |Δ| 0.0000 max |Δ| 0.0000
decode prose / code tok/s 54.1 / 77.7 54.2 / 77.8 61.0 / 86.8 61.6 / 92.9
cold TTFT 2K / 16K / 28K s 0.681 / 3.94 / 6.92 0.677 / 3.95 / 6.99 0.673 / 3.90 / 6.88 0.673 / 3.94 / 6.94
C1 / C2 / C4 / C8 tok/s 51.3 / 83.5 / 131 / 192 51.3 / 83.4 / 130 / 189 58.1 / 88.5 / 139 / 192 58.8 / 89.2 / 139 / 202

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

  • Production's ngram_pack suite: 15 tests, plus the ignored verify-cost bench.
  • Interleaved-layout gather against the golden fixtures.
  • The stride guard.
  • fmt, clippy, doc and the spark-storage and spark-model tests pass.
  • Not yet run: the GPU golden gather test (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

data-angel and others added 3 commits October 29, 2026 21:23
…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]>
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