Skip to content

display carveout: lend the GB10 display memory to the KV cache (SparkQwen 0.4.0; ported from Enntity) - #282

Merged
AzeezIsh merged 11 commits into
mainfrom
port/display-carveout
Oct 31, 2026
Merged

AzeezIsh merged 11 commits into
mainfrom
port/display-carveout

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

Ports SparkQwen 0.4.0's GB10 display-carveout KV extension (data-angel, Enntity 93d6e45a5, 049f872d8, 163150046, 4d75b9ec2; AGPL-3.0, credited in each commit).

  • What it does: spark display-carveout --lock <file> -- spark serve … lends the firmware's display memory (DISPLAY_FRM, 2–4 GiB on GB10) to the KV pool. The display scanout heap is exported as an RM object fd and handed to serve through ATLAS_DISPLAY_CARVEOUT_FD/_SIZE. KV buffers are then placed there.
  • QSA charge: 4d75b9ec2 charges qwen4_exp's per-token QSA indexer state for every added block. That's kv: charge QSA index-key state per block when the KV pool extends into the display carveout (ported from Enntity) #254's content, which couldn't land on its own because main had no carveout module.
  • Who uses it: five SparkQwen 0.4.0 profiles turn it on: hour-video, max-16x262k and saver-8x262k (all qualified) plus 4x512k and 4x1m.
  • Opt-in by construction: without the launcher's fd in the environment, KV sizing and placement are unchanged.
  • Dropped: the GLM latent-shard pieces (0e16041a8, 8addba7cd, GLM hunks of f4d95a100), because glm: add native prefill and FP4-Local support for dual DGX Spark #199 isn't on main.
  • Our fix on top (fa3bac885):
    • Bug: run natively as a normal user, outside a container, the launcher exported the carveout and then exited with PR_CAPBSET_DROP: Operation not permitted. Its bounding set lists CAP_SYS_ADMIN, and dropping it needs CAP_SETPCAP. 0.4.0 does the same; SparkQwen only avoids it because its container has no SYS_ADMIN.
    • Fix: when SYS_ADMIN isn't in the permitted set, the launcher sets PR_SET_NO_NEW_PRIVS and skips the drop. A privileged launcher behaves as before.
    • Port bug: N94 also found and fixed one (plan() had kept the pre-QSA-charge math).

Test plan (pair: reiner + spark2, TP=EP=2; receipts in reiner's ~/code/night1027/out/carv*/)

  • Unit tests: kv_carveout 5/5, placement tests, display_carveout 6/6. clippy and fmt are clean.
  • Carveout off (rc16, no launcher): C1 and C8 greedy 8/8 identical to main.
  • Carveout on, SparkQwen's qualified saver-8x262k config (PLE on NVMe, util 0.74, 262K context):
    • rank 0 (driver 580.126.09): display carveout 4092 MiB holds 3 buffers → 135290 blocks (+15916, +13.3%) for the same system memory. The ranks agree on 134028 blocks, against 117647 without the carveout.
    • C1 greedy 8/8 identical to the same config without the carveout.
    • SparkQwen's lp_dump per-token logprobs are identical at 1.5K / 6K / 20K (26,912 tokens, max |Δ| 0.0000).
  • Both ranks with the carveout: blocked by spark2's NVIDIA driver. spark2 runs 580.82.09 (reiner 580.126.09). There the export succeeds, but serve fails at import with display carveout import: CUDA_ERROR_INVALID_HANDLE, the same as 0.4.0's code would. Not tested here: whether a newer driver on spark2 fixes it; that needs the driver upgraded. Also, an import failure is fatal rather than falling back to no carveout. Behaviour is unchanged from 0.4.0; flagged for data-angel.

Part of bringing SparkQwen 0.4.0 onto main (#220). Supersedes #254.

Generated with Devin

AzeezIsh and others added 9 commits October 31, 2026 03:52
decode, but ~1.9 GB on top of the BF16 projections prefill keeps. At
MAX_BATCH 8 (SSM slots raised to 10 for Marconi) that took pre-KV from
89.2 to 91.1 GB of a 91.2 GB budget on the 96 GB framework GPU. 0.1 GB
of KV (203 blocks) was left, and C4/C8 requests ran one at a time: max
TTFT 85 s / 195 s, aggregate equal to C1 (f114 vs f110).

Above MAX_BATCH 1 the recipe now defaults ATLAS_QWEN4EXP_FP8_GDN=0. An
explicit setting still wins, and MAX_BATCH 1 (the recipe default) keeps
the FP8 copy. The variable is read only by qwen4_exp, so other models
are unaffected.

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

Ported from Enntity/atlas (AGPL-3.0-only, data-angel)
…out to the KV cache

GB10's firmware reserves a 2046 MiB display carveout (DISPLAY_FRM) that
Linux never sees and the NVIDIA driver never allocates from on this chip:
every scanout-carveout allocation path requires PDB_PROP_GPU_IS_SOC_SDM,
which only GB20B/GB20C set (checked in open-gpu-kernel-modules 580.173.02
and 580.178.04).

- `spark display-carveout --lock FILE -- CMD`: exports the carveout as an
  RM memory-list fd (needs CAP_SYS_ADMIN), takes a host-wide flock so one
  process per host holds it, drops CAP_SYS_ADMIN from its sets and the
  bounding set, and execs CMD with the fd and lock inherited. On a held
  lock, an unvalidated driver or a failed export it runs CMD without.
- The CUDA backend imports the fd with the VMM API on first use (after KV
  sizing), zeroes it, and lends pieces through `alloc_carveout`; `free`
  recognises them.
- KV pools are separate per-layer allocations, so whole buffers move: a
  placement planned at the largest block count each rank sizes for, kept
  through the ranks' min-agreement, so system-memory KV bytes never exceed
  the budgeted pool's. SparkGLM TP2: ~95.5K -> ~116K blocks per rank.

Measured on spark03 (580.178.04): export/import across exec works, 0 bad
words over the full region, SM-kernel copies at the speed of cuMemAlloc
memory; copy-engine memcpy runs at about half.

Provenance: the observation that DISPLAY_FRM is unused on GB10 and can be
exported as an RM memory-list fd comes from kindling-spark-os's dispram
(github.com/kindlingai/kindling-spark-os, AGPL-3.0; idea only, no code
taken), which credits emihuang's earlier NVIDIA developer forum post.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3660b64)
(cherry picked from commit ec1e151)
(cherry picked from commit 93d6e45)

Ported from Enntity/atlas (AGPL-3.0-only, data-angel)
…acement

Measured on spark03 (cvbench, Enntity/sparkglm#30) and confirmed in
open-gpu-kernel-modules 580.173.02: memory-list descriptors start
NV_MEMORY_UNCACHED and the sysmem path never sets them cached.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7258854)
(cherry picked from commit 049f872)

Ported from Enntity/atlas (AGPL-3.0-only, data-angel)
RM knows GB10 as chip GB20B, for which it manages DISPLAY_FRM as its
scanout heap: display surfaces are allocated there (spark03 headless:
4 MiB), so wrapping the whole region in a memory-list object overlapped
and zeroed them. The launcher now asks that heap for its largest free
range (NV01_MEMORY_SYSTEM with USE_SCANOUT_CARVEOUT), which needs no
CAP_SYS_ADMIN and never overlaps the display, and marks it
GPU_CACHEABLE: the GPU now caches it in L2 like cuMemAlloc memory
(4 MiB re-read 1,762 vs 260 GB/s, dependent load 156 vs 404 ns).

Driver compatibility: no version allowlist. All 52 open-gpu-kernel-
modules releases from 580.76.05 to 615.78.08 share every number,
layout and the heap (a probe compiled against each tag). Beyond them
the kernel and RM size checks fail a changed layout cleanly, allocation
parameters carry a zeroed tail (RM copies its own size), and the
allocation must prove it is the heap: one step more than DISPLAY_FRM
fails and the result is at least half of it.

03/04, production 4x1m profile, container without SYS_ADMIN: 2042/2044
of 2046 MiB lent, 126,726 agreed blocks (memory list 126,976), prompt-
logprob hash 246cd1331b41 on every arm, 64K cold prefill 25.69 s median
(memory list 26.31 s). Index buffers in the carveout no longer cost
prefill time (ATLAS_KV_CARVEOUT_ORDER=size: 25.93 s); the latent
default stays, since the latent pools already fill the carveout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 1631500)

Ported from Enntity/atlas (AGPL-3.0-only, data-angel)
…fields/tests, keep the per-token aux charge

Ported from Enntity/atlas (AGPL-3.0-only, data-angel)
… pools only by default — the L2-uncached carveout's worst case is the sparse index)
…ceiling math (4d75b9e's fit check — the earlier merge left pre-aux math)
…of failing

Run natively as a normal user (not root in a container), the launcher
holds no CAP_SYS_ADMIN, but its bounding set still lists it, and
PR_CAPBSET_DROP needs CAP_SETPCAP. So it exported the carveout and then
exited with "PR_CAPBSET_DROP: Operation not permitted" before exec,
on both ranks of our pair (0.4.0's launcher behaves the same outside
its container).

When CAP_SYS_ADMIN is not in the permitted set there is nothing to
drop, so set PR_SET_NO_NEW_PRIVS (allowed unprivileged), which keeps
the command from gaining the capability through a setuid or
file-capability exec. A launcher that holds the capability (root in a
container) drops it exactly as before.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh
AzeezIsh merged commit 2a28b4f into main Oct 31, 2026
25 of 26 checks passed
vcruz305 pushed a commit to vcruz305/atlas that referenced this pull request Nov 11, 2026
…-Inf#256)

Port of Atlas-Inf#256 (Enntity/atlas f3f3876 via 5497364, plus 8a8a959 from
Atlas-Inf#295) onto main's Atlas-Inf#286 video path. Atlas-Inf#256's stack base already landed
through Atlas-Inf#282, and the DFlash warm-ctx port from the same stack (Atlas-Inf#255) is
not included. Every video file here is byte-identical to the version
gated in train Atlas-Inf#305.

- ensure_decoder is the single source for the ffmpeg enabled/available
  check, in video_decode_ffmpeg/probe.rs (pub(super)); decode_with_plan
  and frames.rs call it.
- The moov/faststart decode tests use the enabled() policy; on a host
  with ffmpeg they fail on main under FfmpegPolicy::default().
- The GLM reference path pads a single sampled frame into a temporal
  pair. Qwen's generic path is unchanged.
- The generic-path GLM single-frame refusal test is dropped, superseded
  by the reference pad test (the generic GLM branches are now unreachable
  behind the is_glm5_next early return; follow-up).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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