Skip to content

CUDA illegal memory access with Qwen3-Next on multi-GPU using -ot (regression) #19816

Description

@nerdpudding

Name and Version

Last known working: b48e80f67 (b8022, 2026-02-13)
First observed broken: ed4837891 (b8022+93 commits, 2026-02-22, head of master at time of fetch)

Operating systems

Linux (Ubuntu 24.04)

GGML backends

CUDA

Hardware

  • GPU 0: NVIDIA RTX 4090 (24 GB VRAM) — sm_89
  • GPU 1: NVIDIA RTX 5070 Ti (16 GB VRAM) — sm_120
  • CPU: AMD Ryzen 7 5800X3D
  • RAM: 64 GB DDR4
  • Driver: 580.x (open kernel)
  • CUDA: 13.0

Models

  • Qwen3-Next-80B-A3B-Instruct UD-Q5_K_XL (from unsloth)
  • Qwen3-Coder-Next UD-Q5_K_XL (from unsloth)

Both models exhibit the same behavior.

Problem description & steps to reproduce

When using -ot (per-layer tensor overrides) to split layers across two GPUs with expert offload to CPU, the server crashes with CUDA error: an illegal memory access was encountered on the first generated token after prompt processing.

Key observations:

  • Prompt processing completes successfully (confirmed in logs)
  • Sampler initialization completes successfully
  • Crash occurs at the start of token generation (first decode step)
  • Short prompts (~20 tokens) work fine
  • Longer prompts (~100+ tokens) consistently crash
  • The same configuration and same models work without issues on commit b48e80f67

Server command (via docker-compose, effective flags):

llama-server \
  --model Qwen3-Next-80B-A3B-Instruct-UD-Q5_K_XL-00001-of-00002.gguf \
  --ctx-size 10240 \
  --n-gpu-layers 99 \
  --flash-attn on \
  --cache-type-k q8_0 \
  --cache-type-v q8_0 \
  --jinja -np 1 -b 512 -ub 512 \
  --no-context-shift \
  -ot blk\.([0-9]|1[0-8])\.=CUDA0,blk\.(1[9]|2[0-7])\.=CUDA1,exps=CPU

Steps to reproduce:

  1. Load either Qwen3-Next or Qwen3-Coder-Next with the -ot configuration above (layers split across two GPUs, experts on CPU)
  2. Send a chat completion request with a prompt of ~100+ tokens
  3. Server crashes during first token generation

What I tested:

  • Reverted to b48e80f67 → works perfectly, no CUDA errors
  • Tried different -ot layer splits (both production and bench profiles) → same crash on new code
  • Tested both Qwen3-Next and Qwen3-Coder-Next → both crash identically
  • Short prompts (~20 tokens) succeed even on the broken build

Possibly related

This resembles #18580, which reported the same error (CUDA illegal memory access with Qwen3-Next on multi-GPU) and was fixed by #18593 (merged in b7625). The fix is included in our last working commit, so this appears to be a new regression of a similar issue rather than the original bug.

First Bad Commit

Not bisected. There are 93 commits between the last known good (b48e80f67) and the broken head. I have not narrowed it down further.

Relevant log output

Logs

Server startup (loads fine):

load_tensors: offloading 49/49 layers to GPU
load_tensors:   CPU_Mapped model buffer size = 47115.28 MiB
load_tensors:   CPU_Mapped model buffer size =  6669.17 MiB
load_tensors:        CUDA0 model buffer size = 21203.75 MiB
load_tensors:        CUDA1 model buffer size = 10666.26 MiB

Crash (repeats on every request with 100+ token prompts):

slot update_slots: id  0 | task 0 | prompt processing progress, n_tokens = 162, batch.n_tokens = 162, progress = 1.000000
slot update_slots: id  0 | task 0 | prompt done, n_tokens = 162, batch.n_tokens = 162
slot init_sampler: id  0 | task 0 | init sampler, took 0.02 ms, tokens: text = 162, total = 162
/build/ggml/src/ggml-cuda/ggml-cuda.cu:97: CUDA error
CUDA error: an illegal memory access was encountered

The server restarts (docker restart: unless-stopped), reloads the model, and crashes again on the next request. Observed 22 CUDA errors and 11 model reloads before stopping the container.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions