Skip to content

Annotate W4A16 profiler scopes with group size and symmetry - #1067

Merged
mgehre-amd merged 1 commit into
gfx11from
matthias.w4a16-profiler-group-sym-markers
Jul 29, 2026
Merged

Annotate W4A16 profiler scopes with group size and symmetry#1067
mgehre-amd merged 1 commit into
gfx11from
matthias.w4a16-profiler-group-sym-markers

Conversation

@mgehre-amd

@mgehre-amd mgehre-amd commented Jul 29, 2026

Copy link
Copy Markdown

Problem

The W4A16 record_function labels carried only MxNxK. That is not enough to turn a
trace into a bandwidth number, because a grouped W4A16 GEMM does not only stream weights:

  • a per-group scale, N * (K/group_size) elements at 2 bytes
  • for asymmetric layers, a per-group zero-point, same size again

Neither is derivable from the shape, so the roofline tooling counted N*K/2 weight bytes
and nothing else.

On cyankiwi/gemma-4-31B-it-AWQ-4bit (g=32, asymmetric) that is 28.9 MB unaccounted
against 115.6 MB of weights — a 25% undercount
. The consequence was not cosmetic: the
decode GEMMs read as ~163 GiB/s. Counting the bytes actually moved puts
every one of those shapes at 187-204 GiB/s

Change

Labels now carry g<group_size> and sym/asym:

wvsplitk_int4 1x43008x5376 g32 asym
hybrid_triton_w4a16 779x43008x5376 g32 asym
fused_moe_wvsplitk_int4 1x1536x2048 E=128 top_k=8 g=32 sym
hybrid_triton_moe 512x1536x2048 E=128 top_k=8 g=32 sym

The W4A16 record_function labels carried only MxNxK, which is not enough
to turn a trace into a bandwidth number. A grouped W4A16 GEMM also streams
a per-group scale, and for asymmetric layers a zero-point, each
N * (K/group_size) elements at 2 bytes. Neither is derivable from the
shape, so the roofline tooling counted N*K/2 weight bytes and nothing
else.

On gemma-4-31B-it-AWQ-4bit (g=32, asymmetric) that omission is 28.9 MB
against 115.6 MB of weights -- a 25% undercount. It made the decode GEMMs
read as 163 GiB/s next to 216 GiB/s for the fp16 lm_head in the same
trace, i.e. an apparent 25% kernel deficit that does not exist: counting
all the bytes actually moved puts every shape at 187-204 GiB/s.

Labels now carry g<group_size> and sym/asym:

    wvsplitk_int4 1x43008x5376 g32 asym
    fused_moe_wvsplitk_int4 1x1536x2048 E=128 top_k=8 g=32 sym

Changes:
- Covers both W4A16 GEMM paths (wvsplitk_int4, hybrid_triton_w4a16) and
  the dense-prefill hybrid_dequant_w4a16, plus the MoE scopes
  (fused_moe_wvsplitk_int4 GEMM1/GEMM2, moe_gemm_w4a16, hybrid_triton_moe).
- MoE GEMM1 and GEMM2 read w1_zp and w2_zp independently rather than
  assuming both halves share a symmetry.
- hybrid_triton_moe is hardcoded "sym" because that wrapper is
  symmetric-only by construction (b_zp_ptr=None, has_zp=False, zero-point
  bias folded into the constant 8). Emitting the marker anyway lets the
  tooling account the scale bytes.
- moe_gemm_w4a16 takes an optional asym flag defaulting to None, which
  emits nothing, so any caller that cannot supply it keeps the old label
  rather than getting a wrong "sym".
- Consumer side is a separate change in the roofline script; labels
  without the markers keep parsing, so old traces are unaffected.

Validated on gfx1151: gemma-4-31B (dense, g32 asym) and
Qwen3-30B-A3B-Instruct-2507-AWQ-4bit (MoE, g32 sym); byte counts
hand-checked against the emitted labels.

Signed-off-by: Matthias Gehre <matthias.gehre@amd.com>
@mgehre-amd
mgehre-amd merged commit 7592c73 into gfx11 Jul 29, 2026
7 checks passed
@mgehre-amd
mgehre-amd deleted the matthias.w4a16-profiler-group-sym-markers branch July 29, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants