mirror of
https://github.com/Comfy-Org/comfy-kitchen.git
synced 2026-11-04 23:37:42 +00:00
[PR #180] Bound VSA coarse score memory on HIP #199
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#199
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/180
Author: @Siilent-Sea
Created: 9/16/2026
Status: 🔄 Open
Base:
main← Head:codex/vsa-coarse-query-chunk📝 Commits (1)
88569c7Bound VSA coarse score memory on HIP📊 Changes
3 files changed (+48 additions, -6 deletions)
View changed files
📝
comfy_kitchen/backends/eager/sol_attn.py(+14 -4)📝
comfy_kitchen/backends/hip/__init__.py(+4 -2)➕
tests/test_eager_sol_attn.py(+30 -0)📄 Description
Problem and scope
The VSA coarse branch currently materializes the complete
[BH, N, N]FP32score tensor. At the production-shape synthetic geometry used here
(
BH=56,N=1338,D=128), that score path accounts for a large avoidablepeak allocation.
Why the change is general
Each query row is independent once the complete key/value block means are
available. Slicing only the query dimension preserves the full key set and the
per-query softmax denominator; it does not change VSA routing, keys, values, or
the mathematical operation.
Implementation
query_chunkargument to eagercoarse_output.slice before concatenation.
query_chunk=64from the two HIP coarse-gate call sites only.Regression test
The new CPU test compares dense and query-chunked results for both a divisible
and a ragged final chunk (
131/64and17/7).Numerical validation
6c7f08bf8d8c6d039892b311d40c976c26ce979f271rtol=2e-4,atol=5e-54.172325134277344e-075.066394805908203e-07Performance and memory validation
Environment: WSL2 Ubuntu 24.04, AMD Radeon RX 9070 XT (gfx1201), PyTorch
2.9.1+rocm7.2.1.gitff65f5bc, HIP7.2.53211-e1a6bc5663, FP32 syntheticblock-mean tensors of shape
[56, 1338, 128], two warmups and seven measuredruns.
That is an 88.59% reduction in the measured peak allocation delta with no
timing regression in this isolated coarse-branch benchmark.
Raw warm wall samples (seconds)
0.018001765, 0.017981337, 0.018061866, 0.018013761, 0.018130983, 0.018103780, 0.0180400320.017591071, 0.017467413, 0.017297295, 0.017588049, 0.017518593, 0.017421424, 0.018291322Platforms tested / not tested
Tested on Mac CPU for current-main import/numerics and on gfx1201 HIP for
numerics, peak allocation, and timing. This is not an H3 end-to-end benchmark.
CUDA/NVIDIA and other AMD generations were not measured.
Risks and fallback
The shared eager helper remains byte-for-byte on its existing dense branch when
query_chunkis omitted. The behavior change is limited to the two HIPcoarse-gate call sites; removing their argument restores the previous path.
Privacy and asset provenance
All validation uses deterministic synthetic tensors. No video, prompt, latent,
model/adapter weight, private path, or private hash is included.
Related issue or discussion
Searches for
VSA coarse attention,sol_attn memory,coarse_output, andquery chunk attentionfound no existing issue or PR implementing this bound.Contribution status
The account holder will complete any platform-requested DCO or Comfy CLA step.
AI assistance disclosure
Submitted by the project owner with assistance from an owner-authorized AI
engineering agent. Reproduction, code, tests and benchmark artifacts are
included.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.