Skip to content

GB10 unified memory: KV budget and cuCtxCreate respond to page-cache-polluted MemFree, not MemAvailable — same core+reserve gives 2.08M vs 3.43M KV tokens and spurious CUDA_ERROR_OUT_OF_MEMORY #630

In progress

Description

@pfn

Environment

2x DGX Spark (GB10, 121.6 GiB unified memory each), flare 0.5.0, manual two-rank flare run and orbit run. Core: GLM-5.3-Flash-FP4-Local TP2 (CP-off via --no-context-parallel), per-request context 1,048,576, [memory] reserve = "4G".

Observed — identical core, identical flags, different page-cache state at plan time

memory state at plan cache budget KV pages KV tokens source log
page cache full (distribution re-hash filled it) 13.75 GiB 8,129 2,081,024 orbit run
page cache full (second polluted run) 14.44 GiB 8,548 2,188,288 orbit run
page cache cleared first (MemFree ~114 GiB) 22.20 GiB 13,389 3,427,584 manual run

MemAvailable reads ~116 GiB in every one of those states; only MemFree differs (0.8–1.4 GiB vs 114 GiB). On GB10 the page cache competes with CUDA allocations, and two distinct failures follow:

  1. Hard failure — cuCtxCreate_v2 failed (2, CUDA_ERROR_OUT_OF_MEMORY) during Initialize GPU, reproduced twice with MemFree 0.8–1.5 GiB while MemAvailable still reported ≈116 GiB:
    [rank 0 neuron] [  FAILED  ] Initialize GPU.  0.2s
    [rank 0 neuron] Error: cuCtxCreate_v2 failed (2, CUDA_ERROR_OUT_OF_MEMORY): out of memory
    
  2. Silent degradation — even when startup succeeds, the KV pool is planned 37 % smaller (limited by memory) with no hint that the "missing" memory is reclaimable page cache created by flare's own reads minutes earlier.

No-root workaround that restores correct behavior

Allocate + touch anonymous memory to force eviction, release, then launch (MemFree 6.6 → 64.8 GiB / 4.4 → 64.7 GiB, Cached 110 → 52 GiB). With that baseline, plans land at the 22.2 GiB / 3.43 M-token figure consistently. (sync; echo 3 > /proc/sys/vm/drop_caches does the same but needs root; anonymous-touch works without.)

Asks

  1. Before planning the KV pool on unified-memory parts, either reap reclaimable page cache or size the budget from physically-free pages (MemFree-like), not MemAvailable-style accounting.
  2. If the plan lands well below what a clean baseline would give, log a one-line warning that reclaimable page cache is limiting the KV budget.
  3. On the cuCtxCreate failure path, print MemFree/MemAvailable/Cached so the root cause is visible — both reproductions looked like a genuine OOM with 116 GiB "available", which cost us two dead runs.

Related

#73 documents the export-time cousin of this (vm.min_free_kbytes watermarks hide ~6.6 GB from the headroom check); this is the serving-time cousin (reclaimable page cache pinning MemFree). Same island: GB10 free-memory accounting.

Activity

  1. added
    area:memory
    bug
    performance
    priority:P2
    triage:investigate
    on Nov 30, 2026
  2. pfn commented on Dec 1, 2026

    @pfn
    Author

    Still open on main e85019b9 — #646's GB10 KV-sizing change did not cover this path.

    Cleanest reproduction yet (same core gb10-tp2-…0434, same reserve=4G, nothing else running):

    launch memory state at plan time Allocate cache
    orbit run (plans immediately after distributing ~95 GiB of rank-1 weights over CX7, which reads them into page cache on the controller) MemFree depressed by distribution reads 13.3 GiB · 2,005,760 KV tokens (both ranks)
    manual flare run after echo 3 > drop_caches-style eviction MemFree ~110 GiB 22.2 GiB · 3,427,584 KV tokens

    i.e. the KV pool silently loses ~41% of its tokens purely because of page cache pinned by a read burst that finished seconds earlier — and 2,005,760 sat just above our 2M-token operating floor, so the same plan can land unacceptably low. MemAvailable still reads ~115 GiB at plan time; only MemFree predicts the outcome (unified memory, cuCtxCreate_v2 can't use page cache).

    The ask from the original report stands: size the KV plan (and the CUDA context budget) from MemFree, or flush reclaimable cache before planning on GB10; either way please print MemFree/MemAvailable/Cached alongside the Allocate cache line, and consider warning when the two diverge by >10 GiB.

  3. pfn commented on Dec 2, 2026

    @pfn
    Author

    Still open on v0.5.1 (1fbcc3c9, #667) — first GB10 re-measurement of the page-cache release described there ("not yet re-measured on GB10 hardware").

    Same pair, same day, same core/flags, nothing else running; only difference is who launches:

    launch memory state at plan time Allocate cache
    orbit run (plans immediately after distributing ~84 GiB of rank-1 weights over CX7, which saturates page cache on both ends — reads on the controller, fabric writes on the peer) controller MemFree depressed by distribution reads 13.0 GiB · 1,961,984 KV tokens · 7,664 pages · 152 slots (both ranks, limited by memory)
    manual flare run after eviction MemFree ~107 GiB 20.5 GiB · 3,153,664 KV tokens · 12,319 pages · 244 slots

    −37.8% of the KV pool, and 1,961,984 is below our 2,000,000-token operating floor (the previous e85019b9 data point, 2,005,760 on the older core, scraped past it). The arithmetic is clean: the two plans differ by 7.5 GiB of budget, and at this core's fixed 153,837 tokens/GiB that is exactly the 1.19M-token delta — i.e. the sizing path is unchanged, it still trusts a memory figure that distribution's own residency depresses.

    A detail from the per-rank Plan cache lines that may help localize it: rank 0 (controller) budgeted 13.00 GiB while rank 1 (peer) budgeted 14.42 GiB; the group takes the min, so the polluted controller is the binding constraint. After the group was fully loaded and idle: controller MemFree 1.0 / MemAvailable 11.2 / Cached 10.6 GiB vs peer MemFree 11.9 / MemAvailable 13.2 / Cached 1.6 GiB — ~9 GiB of distribution-related page cache still resident on the controller at idle, consistent with the 7.5 GiB budget shortfall. None of the release calls added by #667 (sha256_file, serve_source ranges, store_parallel/store_partial, agent::fetch, post-load_payload) visibly cleared it by plan time on this path.

    For completeness, eviction quality on the manual side also shifts the plan: with Cached 8.2 GiB still resident (an aggressive MemFree-targeted evictor declared victory) the manual launch planned 3,153,664; the same core with Cached 1.4 GiB planned 3,252,736. MemFree alone can over-report cleanliness when reclaimable cache is left in place.

    The ask stands: size the KV plan (and CUDA context budget) from MemFree, or flush reclaimable cache before planning; print MemFree/MemAvailable/Cached alongside the Allocate cache line; warn when they diverge by >10 GiB. Happy to run any instrumented pass on this hardware — it is a 5-minute reproduction (orbit run on a 2-node GB10 pair, compare against a manual launch of the same core).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:memorybugperformancepriority:P2triage:investigate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions