Skip to content

[Bug] sd-server keeps offloaded weights on the GPU between jobs since 1117 (#2321), and Qwen Image 2.1 edits run ~40% slower #2401

Closed

Description

@beja19

Git commit

Affected: master-1117-0d71f96 (0d71f96). Not affected: master-1028-37bc88b (37bc88b). Both are the release builds sd-master-*-bin-Linux-Ubuntu-24.04-x86_64-rocm-10.1.0.zip, run against the system's ROCm 10.2.

Operating System & Version

Ubuntu 26.04.1 LTS, kernel 7.0.0-44, amdgpu 31.70 (DKMS), ROCm 10.2.0

GGML backends

HIP

Command-line arguments used

sd-server --diffusion-model qwen-image-2.1-UC-Q8_0.gguf --vae qwen_image_2.1_vae_bf16.safetensors --llm Qwen3VL-8B-Instruct-Q8_0.gguf --llm_vision mmproj-Qwen3VL-8B-Instruct-F16.gguf --cfg-scale 1.0 --steps 6 --sampling-method euler --offload-to-cpu --eager-load --vae-tiling --listen-ip 0.0.0.0 --listen-port 7860

Steps to reproduce

  1. Start sd-server with the arguments above on a 16 GB card (RX 6800, gfx1030), nothing else on the card.
  2. Read VRAM in use (/sys/class/drm/card0/device/mem_info_vram_used): about 340 MiB.
  3. Send one POST /v1/images/generations (768 x 768, a 7-step custom sigma list, one LoRA in sd_cpp_extra_args), then three POST /v1/images/edits (768 x 768 and 512 x 1168, one reference image, same sampling).
  4. Read VRAM in use again a few seconds after the last job.

What you expected to happen

As on 1028: with --offload-to-cpu, the weights stay in system RAM and the GPU copies are released when a job ends, so the card is nearly empty between jobs and another process can use it. Edits run with the Qwen Image 2.1 prefix cache.

What actually happened

On 1117 the GPU copies stay on the card after every job until the server itself needs the space, so another process on the same card gets only what is left. Edits are also about 40% slower. Same machine, models, flags and requests; one server process at a time:

1028 1117 1117 with --max-vram 10
VRAM between jobs 580 MiB 14.1 to 14.2 GB 9.6 GB
VRAM peak during a job (sampled every 1.5 to 2 s) 12.5 GB 15.9 GB 14.7 GB
Generate, 768 x 768, 7 steps (sampling) 18.2 s 16.1 s 16.1 s
Edit, 768 x 768, 7 steps (sampling) 18.9 s 31.3 to 31.4 s 31.9 to 32.9 s
Edit, 512 x 1168, 7 steps (sampling) 19.6 s 32.5 s
System RAM held by the server 19.9 GB 19.8 to 20.5 GB 19.9 GB

--model-args qwen_image_2_1_prefix_cache=true on 1117 changed nothing (edit sampling 31.4 s). The edit rate on 1117 (4.5 s a step) matches what 1028 does with the prefix cache off, which fits the documented behaviour that the cache is released and the run repeated without it when cached execution runs out of memory, with the card already full of retained weight copies. That part is my reading of the numbers, not something the log shows at the default level.

Logs / error messages / stack trace

No errors. The start-up lines are the same on both builds apart from the version (found 1 ROCm devices ... VRAM: 16368 MiB, flash attention auto: ROCm0 -> on).

Additional context / environment details

  • Ryzen 5 5600X, 32 GB DDR4, RX 6800 16 GB (gfx1030) on PCIe Gen 3 x16, headless.
  • Models: Qwen Image 2.1 Q8_0 GGUF, Qwen3-VL-8B-Instruct Q8_0 with its F16 mmproj, Qwen Image 2.1 VAE (bf16), Viggle's Qwen-Image-2.1 turbo LoRA per request.
  • The change lines up with refactor: unify runner execution and weight residency #2321 (unify runner execution and weight residency, merged 2026-11-10). docs/guides/backend.md on 1117 describes it: offloaded weights get GPU replicas that "remain resident for reuse" and are evicted only when the next weight or compute allocation needs space. MiniMax-H3 on 16 GB cards: layer-split OOM from never-released weight staging, CUDA chunk-budget no-op, f32 activation floor #2371 reports the same pressure-only eviction from the multi-GPU side.
  • --max-vram lowers the idle figure but is a soft budget (the card still reached 14.7 GB during a job), and only the server's own allocations trigger eviction, so a second process (here, an LLM server meant to share the card) cannot get the memory back.
  • Request: an option to release offloaded weights' GPU copies, and per-run caches, when a job ends (the 1028 behaviour), or to make that the default for --offload-to-cpu in sd-server, where the process sits idle between requests.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions