Skip to content

K1: apr serve sizes the GPU KV from the model's context within free VRAM, not a fixed 4096 #4636

Closed as not planned

Description

@noahgift

Child of #3715 (ruling-3715 K1). Carried by PR #4630 together with D5 (#4614 / PMAT-4616).

Before: apr serve fixed the device KV at 4096 whatever the model declared, so a prompt past 4096 tokens on a longer-context model overflowed the KV and came back as a 500.

Acceptance:

  • apr serve builds the CUDA model with OwnedQuantizedModelCuda::for_serving; with no --context-length the device KV = serving_kv_len = min(model context, what free VRAM holds with SERVE_BATCH_SLOTS=2 batched slots budgeted), floored at 4096 (or the model's context when shorter).
  • An explicit --context-length (≠ default) still sizes the KV via REALIZR_CONTEXT_LENGTH.
  • The D5 refusal limit (PMAT-4616) is the serving context this KV yields: at the limit 200 whole, one past it 400, never 500. api/tests/serve_kv_limit_k1.rs checks this on the device with an 8192-context model (above the old 4096, so a return to the fixed size fails).
  • session_kv.rs unit tests: small model gets its whole context; a model that fills the card keeps the 4096 floor; partial room is used and never exceeded.

Agent: aprender-kv

Activity

  1. added a commit that references this issue on Sep 29, 2026
  2. added this to the 0.71.0 milestone on Oct 8, 2026
  3. noahgift commented on Oct 12, 2026

    @noahgift
    MemberAuthor

    Status (aprender-clerk, owner): not on main. At cc71bde, main has no for_serving, serving_kv_len, SERVE_BATCH_SLOTS, session_kv.rs or serve_kv_limit_k1.rs.

    Next: re-cut onto current main as one K1 PR, after cargo test -p aprender-serve --lib (session_kv unit tests) passes on a CPU host. The acceptance test serve_kv_limit_k1.rs needs a CUDA device with an 8192-context model, so it needs a GPU host slot. The PR opens on a release-train slot.

    🤖 Generated with Claude Code

  4. added
    P1High priority
    and removed
    P0Critical priority
    on Oct 14, 2026
  5. noahgift commented on Oct 14, 2026

    @noahgift
    MemberAuthor

    P0 to P1 (2026-10-14 P0 triage): P0 now means it blocks the next release or carries the operator's own words on it; this issue does neither, so it stays on the 0.71.0 milestone at P1.

  6. noahgift commented on Oct 14, 2026

    @noahgift
    MemberAuthor

    Folded into #3715 as a checklist row (TRIAGE-100, 2026-10-14): the open-ticket cap is 100, so this ticket is now tracked on that master and closed as not planned. Nothing is lost: reopen it when its work resumes, and an open PR for it reopens it.

    Agent: aprender-clerk

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

    P1High priorityowner:aprender-clerkowner: aprender-clerk (aprender-3e)size:MK̂ 3-4 h

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions