mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #184] Optimize HIP Sol exact attention with paired query blocks #205
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/comfy-kitchen#205
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/comfy-kitchen/pull/184
Author: @qweqweewqe7-create
Created: 9/17/2026
Status: 🔄 Open
Base:
main← Head:optimize-hip-sol-pair128📝 Commits (1)
53e545bOptimize HIP Sol exact attention with paired query blocks📊 Changes
1 file changed (+238 additions, -0 deletions)
View changed files
📝
comfy_kitchen/backends/hip/sage_attention/sol_attn_exact.hip(+238 -0)📄 Description
Summary
Pair adjacent 64-query blocks in the HIP Sol exact-attention consumer so they can share K / V^T / KSB staging when their routed key-block lists overlap.
The two routed block lists are already sorted. The new 256-thread CTA merges those lists with a two-pointer walk while preserving each query block's original traversal order:
Token-augmented calls (
n_tok != 0) keep using the existing exact kernel.Performance
Measured on RX 9070 XT / gfx1201, BF16 MiniMax H3-style Sol exact workloads. Timings are median exact-core latency using ABBA ordering.
The gain stays roughly flat across the tested H3 sequence-length range instead of depending on one specific shape.
Correctness
For the BF16 sweep above, Pair128 matched the existing exact kernel bit-for-bit on sampled outputs and
kmean_next:kmean_nextexact: trueFP16 was also compared directly against the existing exact kernel at ragged / odd-query-block lengths:
Tests
Built for both gfx1200 and gfx1201 and ran the Sol attention test suite with Pair128 as the default non-token exact path:
104 passed, 1 skipped104 passed, 1 skippedThe suite covers ragged tails, batch > 1, FP16/BF16, strided inputs, chunked producer behavior, sinks, top-k routing, and token augmentation / fallback behavior.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.