Repository navigation
[Engine] inkling: reject --kv k8v4/k8v8 on the hip/metal/sycl pools (fp16-sized regardless; #6681); --kv typo no longer silently auto - #6692
Conversation
…) instead of silently allocating fp16-sized KV (Niko1221#6681) The integer quantized KV formats are implemented on the CPU (pool init takes the dtype, selfcheck verifies the round-trip, Niko1221#6520) and on CUDA (its own InkKvDtype path). hip/metal/sycl ignore the dtype in alloc_slot and allocate fp16-sized pages, so --kv k8v4/k8v8 there pays quantize overhead for fp16 memory and the user believes the depth win is real. Reject at init with the working alternatives. Also: --kv stopped silently treating unknown strings as 'auto' (a typo'd mode became auto-select with no message). Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for the pull request. To keep the tracker readable, every item needs an area prefix in the title and the parts of the pull request template filled in. This one is missing:
Edit the pull request (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment Details: CONTRIBUTING.md |
|
Thanks, this follows the format now. |
|
Closing as superseded — commit 759ccf6 ("harden hy4 vcache headroom, inkling2 Metal/HIP/SYCL/CUDA guards, GGUF layout, and CMake checks") independently landed the same fix on
Nothing left in this PR that |
Problem and result
Triggered by #6681: on the HIP backend
--kv k8v4/--kv k8v8are silently accepted whileVisitKvPoolallocates fp16-sized pages regardless of dtype (elem_b = is_fp8 ? 1 : 2, the scale buffers live underif (is_fp8), andalloc_slot's dtype parameter is commented out). Metal and SYCL have the identical pattern (dtype stored forstats()only, ignored inalloc_slot). Measured on an RX 7900 XTX at matched shapes (full table in #6681's correction comment):fp16andk8v4peak at byte-identical VRAM and OOM at the same context, whilefp8serves past 140k on the same card.Before: a request for
--kv k8v4|k8v8on hip/metal/sycl pays the quantize/dequantize cost for fp16-class memory; the only evidence is a confusing OOM tens of thousands of tokens later. After: init rejects the two formats with a message naming the working alternatives (fp8,fp16). Also: an unknown--kvvalue (e.g.--kv k4v4) used to silently meanautowith no message; it is now a fatalunknown --kv value '...'exit(2), andautobecomes an explicitly accepted value.Related discussion
#6681 — issue opened by us, root cause cited by line; the reject-at-init fix shape was proposed in its correction comment. No separate maintainer agreement on scope (bug fix, not a feature/default change). CUDA deliberately untouched: see Approach.
Approach
The real support matrix, read from the source:
InkKvDtypepath with per-format allocation (kv_bytes_per_visit_pos, half-width V for K8V4). #6645's SIGSEGV is a crash inside a real implementation; guarding it would mask the fix, so no CUDA change hereink_batch.h:kv_dtype_is_int_quant()next to the enum, support-matrix rationale in the comment.init()prologues (hip: right after the device check, before any VRAM is spent), reusing the existinginit(...) -> string& errabort path the CLI already prints and exits on.ink_runner.cuhhas the full path; the claim that survives (and this PR fixes) is hip/metal/sycl silently allocating fp16-sized KV.Compatibility: the only behavior change is that the unimplemented modes now fail instead of lying about memory. Auto-select is unaffected (it never picks an integer dtype).
Validation
Passed:
g++ -std=c++20 -Wall -Wextra -I engine/src/inkling2 engine/tests/core/kv_dtype_guard_test.cpp && ./kv_dtype_guard_teston branch45e2f34(basea34979f, g++/Linux, no GPU) → printsok, exit 0. The test covers the guard's truth table (fp16/fp8 false, k8v8/k8v4 true) and the dtype-name strings the reject message prints.Failed:
Not run:
init()prologue referencing only symbols already visible in that TU (KvDtypeis referenced by all three files today).--bench/--serveruns of a patched binary, same reason. The reject rides the identical error path as the existing"[ink-hip] no HIP devices visible"abort, which the CLI already prints and exits non-zero on.Limits
--kv k8v4advertises remains CPU/CUDA-only (hip users getfp8, which measured no accuracy cost vs fp16). Fully closing [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 means a real integer path on hip — the touch points areVisitKvPool'selem_bbranch and the ignoredalloc_slotdtype parameter.kv_dtype_name'sdefault:arm still maps unknown enum values to"fp16"; left alone as unrelated cleanup.