Skip to content

fish_drama3 on CUDA 13.x: same seed gives a different take on every request (ggml top-k uses cub::DeviceTopK before CCCL 3.4.3) #952

Closed

Description

@Tures55

Summary

With a CUDA 13.x toolkit, fish_drama3 does not reproduce a take for a fixed seed: identical requests return different VQ codes from frame 0. The cause is the vendored ggml-cuda/top-k.cu, which enables cub::DeviceTopK for CCCL >= 3.2. DeviceTopK has a race before CCCL 3.4.3 (NVIDIA/cccl#10627), and upstream llama.cpp only enables it from 3.4.3 (see ggml-org/llama.cpp#28497). Backporting that guard makes seeded takes bit-identical.

Environment

  • Windows 11, RTX 5070 Ti 16 GB (sm_120), driver 616.56
  • CUDA 13.3 toolkit, CCCL 3.3.4 (CCCL_VERSION 3003004)
  • audio.cpp d5fbed4, scripts/build_windows.ps1 -ModelSet custom -Models fish_drama3 -Target audiocpp_server -CudaArchitectures 120 -CpuArch avx2
  • Jmica/Drama-3-GGUF drama-3-backbone-8bit-experts-Q3_K_S.gguf and -Q4_K_S.gguf

Reproduction

POST /v1/tasks/run, the same body three times:

{"model": "drama3", "request": {
  "text": "<about 250 characters, two chunks>",
  "voice_ref": "<7 s WAV>", "reference_text": "<transcript>",
  "seed": 42, "temperature": 1.0, "top_p": 0.9, "top_k": 30, "max_tokens": 480}}

Session options tried: disk_experts=true, cpu_expert_layers=0; the same with pin_experts=true; and resident cpu_expert_layers=24. audiocpp_cli --seed 42 behaves the same.

Check Result
CUDA, same session, 3 requests codes differ from frame 0 (330 / 351 / 353 frames)
CUDA, fresh server process for each request codes differ from frame 0
Reference passed as prepared vq_codes (encode_reference_only returns identical codes every time) codes still differ from frame 0
GGML_CUDA_DISABLE_GRAPHS=1 codes still differ
temperature=0 frame-0 semantic token stable, residual codebooks differ
"backend": "cpu" 3 runs identical

Cause

build_moe_inputs in src/community_models/fish_drama3/backbone.cpp routes experts with ggml_top_k. On CUDA with CCCL >= 3.2, ggml_cuda_op_top_k calls DeviceTopK::MaxPairs with determinism::not_guaranteed and output_ordering::unsorted. The selected expert order, and therefore the summation order of the expert outputs and routing weights, changes between calls, so the logits differ slightly on every request. With CCCL 3.3.4 the race fixed in NVIDIA/cccl#10627 is also present.

Fix tested

Backport of the upstream llama.cpp guard in external/ggml/src/ggml-cuda/top-k.cu:

-#    if (CCCL_MAJOR_VERSION >= 3 && CCCL_MINOR_VERSION >= 2)
+// DeviceTopK has a race condition before CCCL 3.4.3 (backport of llama.cpp's guard).
+// https://github.com/NVIDIA/cccl/pull/10627
+#    if (CCCL_MAJOR_VERSION > 3 || \
+         (CCCL_MAJOR_VERSION == 3 && CCCL_MINOR_VERSION > 4) || \
+         (CCCL_MAJOR_VERSION == 3 && CCCL_MINOR_VERSION == 4 && CCCL_PATCH_VERSION >= 3))
 #        define CUB_TOP_K_AVAILABLE

With CCCL 3.3.4 this falls back to the argsort path (bitonic for 256 experts). Results after rebuilding audiocpp_server:

  • seed 42, 3 requests in one session: identical codes
  • after restarting the server: identical to the earlier takes
  • disk_experts with and without pin_experts: identical take for the same seed
  • different seeds still give different takes
  • speed (Q3_K_S, pin_experts, warm, same requests): 33.6-35.2 frames/s, against 30.6-32.1 frames/s before

The upstream guard only helps while CCCL is older than 3.4.3, since DeviceTopK keeps determinism::not_guaranteed after that. Because the MoE sums depend on the expert order, an order-independent fix in fish_drama3 (for example sorting the selected ids, or ggml_argsort_top_k) may be the more durable option.

Activity

  1. 0xShug0 commented on Oct 17, 2026

    @0xShug0
    Owner

    @Tures55 Thanks for reporting and investigating this! I'll use the model-local ggml_argsort_top_k approach so expert ordering is explicit across backends, rather than fixing only the affected CUDA path.

    Update: Maybe not...argsort has higher WER error. Needs further investigation... Fixed.

  2. 0xShug0 commented on Oct 17, 2026

    @0xShug0
    Owner

    @Tures55 Please check the latest commit.

  3. added a commit that references this issue on Oct 18, 2026
    2052adf
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions