Skip to content

cuda : a quantize launch between attention and output projection #107

Closed

Description

@rafasmour

One token of Gemma 4 31B launches quantize_q8_1 241 times on an RX 7900 XT (rocprofv3 kernel trace, llama-bench), 4 times per layer. One of the four sites is the attention result that the output projection reads: the mat-vec kernel wants its input as q8_1 blocks, so a quantize kernel runs between the attention and the projection.

The rms_norm and the gated unary kernels already write the q8_1 copy of their result into the cache that the mat-vec looks up. The combine kernel of the attention (flash_attn_combine_results) can do the same: it has one block per head and token with one thread per value, so each warp holds exactly one q8_1 block when the head size is a multiple of 32.

An empty launch costs 2.9 us on this card (ROCm 10.1), the quantize kernel itself 2.0 us.

Activity

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