Skip to content

Qwen4 next flash multi gpu & buffer size issues solved - #28623

Draft
gopinath87607 wants to merge 2 commits into
ggml-org:masterfrom
gopinath87607:qwen4exp-qsa-chunked
Draft

Qwen4 next flash multi gpu & buffer size issues solved#28623
gopinath87607 wants to merge 2 commits into
ggml-org:masterfrom
gopinath87607:qwen4exp-qsa-chunked

Conversation

@gopinath87607

@gopinath87607 gopinath87607 commented Sep 9, 2026

Copy link
Copy Markdown

Overview

this pr is not complete one just sharing what i find you can close it it any time

Additional information

here how you can run

export LLAMA_QSA_TOPK=9000
echo 0 | sudo tee /proc/sys/kernel/numa_balancing
CUDA_VISIBLE_DEVICES=2,3,0,1
numactl --interleave=all
~/llama.cpp/build/bin/llama-server
--model /mnt/nvme/Qwen3.8-Flash-Next-Q8_0-00001-of-00006.gguf
--chat-template-kwargs '{"reasoning_effort":"xhigh"}'
--tensor-split 3,4,1,1
--mlock
--lazy-mode off
-cmoe
--numa distribute
-c 260000
--batch-size 9000
--ubatch-size 9000
--top-p 0.95
--top-k 20
--min-p 0.0
--presence-penalty 0.0
--repeat-penalty 1.0
--parallel 1
--threads 42
--threads-batch 42
-ngl 100
--host 127.0.0.1
--port 8082
--jinja

Requirements

gopinath87607 and others added 2 commits September 8, 2026 12:47
score and mask each query chunk against the compacted cache instead of
materializing [n_kv, n_tokens] tensors, and hoist the per-chunk mask
buffer so the scratch no longer grows with the chunk count. enable the
CUDA top_k radix select for any row width and route flash attention to
the mask-compacting sparse path for the QSA head shapes. rebuild the
causal mask on device from cell positions, with future and foreign
cells saturating to -inf.

Assisted-by: Claude Code
Checkpoint of the working tree on qwen4exp-qsa-chunked. Root cause of the
QSA output corruption: prefill ubatch self-attends up to `ub` in-batch
cells, so corruption occurs iff ub > width (top_k + r - 1). Keep
LLAMA_QSA_TOPK >= ub to avoid it. Fix is env-gated and behavior-identical
to stock when unset.

Also carries the chunked-QSA prefill with bounded scratch from HEAD plus
remaining experimental/bisect toggles (QSA_OFF, NOIDXW, fresh-mask,
fattn/cu/test-backend-ops hacks) marked "revert me". Cleanup of those is a
follow-up before any upstream PR.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@gopinath87607
gopinath87607 requested review from a team, CISC and ggerganov as code owners September 9, 2026 02:40
@github-actions github-actions Bot added model Model specific testing Everything test related ggml changes relating to the ggml tensor library for machine learning CUDA Related to the CUDA backend labels Sep 9, 2026
@ggml-gh-bot

ggml-gh-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

Hi @gopinath87607, thanks for your contribution!

Per our contribution guidelines, the automated PR checker found the following issue(s) that need your attention:

  • PR Template not respected: Please respect the template when creating a new pull request. Make sure to fill out all required sections.

Please note that maintainers reserve the right to make final decisions on PRs. If you believe there is a mistake, please comment below.

@ggml-gh-bot ggml-gh-bot Bot added the draft PR will be changed to draft by github-actions bot label Sep 9, 2026
@github-actions
github-actions Bot marked this pull request as draft September 9, 2026 02:45
@github-actions github-actions Bot removed the draft PR will be changed to draft by github-actions bot label Sep 9, 2026
@gopinath87607 gopinath87607 changed the title Qwen4exp qsa chunked Qwen4exp qsa chunked moe + multi gpu solve experimental Sep 9, 2026
@gopinath87607 gopinath87607 changed the title Qwen4exp qsa chunked moe + multi gpu solve experimental Qwen4exp qsa chunked moe + multi gpu solve experimental & buffer size issues solved Sep 9, 2026
@gopinath87607 gopinath87607 changed the title Qwen4exp qsa chunked moe + multi gpu solve experimental & buffer size issues solved Qwen4 next flash multi gpu & buffer size issues solved Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CUDA Related to the CUDA backend ggml changes relating to the ggml tensor library for machine learning model Model specific testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant