Skip to content

Misc. bug: Qwen4exp, top_k_radix_cuda not compiled/used in Qwen4exp #29326

Closed

Description

@albertnsoliz

Name and Version

All versions

Operating systems

Windows

Which llama.cpp modules do you know to be affected?

llama-server

Command line

llama-server affected. Anything that compiles/builds top-k.cu.

Problem description & steps to reproduce

top-k.cu:
Line 51 replacement:
#if !defined(GGML_CUDA_USE_CUB) && defined(GGML_USE_HIP)
-->
#if defined(GGML_USE_HIP) || defined(GGML_CUDA_USE_CUB)

Line 211 replacement:
#endif // !defined(GGML_CUDA_USE_CUB) && defined(GGML_USE_HIP)
-->
#endif // defined(GGML_USE_HIP) || defined(GGML_CUDA_USE_CUB)

Line 227 insert:
#if defined(GGML_CUDA_USE_CUB)
// Serial top-k launches one pass per row and leaves the GPU idle. For big multi-row inputs (indexer top-k
// at prefill) the parallel radix kernel wins despite reading the data more times.
if (ncols > 1024 && nrows >= 16) {
top_k_radix_cuda(pool, src0_d, dst_d, ncols, nrows, k, stream);
return;
}
#endif


Enables the top-k radix to be used in CUDA builds.

Qwen4exp (Qwen38FlashNext) long term context Prompt Processing gains of +20% at all ranges. Tetsted up to 148k context, gains held throughout.

Tests pass locally, tested on Windows SM75

First Bad Commit

top-k.cu only targets rocM.

Relevant log output

Logs

Activity

  1. changed the title [-]Misc. bug: Qwen4exp PropmtProcessing +20% increase, top_k_radix_cuda not compiled/used in Qwen4exp[/-] [+]Misc. bug: Qwen4exp PromptProcessing +20% increase, top_k_radix_cuda not compiled/used in Qwen4exp[/+] on Sep 23, 2026
  2. albertnsoliz commented on Sep 23, 2026

    @albertnsoliz
    Author

    This was profiled with nsys and llama-bench -r 3 up to 60k and -r 1 up to 148k ctx, radix accounts for roughly ~6%, however benchmark gains seem to be more impactful in real usage.

    Also, no regressions in TG at 1k ctx tested, this aspect wasn't the research target. Need others to test the TG side of things to validate no regressions.

  3. albertnsoliz commented on Sep 23, 2026

    @albertnsoliz
    Author

    I've reached out to other issues/PR's that seem to adress the same file/issue. Waiting for feedback on which route is best.

  4. changed the title [-]Misc. bug: Qwen4exp PromptProcessing +20% increase, top_k_radix_cuda not compiled/used in Qwen4exp[/-] [+]Misc. bug: Qwen4exp, top_k_radix_cuda not compiled/used in Qwen4exp[/+] on Sep 24, 2026
  5. anskumar01 commented on Oct 15, 2026

    @anskumar01

    Is this still an issue?

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions