Skip to content

[Engine] strata-inkling 0.1.65 hip-rx7900: --kv k8v4/k8v8 allocate MORE VRAM than fp16 — "kv grow v: out of memory" at lower context than fp16; --kv fp8 unaffected #6681

Done

Description

@Lomare

Summary

On the linux-x86_64-hip-rx7900 build (strata-inkling 0.1.65, BUILD.json source: f-0219-rc c6f6427d9de9, gfx1100 / RX 7900 XTX 24 GiB), the integer quantized KV modes (--kv k8v4, --kv k8v8) allocate more VRAM than --kv fp16, OOMing at lower total context than fp16 does. --kv fp8 works fine at every depth tested. The failure point scales with --max-context, not with actual prompt size. The CPU backend's --kv k8v4 selfcheck passes, so the quant math is correct — this looks like the hip page/scale allocator.

Repro (all runs single-console --bench, parallel=1, --vram-reserve-mib 512, pack Inkling-2-Mini-SQ-20.strata)

--kv prompt --max-context result
fp16 1k 64k OK — decode 63.5 t/s
k8v4 1k 64k OK — decode 86.5 t/s
k8v4 32768 65536 OK — decode 33.7 t/s
k8v4 49152 65536 OK — decode 27.9 t/s
k8v4 65536 131072 FATAL [ink-hip] kv grow v: out of memory (during decode growth)
k8v8 65536 131072 FATAL [ink-hip] kv grow v: out of memory
fp8 65536 131072 OK — decode 24.0 t/s
k8v4 131072 163840 FATAL [ink-hip] kv grow v: out of memory (during prefill)
fp16 (serve, --parallel 8) grew to ~78,592 prompt tokens 262144 OOM (kv grow v) only at ~79k with 8 slots; single-slot fp16 comfortably exceeds any k8v4-working depth

Engine restarts after the fatal error; every subsequent request in that slot re-OOMs identically (deterministic).

Why this is anomalous

Per the shipped sizing tables (vram_fit.py: KV_BYTES = {"fp16": 2112, "int8": 1056, "q4_0": 576, "k8v4": 816} per token per attention layer — Qwen family), k8v4 should be ~2.6x smaller than fp16, yet it OOMs at strictly lower context. fp8 (per-element format, no block scale buffers) is unaffected, which points at the scale-buffer growth path: the binary's grow error strings come as a set kv grow k / ks / v / vs (K, K-scales, V, V-scales), with GGML-style block-64 quant (quantize_q8_1_g64) and paged pools (SlotKvPages::init(..., KvDtype), VisitKvPool::ensure_page, k3_kv_paged_store<>). Failure scaling with --max-context at fixed prompt size suggests the quant path sizes something from max-context (pre-allocation or stride mistake — e.g. per-token instead of per-block scale stride would be 8x bloat on the ks/vs buffers).

Control

strata-inkling --selfcheck --native SQ-20 --cpu --kv k8v4 → PASS backend=cpu (CPU (avx2, 1 threads)) — the K8V4/K8V8 round-trip assertions pass, so this is backend-specific allocation, not quant logic.

Environment

  • strata-inkling 0.1.65, package strata-inkling-0.1.65-linux-x86_64-hip-rx7900.tar.gz (bundled HIP 7 runtime), strata-control 0.2.19 bundle
  • RX 7900 XTX (gfx1100), 24 GiB; host RAM 64 GiB; Linux (kernel 7.2.8-omarchy at filing; repro identical after update to 7.2.15-omarchy), pack SQ-20 (bit-exact)
  • Also observed (separate, likely dup of [Engine] sm_75 inkling path: --kv k8v8/k8v4 segfault, CUDA 700 when prompt+gen fills --max-context, DSpark OOM at 131K #6590): --draft dspark at serve ctx 163840 dies at ~141k depth with [ink-hip] ds frnn grow: out of memory, and produced zero decode gain on all probes (with draft on/off at matched prompts: 40.9 vs 41.2 t/s @39k) — the accept rate appears to be ~0 on this backend.

Related / dedup

Impact / workaround today

Quantized KV on hip is strictly counterproductive: it costs memory (vs fp16) and decode speed (dequant cost beats the bandwidth win at depth). --kv fp8 is a zero-accuracy-cost workaround on Inkling (fidelity 1.00/0.958 agreement on a 24-probe suite, fp16 vs fp8 indistinguishable) — but fp8 isn't documented anywhere as the supported mode; a per-backend --kv support matrix in the docs would save users this investigation.

Activity

  1. Lomare commented on Nov 22, 2026

    @Lomare
    Author

    Follow-up: source read + controlled retest — correcting one claim in the original report

    Correction first: the original table compared fp16 under --serve --parallel 8 --max-context 262144 against k8v4 under --bench at --max-context 131072. That comparison was confounded. A controlled same-shape retest (console --bench, parallel=1, --vram-reserve-mib 512, RX 7900 XTX, SQ-20):

    prompt / max-context --kv peak VRAM (per-run sampled) result
    49152 / 65536 fp16 23 GB OK — decode 25.9 t/s
    49152 / 65536 k8v4 23 GB OK — decode 27.1 t/s
    65536 / 131072 fp16 OOM bench decode err: [ink-hip] kv grow v: out of memory
    65536 / 131072 k8v4 OOM same error (original report)
    65536 / 131072 fp8 OK decode 24.0 t/s (original report)

    So the accurate claim is not "k8v4/k8v8 allocate more than fp16" — it is: k8v4/k8v8 allocate byte-identical to fp16; the quantized storage is silently never applied. fp8 is the only --kv mode that actually reduces memory on this engine.

    The source confirms it

    Since the engine source is public, the mechanism is visible in engine/src/inkling2/hip/ink_hip_backend.hip.cpp:

    1. VisitKvPool has exactly two storage shapes:

      const size_t elem_b = is_fp8 ? 1u : 2u;
      const size_t page_b = static_cast<size_t>(kKvPageTokens) * kv_dim * elem_b;

      K8V4/K8V8 fall into the 2u branch — full fp16-sized pages. The scale buffers are gated the same way (if (is_fp8) { ...alloc... "kv grow ks" ... }), so they exist for fp8 only — which also matches our original observation order (kv grow v fails before any scale allocation is even attempted).

    2. The pool never sees the requested integer format at all:

      const bool is_fp8 = (default_kv_dtype_ == KvDtype::FP8_E4M3);

      — any other KvDtype enum collapses to is_fp8=false.

    3. alloc_slot() receives the per-session dtype and ignores it — the parameter is literally commented out:

      bool alloc_slot(int slot, int max_ctx, KvDtype /*kv_dtype*/, std::string& err) override {
    4. The CUDA-side inkling engine (engine/src/inkling2/cuda/) appears to have no KV-dtype handling at all — consistent with [Engine] strata-inkling: --kv k8v8 and --kv k8v4 SIGSEGV immediately after load on Linux RTX 3090 (sm_86) #6645 (k8v4/k8v8 SIGSEGV on CUDA immediately after load).

    Taken with #6673 (k8v4 quality collapse on SYCL), it looks like --kv k8v4|k8v8 are accepted by the inkling CLI as inherited Qwen-family flags but were never implemented for this engine on any backend: hip allocates fp16-sized pages and pays the quantize/dequantize kernel cost for zero memory savings, CUDA crashes, SYCL degrades.

    Suggested fix shape

    • At session init, reject or warn on unimplemented --kv modes per backend (silently paying quant overhead with fp16-class memory is the worst outcome — users would assume the memory win is real).
    • Document the actual support matrix (on inkling-hip, fp8 is the only reduced-memory mode — it shows no measurable accuracy cost vs fp16 in our testing, so it's a genuinely good default to document).
    • If implementing k8v4 for inkling-hip is on the roadmap, the two-branch elem_b in VisitKvPool plus the ignored alloc_slot dtype parameter are the touch points.

    (For context: a real deployment here has mitigated by pinning --kv fp8 --parallel 1, which lifts usable depth from ~65k to 141k+ on this card; k8v4-style depth (~200k+) remains out of reach until the modes are actually implemented.)

    Thanks — and apologies for the confounded first table; the corrected claim above should be the one that survives in this thread.

  2. Lomare commented on Nov 22, 2026

    @Lomare
    Author

    Small correction: the "Linux (kernel 6.x)" line in the Environment section was wrong — the box was on 7.2.8-9-omarchy at filing time. We've since updated to 7.2.15-1-omarchy and re-run the repro: identical results (k8v4 OOM at the same point, fp8 unaffected), consistent with the allocation logic being userspace.

  3. Lomare commented on Nov 22, 2026

    @Lomare
    Author

    One correction to my earlier comment here: I wrote that the CUDA-side inkling engine "appears to have no KV-dtype handling at all" — that was wrong. ink_runner.cuh has a full InkKvDtype path (per-format allocation via kv_bytes_per_visit_pos, half-width V for K8V4). So #6645 is a crash inside a real CUDA implementation, not an unimplemented mode. The claim that survives (and the one this issue is about): hip/metal/sycl accept the flag while their pools ignore the dtype and allocate fp16-sized pages.

    I've opened #6692 implementing the reject-at-init fix shape (hip/metal/sycl guards + --kv parse no longer silently treating typos as auto); CUDA is deliberately left unguarded there since its path deserves a real fix.

  4. Lomare commented on Nov 23, 2026

    @Lomare
    Author

    Update from our side: the fix has landed on main via 759ccf6 ("harden hy4 vcache headroom, inkling2 Metal/HIP/SYCL/CUDA guards, GGUF layout, and CMake checks") — we verified the HIP/Metal/SYCL --kv k8v4/k8v8 rejection (with the "allocates fp16-sized pages" explanation), the unknown --kv value hard-error, and the kv_dtype_guard_test CMake wiring are all present. Our PR #6692 (same fix, raced by 759ccf6) is closed as superseded.

    One note: the 0.2.20 / engines 0.1.66 release commit (2e87c08) predates 759ccf6 by ~5 hours, so the fix is on main but not yet in a released engine build. We're on the hip-rx7900 0.1.65 engine where the bug reproduces — happy to re-run the repro (--kv k8v4/--kv k8v8 under --serve --parallel 8 on the 7900) against the next released engine and confirm here so this can be closed. Just ping us, or we'll check on the next engine release ourselves.

  5. Lomare commented on Nov 24, 2026

    @Lomare
    Author

    Re-ran the repro against engine 0.1.67 (v0.2.21, hip-rx7900 line, rebuilt from source with the release build flags; RX 7900 XTX / gfx1100, --serve --parallel 8 --max-context 262144). The over-allocation signature no longer reproduces on the main HIP engine:

    • --kv k8v8 → hard reject at init (exit 2, ~66 ms, no GPU work): --kv must be fp16, int8, q4_0 or k8v4
    • unknown value (--kv k9v9) → same hard parse error — no silent auto fallback
    • --kv k8v4 → accepted and served (READY 262144) with correctly-sized pools: expert cache 9,165 slots / 14.85 GiB vs q4_0's 8,917 / 14.44 GiB — not the ~2–4× fp16-sized allocation reported for 0.1.65

    One caveat so this isn't over-claimed: our binary doesn't compile the inkling2 backends, so we can't runtime-verify the new inkling2 hip/metal/sycl guard from this build (759ccf6 is in-tree at HEAD). From our side the reported defect (silent accept + fp16-sized pages) is confirmed gone on the main engine at the 0.1.67 level; a maintainer — or anyone with a released strata-inkling 0.1.67 on the same card — can confirm the init-time rejection there, after which this looks closable.

  6. Lomare commented on Nov 26, 2026

    @Lomare
    Author

    Final verification from the 7900 XTX box, closing from our side.

    Build: strata 0.1.67, built from source on this machine (v0.2.21 + a local watchdog-recovery patch; HEAD d46f5f26, git merge-base --is-ancestor confirms 759ccf6 is in-tree). RX 7900 XTX / gfx1100, hip backend.

    Runtime (main engine) — confirmed:

    • --kv k8v8 → strata generate: --kv must be fp16, int8, q4_0 or k8v4, exit 2, with no model load and no GPU work (it exits right after the host memory-guard line).
    • Unknown value --kv k9v9 → same hard parse error, exit 2 — no silent auto fallback.

    inkling2 HIP guard — source + unit, with an honest caveat: the SQ-20 test pack is no longer on this machine (deleted after our 11-22 benchmarking), so we cannot runtime-verify the session-init rejection against a real inkling model. What we could verify:

    • The guard is in-tree at engine/src/inkling2/hip/ink_hip_backend.hip.cpp:580: if (kv_dtype_is_int_quant(opts.kv_dtype)) { err = "[ink-hip] --kv k8v4/k8v8 is not supported on the HIP backend (allocates fp16-sized pages); use --kv fp8 or fp16"; ... }
    • kv_dtype_guard_test compiled standalone from this tree on this machine and passes: kv_dtype_guard_test: OK (exit 0).

    Net: the reported defect (silent accept + fp16-sized pages on hip) is runtime-verified gone on the main engine at the 0.1.67 level, and the inkling2 hip guard is present and unit-green at HEAD. Closing as fixed; anyone running a real inkling model on a 0.1.67 build should see the init-time [ink-hip] --kv k8v4/k8v8 is not supported on the HIP backend rejection — if that string ever doesn't fire, please reopen.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions