ROCm SSD streaming on a 32 GB discrete gfx1201: device-resident non-routed weights cap the expert cache, long prompts thrash

Aperta
#1,364 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
8/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

The relevant code is the ROCm streaming path: cuda_model_range_ptr_from_fd() and the expert/span cache budgeting, reached through the --ssd-streaming and --ssd-streaming-cache-experts flags. Read the log lines about the q8 fp16 cache budget and the stream_span allocation, and the DS4_ROCM_STREAM_READ_PROFILE output. Done would mean a design decision on whether non-routed weights can live in host memory on discrete GPUs, plus a measured prefill and decode improvement on a 32 GB card.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Setup
  • GPU: AMD Radeon AI PRO R9700 (gfx1201, discrete, 32 GB VRAM), ROCm 7.2.2, Linux 7.0
  • Host: 32 cores, 121 GiB RAM. The GGUF is on NVMe behind dm-crypt + LVM (max_sectors_kb 128 on every layer); dd bs=16M reads the GGUF at 1.3 GB/s
  • Model: DeepSeek V4 Flash Q2 (ds4f-q2, 80.8 GiB)
  • ds4 at b3f5018 plus a local build patch for gfx1201 (DS4_ROCM_NO_WMMA, same idea as #558 / #599 / #744), built with make strix-halo ROCM_ARCH=gfx1201 ROCM_EXTRA_CFLAGS=-DDS4_ROCM_NO_WMMA
  • Server: ds4-server --rocm --ctx 100000 --ssd-streaming --ssd-streaming-cache-experts <N> --kv-disk-dir <dir> --kv-disk-space-mb 16384, with DS4_ROCM_STREAM_FREE_RESERVE_GB=2
Baseline: June build

80ebbc3 (2026-06-17) with the same gfx1201 patch and --ssd-streaming-cache-experts 22GB: about 2.4 tok/s decode (median of our runs), and a 6.2K-token prompt answered in about 87 s end to end (median).

b3f5018 on the same machine
--ssd-streaming-cache-experts Short prompt (13 tokens) ~4K-token prompt
22GB first request fails (log below) —
16GB 3.6 tok/s decode 3,854 tokens: prefill not finished after 16 min
10GB 1.3 tok/s decode prefill 17.5 tok/s (1,806 new tokens; the first 2,048 came from the KV disk cache), decode 1.0 tok/s
16GB + DS4_ROCM_STREAM_NO_DIRECT=1 2.1 tok/s decode 4,215 tokens: prefill 202 s, decode 1.3 tok/s

So short prompts are faster than the June build at 16GB, but prompts of a few thousand tokens become unusable, and smaller caches slow decode to about 1 tok/s.

22GB, first request:

ds4: ROCm model arena alloc failed for stream_span (144.79 MiB request): out of memory
ds4: ROCm streaming model cache allocation failed for stream_span range 144.79 MiB; refusing host-pointer fallback
ds4: ROCm streaming model range stream_span at offset 74.94 GiB is not device-cached; refusing host-pointer fallback
... finish=error error="rocm decode failed"

16GB, during the 3,854-token prompt (repeated many times):

ds4: ROCm q8 fp16 cache budget exhausted; using q8 kernels (request=16.00 MiB cached=0.00 GiB limit=3.98 GiB free=1.86 GiB reserve=2.00 GiB total=31.86 GiB)
ds4: ROCm releasing 0.06 GiB q8 fp16 cache for streaming model spans (request=1.86 GiB free=3.48 GiB reserve=2.00 GiB)
ds4: ROCm loading model tensors 0.06 GiB cached

The "loading model tensors" progress went from 0 to 8.69 GiB several times within that one prompt, and the process read 295 GiB from storage (read_bytes in /proc/<pid>/io).

Read profile (DS4_ROCM_STREAM_READ_PROFILE=1):

16GB: jobs=57180 bytes=125.64 GiB read=1596611.897 ms upload=8973.606 ms wait=64320.049 ms avg_job=28.079 ms avg_wait=10.430 ms
10GB: jobs=89643 bytes=196.97 GiB read=1846913.778 ms upload=14895.318 ms wait=199385.918 ms avg_job=20.769 ms avg_wait=20.670 ms

About 2.25 MiB per job at 20–28 ms each, roughly 0.5 GB/s overall, on a disk that streams the same file at 1.3 GB/s.

What I think is happening

Since the September builds the non-routed weights (8.2 GiB for this GGUF: attention 5.37, shared experts 1.07, token_embd 0.99, output 0.52, other 0.25) must be device-resident: cuda_model_range_ptr_from_fd() refuses the host-pointer fallback. They sit on top of the expert cache, so on 32 GB the cache tops out near 16 GB. During a long prefill the q8→fp16 cache, the prefill expert reserve and the spans compete for the last GiBs; spans get evicted and reloaded from disk at the ~0.5 GB/s above. The June build kept those weights in host memory and ran with 22 GB of experts.

Page cache experiment (no gain)

Local patch: no O_DIRECT fd and no POSIX_FADV_DONTNEED, so spans and experts go through the page cache, pre-warmed with dd. Not better: a 4,094-token prompt took 98 s of prefill, the next 4,215-token one 165 s, then decode stalled; 358 GiB were still read from disk, and afterwards only 34.5 GiB of the GGUF was resident. Prefill scans ~72 GiB of experts per prompt and the page cache left by other processes is smaller than the 80.8 GiB model, so LRU evicts each page before it is reused. This matches the reasoning in #629.

Questions
  1. Would an opt-in to keep the non-routed weights in host memory on discrete GPUs (what the June build did) be acceptable for ROCm?
  2. During prefill, could eviction prefer the q8→fp16 cache or experts over non-routed spans?
  3. Is a routing-aware host-RAM tier for experts like #629 planned for ROCm as well? With 121 GiB of RAM it would cover most of this model.
  4. Are DS4_ROCM_STREAM_MODEL_CACHE_GB or DS4_ROCM_STREAM_Q8_F16_CACHE_GB worth trying here? I have not tuned them.

Happy to run more measurements or test a branch. Related: #16, #629, #858.

Lingua principale
C
Stelle
24.4k
Fork
2.4k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di antirez/ds4

Tutte le issue di antirez/ds4

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.