Ask
287
@teardown_tues ·

32b q4_k_m drops to 3 tok/s at 16k context on a 24gb 3090 vram-fit

At 4k context I get 28 tok/s and everything is on the card. At 16k the same model gives me 3.1 tok/s. No error, no warning, it just gets slow.

nvidia-smi shows 23.9GB used, and the server log says it offloaded 51 of 65 layers to the GPU instead of all of them. So I understand roughly what is happening - I do not understand why the context length is what pushed it over, since I thought the weights were the big allocation.

What is the actual fix short of buying a second card?

8 answers Share
Report

Answering anonymously — a moderator will review it first.

  • @shoe_resole · 2d ago · 3 replies

    The KV cache is what pushed you over. For a 32B with GQA it is roughly 0.25 MB per token at fp16, so 4k context is about 1 GB and 16k is about 4 GB. Your weights are 19.9 GB and never move; the cache is the variable, and 19.9 + 4 + about 1 GB of compute buffers does not fit in 24.

    Cheapest fix, in order:

    1. Quantise the KV cache. Q8 halves it with essentially no quality change on a 16k window. In llama.cpp that is -fa -ctk q8_0 -ctv q8_0; if you are on Ollama set OLLAMA_FLASH_ATTENTION=1 and OLLAMA_KV_CACHE_TYPE=q8_0 on the server, not per request.
    2. Get the display off the card. A desktop session holds 0.5-1 GB, which at this margin is decisive.
    3. Ask whether you need 16k. Most people asking for it are stuffing a whole document in when 6k of retrieved chunks would answer better.

    The throughput cliff is not gradual - one layer on the CPU costs you more than you expect, because every token crosses PCIe.

    48
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @teardown_tues · 2d ago

      q8 KV cache plus killing the desktop session got me to 24 tok/s at 16k with everything on the card. That is a 7x from two environment variables.

      14
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
    • @soy_pour_sasha · 3d ago

      Worth knowing where the ceiling is: q8 KV is fine, q4 KV is where people start reporting the model losing track of things early in a long context. If you ever go there, test it on your actual task rather than trusting a benchmark someone posted.

      10
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
  • @soy_pour_sasha · 3d ago

    Blunt version: a 14B at Q6 that fully fits will beat your 32B at Q4 that does not, for almost any real workload, because you are comparing 30 tok/s against 3.

    People anchor on parameter count because it is the number on the model card. The number that decides whether your tool is usable is whether every layer is on the card. Below that line nothing else matters.

    32
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @hornworm_hunt · 3d ago

    The line to watch in the logs is the layer count - offloaded 51/65 layers to GPU. If that is not 65/65 you are not measuring what you think you are measuring, and every benchmark you post is meaningless.

    I keep it in my shell prompt for the server, effectively. Saved me from a lot of confused comparisons.

    21
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
  • @layoverlurker · 4d ago · 2 replies

    Set num_gpu higher and force all 65 layers on. The runtime is being conservative with the estimate, it will fit if you tell it to.

    12
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report
    • @cloze_kai · 2d ago

      It will not - the memory is genuinely not there. Force it and you get an out-of-memory abort mid-generation instead of slow output, which is arguably worse because it takes down the whole server. The runtime's estimate is a bit pessimistic on small models but at 19.9 GB of weights plus 4 GB of cache it is just doing arithmetic.

      8
      Share
      Reply

      Answering anonymously — a moderator will review it first.

      Report
  • @bedtime_bargain · 4d ago

    If it is a headless box, check nothing else grabbed VRAM. I lost 900MB for a month to a container that had a CUDA context open and was doing nothing at all with it.

    15
    Share
    Reply

    Answering anonymously — a moderator will review it first.

    Report