Skip to content

cuda: enable the Hopper wgmma Q1_0/PQ2_0 prefill path by default - #171

Merged
bri-prism merged 2 commits into
prismfrom
perf/hopper-q1-default-on-prism
Sep 14, 2026
Merged

bri-prism merged 2 commits into
prismfrom
perf/hopper-q1-default-on-prism

Conversation

@bri-prism

Copy link
Copy Markdown
Collaborator

Replaces #169, which had its base changed in place from prism-v7 to prism and picked up four unrelated commits as a result. This is a fresh branch off prism with only the two Hopper commits cherry-picked, which is what @khosravipasha asked for on that PR. It applies without conflict.

What

Turns the Hopper wgmma Q1_0/PQ2_0 prefill path on by default when the build option is set, and tightens the architecture guard. One file, +7/-7.

  • GGML_HOPPER_Q1 (opt-in) becomes GGML_HOPPER_Q1_DISABLE (opt-out). The path is active by default when built with GGML_CUDA_HOPPER_Q1. A default build is unaffected: the file is compiled out.
  • The upper architecture bound moves from cc >= GGML_CUDA_CC_BLACKWELL to cc >= 1000.

Why the bound changed

GGML_CUDA_CC_BLACKWELL is 1200 in this tree, and the define carries its own comment noting that Blackwell spans CC 1000, 1100 and 1200 with the macro naming the sm_120 family specifically. So the old guard admitted sm_100 and sm_110 Blackwell parts into an sm_90a wgmma path they cannot run. cc >= 1000 excludes the whole Blackwell range, which is what the surrounding comment always claimed the guard did.

The lower bound now uses GGML_CUDA_CC_HOPPER (900) instead of a literal. The old inline comment said no such macro existed in this tree. It does, at common.cuh:56.

Validation

@khosravipasha ran these two commits cherry-picked onto prism head on an L40S (sm_89, CUDA 12.8):

  • default configure builds, file compiled out, binary behaviour unchanged
  • GGML_CUDA_HOPPER_Q1=ON with CUTLASS, arch 89 + 90a: builds clean, GGML_CUDA_CC_HOPPER resolves, test-backend-ops -o MUL_MAT 1283/1283 in both builds
  • llama-bench on 2B/9B/27B PQ2_0 and PTQ1_0: decode identical within 0.5%, prefill within that card's run-to-run spread
  • KLD against the F16 golden matches the certification values to every printed digit (9B PQ2_0 5.02e-4 / 98.490%, 2B PQ2_0 2.68e-4 / 98.951%)

That confirms the runtime gate keeps Ada on standard MMQ even with the path compiled in.

Still outstanding

The H100 re-run after the gate inversion has not been done. The original measurements were taken with the path opt-in. Nobody has re-measured on actual Hopper since it became default-on, and since the architecture bound changed. Neither @khosravipasha nor I have a Hopper card in front of us. Please do not treat this as a validated Hopper result until that runs.

Nothing in shipped release binaries changes either way, since the build option stays off by default.

Inverts the runtime gate from opt-in (GGML_HOPPER_Q1) to opt-out
(GGML_HOPPER_Q1_DISABLE) for builds configured with GGML_CUDA_HOPPER_Q1.
The build-time flag is unchanged and still off by default, since it
requires a CUTLASS checkout.

Validated internally: prefill improves for the shapes this path serves
and decode is unaffected. A control arm with the path disabled matches
baseline, so the sm_90a plus CUTLASS build costs nothing by itself.

The per-128-K activation scale is coarser than q8_1's per-32, so results
are not bit-identical. The deviation was measured against a same-path
control; it is small and the tail is bounded.

@khosravipasha khosravipasha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…ment

GGML_CUDA_CC_BLACKWELL is 1200, the sm120 family, not the start of
Blackwell. Blackwell spans CC 1000, 1100 and 1200, so the old
cc >= GGML_CUDA_CC_BLACKWELL bound let sm_100 and sm_110 reach an sm_90a
wgmma kernel. That was unreachable while the path was opt-in and becomes
reachable once it defaults on, so bound the dispatch to the 900 series.

Also use GGML_CUDA_CC_HOPPER instead of a literal 900. The macro does
exist in this tree, contrary to the comment that was there.

The file comment is shortened to the concise form AGENTS.md asks for and
no longer points at notes a reader of this repo cannot open.
@bri-prism
bri-prism force-pushed the perf/hopper-q1-default-on-prism branch from 29ed1bb to 2c66a75 Compare September 14, 2026 03:33
@bri-prism
bri-prism merged commit 6ac5eb0 into prism Sep 14, 2026
8 checks passed
@khosravipasha
khosravipasha deleted the perf/hopper-q1-default-on-prism branch September 24, 2026 07:27
imaami pushed a commit to imaami/llama.cpp that referenced this pull request Oct 13, 2026
Build the CUTLASS-based sm_90a path when GGML_CUDA_HOPPER_Q1 is enabled. Select it for supported prefill shapes and retain the existing MMQ fallback.

Source: PrismML-Eng#171

Source commits (PrismML-Eng/llama.cpp):
0845962
6ac5eb0

Co-authored-by: bri-prism <[email protected]>
Assisted-by: GitHub Copilot
Assisted-by: OpenAI Codex

Ported and rebased by Codex.
imaami pushed a commit to imaami/llama.cpp that referenced this pull request Oct 13, 2026
Build the CUTLASS-based sm_90a path when GGML_CUDA_HOPPER_Q1 is enabled. Select it for supported prefill shapes and retain the existing MMQ fallback.

Source: PrismML-Eng#171

Source commits (PrismML-Eng/llama.cpp):
0845962
6ac5eb0

Co-authored-by: bri-prism <[email protected]>
Assisted-by: GitHub Copilot
Assisted-by: OpenAI Codex

Ported and rebased by Codex.
imaami pushed a commit to imaami/llama.cpp that referenced this pull request Nov 2, 2026
Build the CUTLASS-based sm_90a path when GGML_CUDA_HOPPER_Q1 is enabled. Select it for supported prefill shapes and retain the existing MMQ fallback.

Source: PrismML-Eng#171

Originally written by bri-prism in PrismML-Eng#39:
576fdf6
0ce8b19

Source commits (PrismML-Eng/llama.cpp):
0845962
6ac5eb0

Co-authored-by: Pasha Khosravi <[email protected]>
Assisted-by: GitHub Copilot
Assisted-by: OpenAI Codex

Ported and rebased by Codex.
imaami pushed a commit to imaami/llama.cpp that referenced this pull request Nov 24, 2026
Build the CUTLASS-based sm_90a path when GGML_CUDA_HOPPER_Q1 is enabled. Select it for supported prefill shapes and retain the existing MMQ fallback.

Source: PrismML-Eng#171

Originally written by bri-prism in PrismML-Eng#39:
576fdf6
0ce8b19

Source commits (PrismML-Eng/llama.cpp):
0845962
6ac5eb0

Co-authored-by: Pasha Khosravi <[email protected]>
Assisted-by: GitHub Copilot
Assisted-by: OpenAI Codex

Ported and rebased by Codex.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants