Skip to content

[Bug] VRAM spill with automatically set context size #6682

Closed

Description

@ShenLishuang

One example:
Thu Jun 25 09:31:42 AM PDT 2026
Using 29% GPU, 300% CPU, 4100 MiB
context: -c 112128

/home/my/.unsloth/llama.cpp/llama-server -m /home/my/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/Qwen3.6-27B-UD-Q4_K_XL.gguf --port 53669 -c 112128 --parallel 1 --flash-attn on --no-context-shift -ngl -1 --metrics --jinja --cache-type-k q8_0 --cache-type-v q8_0 --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-kwargs {"enable_thinking": true, "preserve_thinking": false} --mmproj /home/my/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/mmproj-F16.gguf

top
top - 09:30:30 up 16:41, 3 users, load average: 2.78, 2.20, 1.06
Tasks: 506 total, 2 running, 504 sleeping, 0 stopped, 0 zombie
%Cpu(s): 11.9 us, 0.0 sy, 0.0 ni, 88.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
MiB Mem : 63724.5 total, 28112.7 free, 8409.7 used, 29043.1 buff/cache
MiB Swap: 8192.0 total, 8192.0 free, 0.0 used. 55314.7 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                  

45506 shen 20 0 152.9g 4.1g 2.4g R 272.7 6.6 21:06.41 llama-server

By the way, recent updates of unsloth studio can squeeze a larger context setting automatically. But it seems that, some times it splits job out to CPU/ RAM, which leaves the GPU utility rate < 20%, and the speed is greatly reduced.
The settings should allow strictly fitting within VRAM for speed consideration.

Originally posted by @ShenLishuang in #6619

Activity

  1. Imagineer99 commented on Jun 25, 2026

    @Imagineer99
    Member

    thanks, this looks like auto context fit estimate overshooting for this GGUF model

    if possible can you share the console logs before and after for this

  2. self-assigned this
    on Jun 25, 2026
  3. ShenLishuang commented on Jun 25, 2026

    @ShenLishuang
    Author

    Background on Gemm3-E2B: Context Length =131072

    -model-draft /home/my/.cache/huggingface/hub/models--unsloth--gemma-4-E2B-it-GGUF/snapshots/ecc8b33b2c50598815e4b0f7cea6088e3ae7adb8/mtp-gemma-4-E2B-it.gguf --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-file /tmp/unsloth_chat_template_gahh4o11.jinja --chat-template-kwargs {"enable_thinking": true, "preserve_thinking": false} --mmproj /home/my/.cache/huggingface/hub/models--unsloth--gemma-4-E2B-it-GGUF/snapshots/ecc8b33b2c50598815e4b0f7cea6088e3ae7adb8/mmproj-F16.gguf"}
    {"timestamp": "2026-06-25T18:17:22.395591Z", "level": "info", "event": "llama-server stdout/stderr -> /home/my/.unsloth/studio/logs/llama-server/llama-1782411442-port-58167-try0.log"}
    {"timestamp": "2026-06-25T18:17:24.148720Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/load-progress", "status_code": 200, "process_time_ms": 5.19}
    {"timestamp": "2026-06-25T18:17:24.945250Z", "level": "info", "event": "llama-server ready on port 58167 for model 'unsloth/gemma-4-E2B-it-GGUF'"}
    {"timestamp": "2026-06-25T18:17:24.950680Z", "level": "info", "event": "Loaded GGUF model via llama-server: unsloth/gemma-4-E2B-it-GGUF"}
    {"timestamp": "2026-06-25T18:17:24.952226Z", "level": "info", "event": "Loaded default model defaults from /home/my/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/studio/backend/assets/configs/model_defaults/default.yaml"}
    {"timestamp": "2026-06-25T18:17:24.953789Z", "level": "info", "event": "request_completed", "method": "POST", "path": "/api/inference/load", "status_code": 200, "process_time_ms": 3675.41}
    {"timestamp": "2026-06-25T18:17:24.986740Z", "level": "info", "event": "Loaded default model defaults from /home/my/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/studio/backend/assets/configs/model_defaults/default.yaml"}
    {"timestamp": "2026-06-25T18:17:24.988278Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/status", "status_code": 200, "process_time_ms": 3.79}
    {"timestamp": "2026-06-25T18:17:24.990150Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/models/list", "status_code": 200, "process_time_ms": 1.8}
    {"timestamp": "2026-06-25T18:17:25.000643Z", "level": "info", "event": "Found 3 trained models in /home/my/.unsloth/studio/outputs"}
    {"timestamp": "2026-06-25T18:17:25.000712Z", "level": "info", "event": "Detected base model from adapter_config.json: Qwen/Qwen3.5-4B"}
    {"timestamp": "2026-06-25T18:17:25.000762Z", "level": "info", "event": "Detected base model from adapter_config.json: unsloth/qwen3-0.6b-unsloth-bnb-4bit"}
    {"timestamp": "2026-06-25T18:17:25.000805Z", "level": "info", "event": "Detected base model from adapter_config.json: unsloth/qwen3-0.6b-unsloth-bnb-4bit"}
    {"timestamp": "2026-06-25T18:17:25.000993Z", "level": "info", "event": "Found 2 exported models in /home/my/.unsloth/studio/exports"}
    {"timestamp": "2026-06-25T18:17:25.001155Z", "level": "info", "event"

    /home/my/.unsloth/llama.cpp/llama-server -m /home/my/.cache/huggingface/hub/models--unsloth--gemma-4-E2B-it-GGUF/snapshots/ecc8b33b2c50598815e4b0f7cea6088e3ae7adb8/gemma-4-E2B-it-UD-Q4_K_XL.gguf --port 55031 -c 131072 --parallel 1 --flash-attn on --no-context-shift -ngl -1 --metrics --jinja --cache-type-k q8_0 --cache-type-v q8_0 --model-draft /home/my/.cache/huggingface/hub/models--unsloth--gemma-4-E2B-it-GGUF/snapshots/ecc8b33b2c50598815e4b0f7cea6088e3ae7adb8/mtp-gemma-4-E2B-it.gguf --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-file /tmp/unsloth_chat_template_8ffs_nxp.jinja --chat-template-kwargs {"enable_thinking": true, "preserve_thinking": false} --mmproj /home/my/.cache/huggingface/hub/models--unsloth--gemma-4-E2B-it-GGUF/snapshots/ecc8b33b2c50598815e4b0f7cea6088e3ae7adb8/mmproj-F16.gguf

    after switching/loading Qwen3.6-27B-MTP:

    context=112128

    n/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/Qwen3.6-27B-UD-Q4_K_XL.gguf --port 52193 -c 112128 --parallel 1 --flash-attn on --no-context-shift -ngl -1 --metrics --jinja --cache-type-k q8_0 --cache-type-v q8_0 --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-kwargs {"enable_thinking": true, "preserve_thinking": false} --mmproj /home/my/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/mmproj-F16.gguf"}

    {"timestamp": "2026-06-25T18:18:17.298435Z", "level": "info", "event": "llama-server stdout/stderr -> /home/my/.unsloth/studio/logs/llama-server/llama-1782411497-port-52193-try0.log"}
    {"timestamp": "2026-06-25T18:18:17.424699Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/load-progress", "status_code": 200, "process_time_ms": 1.13}
    {"timestamp": "2026-06-25T18:18:19.441619Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/load-progress", "status_code": 200, "process_time_ms": 0.83}
    {"timestamp": "2026-06-25T18:18:21.491083Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/load-progress", "status_code": 200, "process_time_ms": 1.01}
    {"timestamp": "2026-06-25T18:18:21.903815Z", "level": "info", "event": "llama-server ready on port 52193 for model 'unsloth/Qwen3.6-27B-MTP-GGUF'"}
    {"timestamp": "2026-06-25T18:18:21.910446Z", "level": "info", "event": "Loaded GGUF model via llama-server: unsloth/Qwen3.6-27B-MTP-GGUF"}
    {"timestamp": "2026-06-25T18:18:21.912018Z", "level": "info", "event": "Loaded default model defaults from /home/my/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/studio/backend/assets/configs/model_defaults/default.yaml"}
    {"timestamp": "2026-06-25T18:18:21.913596Z", "level": "info", "event": "request_completed", "method": "POST", "path": "/api/inference/load", "status_code": 200, "process_time_ms": 5676.46}
    {"timestamp": "2026-06-25T18:18:21.942205Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/models/list", "status_code": 200, "process_time_ms": 2.19}
    {"timestamp": "2026-06-25T18:18:21.944238Z", "level": "info", "event": "Loaded default model defaults from /home/my/.unsloth/studio/unsloth_studio/lib/python3.13/site-packages/studio/backend/assets/configs/model_defaults/default.yaml"}
    {"timestamp": "2026-06-25T18:18:21.945690Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/inference/status", "status_code": 200, "process_time_ms": 3.38}
    {"timestamp": "2026-06-25T18:18:21.966512Z", "level": "info", "event": "Found 3 trained models in /home/my/.unsloth/studio/outputs"}
    {"timestamp": "2026-06-25T18:18:21.966617Z", "level": "info", "event": "Detected base model from adapter_config.json: Qwen/Qwen3.5-4B"}
    {"timestamp": "2026-06-25T18:18:21.966673Z", "level": "info", "event": "Detected base model from adapter_config.json: unsloth/qwen3-0.6b-unsloth-bnb-4bit"}
    {"timestamp": "2026-06-25T18:18:21.966718Z", "level": "info", "event": "Detected base model from adapter_config.json: unsloth/qwen3-0.6b-unsloth-bnb-4bit"}
    {"timestamp": "2026-06-25T18:18:21.966915Z", "level": "info", "event": "Found 2 exported models in /home/my/.unsloth/studio/exports"}
    {"timestamp": "2026-06-25T18:18:21.967112Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/models/loras", "status_code": 200, "process_time_ms": 1.47}
    {"timestamp": "2026-06-25T18:18:22.208597Z", "level": "info", "event": "request_completed", "method": "GET", "path": "/api/export/status", "status_code": 200, "process_time_ms": 1.64}

    llama.cpp/llama-server -m /home/my/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/Qwen3.6-27B-UD-Q4_K_XL.gguf --port 52193 -c 112128 --parallel 1 --flash-attn on --no-context-shift -ngl -1 --metrics --jinja --cache-type-k q8_0 --cache-type-v q8_0 --spec-type draft-mtp --spec-draft-n-max 2 --chat-template-kwargs {"enable_thinking": true, "preserve_thinking": false} --mmproj /home/my/.cache/huggingface/hub/models--unsloth--Qwen3.6-27B-MTP-GGUF/snapshots/5cb35eb3dcbf52dbce5f87dbc64df6aaffadcace/mmproj-F16.gguf

    nvtop:
    GPU[ 0%(eff 0%)] MEM[|||||||||||||||||||||||22.296Gi/23.890Gi]
    PID USER DEV TYPE GPU GPU MEM CPU HOST MEM Command
    51480 my 1 Compute N/A 21990MiB 90% 0% 3080MiB /home/my/.unsloth/llama.cpp/llama-server -m /home/my/.cache/huggingface/hub/
    44750 shen 1 Compute N/A 334MiB 1% 0% 1126MiB

    90% GPU VRAM, is CPM/RAM used for --mmproj ? Seems only limited to MTP?

    When a new and long chat is started, GPU utility is 90% for 20 seconds, then falls to 27%. CPU at 300% with 3880 MiB (Host MEM)

  4. ShenLishuang commented on Jun 25, 2026

    @ShenLishuang
    Author

    Another problem is that while I have 24 CPU threads, but the Qwen3.6-27B-MTP-GGUF is using only 3 CPU threads and <25% GPU, this is under-utility, leading to poor tps.

    Prompt eval
    22.15s
    Prompt speed
    869.8 tok/s
    Generation
    590.86s
    Speed
    14.3 tok/s
    Tokens
    8,464
    First token
    22.15s
    Total
    613.12s
    Chunks 7304
    So Speed = 14.3 tok/s

    For comparison, the previous version unsloth, run unsloth/Qwen3.6-27B-MTP-GGUF within VRAM, speed is 30-35 tok/s.

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

Metadata

Metadata

Assignees

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