Skip to content

[Triton/Gluon] Sol-Attn: block pooling, routing and low-rank tilt factors - #7729

Merged
nsakkine merged 3 commits into
ROCm:mainfrom
nsakkine:nsakkine/sol-attn-triton
Nov 12, 2026
Merged

nsakkine merged 3 commits into
ROCm:mainfrom
nsakkine:nsakkine/sol-attn-triton

Conversation

@nsakkine

@nsakkine nsakkine commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Sol-Attn (arXiv 2607.24027) adds a pooled pass to block-sparse attention: a block that the LUT leaves out adds its pooled K/V term instead of nothing. This PR adds the Triton operators that prepare those operands. The mha_v4 ASM kernels that read them follow in the next PR.

Changes

  • sol_prepare() (attention/utils.py): from one block selection, it builds the LUT, the block bitmap and the pooled K/V. The selection is routed from beta or supplied as a mask. It can also give the Jensen K variance.
  • sol_attn_pool (attention/sol_attn_pool.py, kernel in _triton_kernels/): pools a BSHD tensor into one row per block. It gives the block mean and, optionally, the variance or the mean of squares, in one read.
  • attention/sol_tilt.py: the Jensen cap and the low-rank tilt factors and planes for each Sol recipe.
  • mxfp6_fmha_pack.fill_fp6_k_scale_tails: a public helper that writes the MXFP6 K scale tails.
  • Tuned gfx950 configs: sol_attn_pool and sol_tilt_factor. An arch without a config file uses a portable fallback.

Tests

  • op_tests/triton_tests/attention/test_sol_prepare.py
  • op_tests/triton_tests/attention/test_sol_tilt.py

Each wrapper is checked against a Torch reference and under torch.compile(fullgraph=True).

Benchmark: op_tests/op_benchmarks/triton/bench_sol_tilt.py.

Stack

1 of 3. This PR has no HIP or ASM change.

  1. This PR: Triton operators
  2. #PR2: mha_v4 Sol-Attn ASM kernels and launcher, see 7794
  3. #PR3: benchmarks of the Sol-Attn rows

PR Self-Review

Reviewed revision

b9987e0

Behavior and intent

This PR adds new Triton operators. It does not change the behavior of an existing operator.

  • sol_prepare() (attention/utils.py) builds the inputs of the Sol-Attn kernels from one block selection: the LUT, the block bitmap and the pooled K/V in the kernel's own formats, with E8M0 scales where the recipe needs them. The selection is routed from beta (mean or error router) or supplied as a mask. It can also give the Jensen K variance.
  • sol_attn_pool pools a BSHD tensor into one row per block (the mean, plus optionally the variance or the mean of squares) in one read.
  • attention/sol_tilt.py builds the Jensen cap and the low-rank tilt factors and planes for each Sol recipe. It refuses pooled K/V whose block count does not match kv_tile before any kernel writes. It keeps no device-wide state, so a first call inside a CUDA graph capture is safe.
  • mxfp6_fmha_pack.fill_fp6_k_scale_tails is a public helper for the MXFP6 K scale tails. reorder_fp6_k_lds_order_triton now calls it instead of launching the kernel itself. Its output does not change (see Validation).

Why the existing behavior is not sufficient: block-sparse attention (block_attn_mask_to_lut and the mha_v4 sparse rows) keeps or drops each block. A dropped block adds nothing. Sol-Attn (arXiv 2607.24027) adds a pooled pass, in which each dropped block adds its pooled K/V term. That pass needs the LUT, the bitmap and the pooled operands from the same selection, quantized as the kernel reads them. No existing operator makes them. The mha_v4 kernels that consume them follow in #PR2.

Validation and unverified scope

Summary: validated on MI355X (gfx950) with the two op tests, the benchmark, lint and the review-time byte and sweep checks below. What remains unverified: architectures other than gfx950, shapes other than Wan 2.2 at head dim 128, end-to-end accuracy with the ASM kernels (#PR2), and the #PR2 mha_v4 tests against this revision. Details follow.

Hardware and software: MI355X (gfx950), ROCm 10.1.0, torch 2.13.0 (HIP 7.16), Triton 3.8.0. The test, lint and benchmark runs below used this revision (main at 97d2389 plus this PR only). The byte and sweep checks after them ran during development, on a branch with the same Triton files.

  • python3 -m pytest -q op_tests/triton_tests/attention/test_sol_prepare.py: 91 passed.
  • python3 -m pytest -q op_tests/triton_tests/attention/test_sol_tilt.py: 94 passed.
  • ruff check and black --check on the changed Python files: clean.
  • python3 op_tests/op_benchmarks/triton/bench_sol_tilt.py --rank 2 (720p, Ulysses 8, KV tile 128):
    • sol_q_abs_max: 17.4-51.3 us over the 4 Q kinds (rotated 44.2 us);
    • sol_jensen_cap: 21.5-28.9 us over the 5 K kinds;
    • sol_tilt_planes: 113.6-215.6 us over the 8 recipes;
    • sol_tilt_factors: 109.7 us.
  • Rotation signs built in the kernel: rotated sol_q_abs_max outputs are byte-identical to the earlier cached signs on 4 shapes, and 20% faster (55.7 to 44.5 us). The new graph-capture test failed on the cached signs (all 7680 maxima wrong) and passes now.
  • Pooled block-count check: the new rejection test failed in all 6 cases before the check (the call returned, after writing past its planes) and passes now.
  • reorder_fp6_k_lds_order_triton before and after the helper change: byte-identical buffers for 256, 300 and 37 rows (full and partial last tile). Fresh allocations were filled with 0xA5, so unwritten bytes also compare equal.
  • sol_attn_pool schedule: a check with a sentinel config confirmed that the launch reads the JSON. The published values give the same launches as the earlier formulas in Python, and a missing file gives the fallback.
  • sol_tilt_factor schedule: a sweep of num_warps 1/2/4/8 x waves_per_eu 0/1/2/4 over 21 cases (fp8, bf16 and int8 paths; KV tile 64 and 128; rank 1-4; 5 and 40 heads). With the published values, every bench_sol_tilt.py case (720p, Ulysses 8, rank 2, KV tile 64 and 128, all 9 factors and planes recipes) is 11-54% faster than with 4 warps / 2 waves. The outputs are byte-identical, including every tilt plane.

What remains unverified:

  • Unverified: every architecture other than gfx950, because only MI355X was available. On other arches the two config families have no file and use the portable fallback, and the tests that need the gfx950 MXFP4/MXFP6 packers skip. The fallback's correctness and speed and the skipped tests were not run there.
  • Unverified: tuning outside head dim 128 at Wan 2.2 shapes (720p and 480p; 5 and 40 heads). Other shapes use the same configs but were not measured.
  • Unverified in this PR: end-to-end Sol-Attn accuracy, because it needs the ASM kernels. #PR2 tests it (op_tests/test_mha_v4_sparse.py).
  • Unverified on this PR alone: op_tests/test_mha_v4.py, which calls reorder_fp6_k_lds_order_triton. I ran it only on the full stack, where all its checks pass. The byte-identity check above covers that caller.
  • Unverified: the mha_v4 tests in #PR2 against this revision's pooled block-count check. Their callers pass BLOCK_N equal to the tile, so they are expected to pass it.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

Both config families are new. No existing config file changes: the only config changes in this PR are two added files.

  • configs/gfx950/triton/attention/sol_attn_pool/DEFAULT.json is read only by sol_attn_pool._pool_tile(block, element_size, aux), through resolve_config_dir("attention", "SOL_ATTN_POOL"). The key is mean_<element size> for the mean alone, or aux_<element size> when a second statistic is pooled, with element size 1, 2 or 4. Each key is bucketed by block size with BLOCK_LEQ_<n> and any. The only callers are sol_prepare's pooling of Q, K and V.
  • configs/gfx950/triton/attention/sol_tilt_factor/DEFAULT.json is read only by sol_tilt._factor_launch(to_bf16, kv_tile), through resolve_config_dir("attention", "SOL_TILT_FACTOR"). The key is fp8 when K and V are both FP8 and bf16 otherwise, which includes int8 K. It is bucketed by KV tile with BLOCK_N_LEQ_64 and any. The only callers are sol_tilt_factors and sol_tilt_planes.

Evidence that unrelated shapes keep their selection: rg "SOL_ATTN_POOL|SOL_TILT_FACTOR" aiter finds only these two loaders. git diff --name-status 97d2389d41 b9987e01b578 -- aiter/ops/triton/configs lists only the two added files. No other operator reads these families, and no existing family changes, so every other kernel's config selection is the same as on main.

Changed op tests

  • op_tests/triton_tests/attention/test_sol_prepare.py (new) covers sol_prepare and sol_attn_pool:

    • the output contract and shapes, and the agreement of the LUT and bitmap with the mask;
    • the pooled K/V against an independent block mean;
    • the empty-row and partial-tail rules;
    • the mean and error routers against reference thresholds;
    • the supplied-mask path and its input checks;
    • Q-scale routing;
    • the Jensen K variance for integer and block-scaled K;
    • the pooled scale padding;
    • torch.compile(fullgraph=True) parity, with no graph breaks.

    It is not redundant: no existing test calls these operators. test_mha_v4_sparse.py in #PR2 tests the kernels end to end, not the contracts of the preparation step.

  • op_tests/triton_tests/attention/test_sol_tilt.py (new) covers sol_q_abs_max, sol_jensen_cap, sol_tilt_factors, sol_tilt_planes and the parameter builders:

    • the planes decode to the rank-r truncation of each block's covariance and scale with the block gain;
    • the factors match the e4m3 planes;
    • the packed formats keep the packer's zeroed scale backing;
    • the cap damps each block to ln(KV tile);
    • invalid input is rejected, including pooled K/V of another kv_tile, before any kernel writes;
    • each wrapper matches eager under torch.compile(fullgraph=True);
    • a first rotated sol_q_abs_max call inside a CUDA graph capture leaves the eager and compiled calls before the replay correct.

    It is not redundant: these operators are new, and no other test checks them against a reference.

  • op_tests/op_benchmarks/triton/bench_sol_tilt.py (new) times the tilt wrappers at Wan 2.2 shapes. README rule 17 requires a benchmark per Triton op. No other benchmark times these wrappers, and its numbers are the evidence for the tuned sol_tilt_factor values. The Jensen-cap and factors cases pass Q as a one-element view of its shape: those calls read q_abs_max, not Q, so the rotating pool is sized by what the call reads.

…tors

Add the Triton side of Sol-Attn. The mha_v4 Sol-Attn rows read these
operands; that ASM change follows in a separate PR.

- sol_prepare() in attention/utils.py builds the LUT, the block bitmap
  and the pooled K/V from one block selection. The selection is routed
  from beta or supplied as a mask. It can also give the Jensen K
  variance.
- sol_attn_pool pools a BSHD tensor into one row per block: the block
  mean and, optionally, the variance or the mean of squares, in one
  read.
- attention/sol_tilt.py builds the Jensen cap and the low-rank tilt
  factors and planes for each Sol recipe.
- mxfp6_fmha_pack.fill_fp6_k_scale_tails writes the MXFP6 K scale
  tails; reorder_fp6_k_lds_order_triton and sol_tilt use it.
- Tuned gfx950 configs for the pool and the tilt factor kernels.

Tests: test_sol_prepare.py and test_sol_tilt.py check each wrapper
against a Torch reference and under torch.compile(fullgraph=True).
Benchmark: bench_sol_tilt.py.

Signed-off-by: Niko Säkkinen <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter standard tests on MI35X
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:mi300x Run Aiter standard tests on MI300X in PRs; main branch always runs them
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs (added automatically when gfx942 configs change); main branch always runs both MI35X and MI300X
ci:triton-355 Run the full Triton test suite on MI35X, not only the tests the change affects
ci:windows Windows JIT op smoke test on the Radeon R9700 ROCm runner
ci:multi-gpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: DeepSeek-V4-Pro, MiniMax-M3-MXFP4
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 7729 --add-label <label>

One backend per PR:
A PR changes one kernel backend: [Triton/Gluon] (Triton and Gluon count as one), [HIP], [ASM], [CK], [OPUS] or [FlyDSL]. If the title ends up with two backend tags, split the PR -- as stacked pull requests when one part cannot merge without the other.

PR title tags & labels:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title and as PR labels automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf], op tags like [MLA], and human labels (ci:*) are left untouched. Add the no-auto-title label to stop the title rewrites; labels stay in sync either way.

Reviews:
A reviewer is usually assigned within one working day after the PR is ready for review (see Code Review Process). If nobody has responded for about a week, mention the area contact listed in CONTACTS.md. Want to help review? See REVIEWERS.md.

@nsakkine
nsakkine marked this pull request as ready for review November 10, 2026 10:19
@nsakkine
nsakkine requested a review from a team November 10, 2026 10:19
@github-actions github-actions Bot changed the title Sol-Attn: block pooling, routing and low-rank tilt factors [Triton/Gluon] Sol-Attn: block pooling, routing and low-rank tilt factors Nov 10, 2026
@aiter-bot

aiter-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

READY FOR HUMAN REVIEW

PR Self-Review

Revision b9987e01b578 · mode shadow

Author self-review accepted. Readiness report:

Author answers

  • PASS — current-SHA answers are present and structurally specific
Show the author's self-review answers

Behavior and intent

This PR adds new Triton operators. It does not change the behavior of an existing operator.

- `sol_prepare()` (`attention/utils.py`) builds the inputs of the Sol-Attn kernels from one block selection: the LUT, the block bitmap and the pooled K/V in the kernel's own formats, with E8M0 scales where the recipe needs them. The selection is routed from `beta` (mean or error router) or supplied as a mask. It can also give the Jensen K variance.
- `sol_attn_pool` pools a BSHD tensor into one row per block (the mean, plus optionally the variance or the mean of squares) in one read.
- `attention/sol_tilt.py` builds the Jensen cap and the low-rank tilt factors and planes for each Sol recipe. It refuses pooled K/V whose block count does not match `kv_tile` before any kernel writes. It keeps no device-wide state, so a first call inside a CUDA graph capture is safe.
- `mxfp6_fmha_pack.fill_fp6_k_scale_tails` is a public helper for the MXFP6 K scale tails. `reorder_fp6_k_lds_order_triton` now calls it instead of launching the kernel itself. Its output does not change (see Validation).

Why the existing behavior is not sufficient: block-sparse attention (`block_attn_mask_to_lut` and the mha_v4 sparse rows) keeps or drops each block. A dropped block adds nothing. Sol-Attn (arXiv 2607.24027) adds a pooled pass, in which each dropped block adds its pooled K/V term. That pass needs the LUT, the bitmap and the pooled operands from the same selection, quantized as the kernel reads them. No existing operator makes them. The mha_v4 kernels that consume them follow in #PR2.

Validation and unverified scope

Summary: validated on MI355X (gfx950) with the two op tests, the benchmark, lint and the review-time byte and sweep checks below. What remains unverified: architectures other than gfx950, shapes other than Wan 2.2 at head dim 128, end-to-end accuracy with the ASM kernels (#PR2), and the #PR2 mha_v4 tests against this revision. Details follow.

Hardware and software: MI355X (gfx950), ROCm 10.1.0, torch 2.13.0 (HIP 7.16), Triton 3.8.0. The test, lint and benchmark runs below used this revision (main at 97d2389d41 plus this PR only). The byte and sweep checks after them ran during development, on a branch with the same Triton files.

- `python3 -m pytest -q op_tests/triton_tests/attention/test_sol_prepare.py`: 91 passed.
- `python3 -m pytest -q op_tests/triton_tests/attention/test_sol_tilt.py`: 94 passed.
- `ruff check` and `black --check` on the changed Python files: clean.
- `python3 op_tests/op_benchmarks/triton/bench_sol_tilt.py --rank 2` (720p, Ulysses 8, KV tile 128):
  - `sol_q_abs_max`: 17.4-51.3 us over the 4 Q kinds (rotated 44.2 us);
  - `sol_jensen_cap`: 21.5-28.9 us over the 5 K kinds;
  - `sol_tilt_planes`: 113.6-215.6 us over the 8 recipes;
  - `sol_tilt_factors`: 109.7 us.
- Rotation signs built in the kernel: rotated `sol_q_abs_max` outputs are byte-identical to the earlier cached signs on 4 shapes, and 20% faster (55.7 to 44.5 us). The new graph-capture test failed on the cached signs (all 7680 maxima wrong) and passes now.
- Pooled block-count check: the new rejection test failed in all 6 cases before the check (the call returned, after writing past its planes) and passes now.
- `reorder_fp6_k_lds_order_triton` before and after the helper change: byte-identical buffers for 256, 300 and 37 rows (full and partial last tile). Fresh allocations were filled with 0xA5, so unwritten bytes also compare equal.
- `sol_attn_pool` schedule: a check with a sentinel config confirmed that the launch reads the JSON. The published values give the same launches as the earlier formulas in Python, and a missing file gives the fallback.
- `sol_tilt_factor` schedule: a sweep of num_warps 1/2/4/8 x waves_per_eu 0/1/2/4 over 21 cases (fp8, bf16 and int8 paths; KV tile 64 and 128; rank 1-4; 5 and 40 heads). With the published values, every `bench_sol_tilt.py` case (720p, Ulysses 8, rank 2, KV tile 64 and 128, all 9 factors and planes recipes) is 11-54% faster than with 4 warps / 2 waves. The outputs are byte-identical, including every tilt plane.

**What remains unverified:**

- Unverified: every architecture other than gfx950, because only MI355X was available. On other arches the two config families have no file and use the portable fallback, and the tests that need the gfx950 MXFP4/MXFP6 packers skip. The fallback's correctness and speed and the skipped tests were not run there.
- Unverified: tuning outside head dim 128 at Wan 2.2 shapes (720p and 480p; 5 and 40 heads). Other shapes use the same configs but were not measured.
- Unverified in this PR: end-to-end Sol-Attn accuracy, because it needs the ASM kernels. #PR2 tests it (`op_tests/test_mha_v4_sparse.py`).
- Unverified on this PR alone: `op_tests/test_mha_v4.py`, which calls `reorder_fp6_k_lds_order_triton`. I ran it only on the full stack, where all its checks pass. The byte-identity check above covers that caller.
- Unverified: the mha_v4 tests in #PR2 against this revision's pooled block-count check. Their callers pass `BLOCK_N` equal to the tile, so they are expected to pass it.

PR-specific question

Which exact workload keys consume these configuration changes, and what evidence shows that unrelated shapes keep their previous selection?

Both config families are new. No existing config file changes: the only config changes in this PR are two added files.

- `configs/gfx950/triton/attention/sol_attn_pool/DEFAULT.json` is read only by `sol_attn_pool._pool_tile(block, element_size, aux)`, through `resolve_config_dir("attention", "SOL_ATTN_POOL")`. The key is `mean_<element size>` for the mean alone, or `aux_<element size>` when a second statistic is pooled, with element size 1, 2 or 4. Each key is bucketed by block size with `BLOCK_LEQ_<n>` and `any`. The only callers are `sol_prepare`'s pooling of Q, K and V.
- `configs/gfx950/triton/attention/sol_tilt_factor/DEFAULT.json` is read only by `sol_tilt._factor_launch(to_bf16, kv_tile)`, through `resolve_config_dir("attention", "SOL_TILT_FACTOR")`. The key is `fp8` when K and V are both FP8 and `bf16` otherwise, which includes int8 K. It is bucketed by KV tile with `BLOCK_N_LEQ_64` and `any`. The only callers are `sol_tilt_factors` and `sol_tilt_planes`.

Evidence that unrelated shapes keep their selection: `rg "SOL_ATTN_POOL|SOL_TILT_FACTOR" aiter` finds only these two loaders. `git diff --name-status 97d2389d41 b9987e01b578 -- aiter/ops/triton/configs` lists only the two added files. No other operator reads these families, and no existing family changes, so every other kernel's config selection is the same as on main.

Changed op tests

- `op_tests/triton_tests/attention/test_sol_prepare.py` (new) covers `sol_prepare` and `sol_attn_pool`:
  - the output contract and shapes, and the agreement of the LUT and bitmap with the mask;
  - the pooled K/V against an independent block mean;
  - the empty-row and partial-tail rules;
  - the mean and error routers against reference thresholds;
  - the supplied-mask path and its input checks;
  - Q-scale routing;
  - the Jensen K variance for integer and block-scaled K;
  - the pooled scale padding;
  - `torch.compile(fullgraph=True)` parity, with no graph breaks.

  It is not redundant: no existing test calls these operators. `test_mha_v4_sparse.py` in #PR2 tests the kernels end to end, not the contracts of the preparation step.
- `op_tests/triton_tests/attention/test_sol_tilt.py` (new) covers `sol_q_abs_max`, `sol_jensen_cap`, `sol_tilt_factors`, `sol_tilt_planes` and the parameter builders:
  - the planes decode to the rank-r truncation of each block's covariance and scale with the block gain;
  - the factors match the e4m3 planes;
  - the packed formats keep the packer's zeroed scale backing;
  - the cap damps each block to ln(KV tile);
  - invalid input is rejected, including pooled K/V of another kv_tile, before any kernel writes;
  - each wrapper matches eager under `torch.compile(fullgraph=True)`;
  - a first rotated `sol_q_abs_max` call inside a CUDA graph capture leaves the eager and compiled calls before the replay correct.

  It is not redundant: these operators are new, and no other test checks them against a reference.
- `op_tests/op_benchmarks/triton/bench_sol_tilt.py` (new) times the tilt wrappers at Wan 2.2 shapes. README rule 17 requires a benchmark per Triton op. No other benchmark times these wrappers, and its numbers are the evidence for the tuned `sol_tilt_factor` values. The Jensen-cap and factors cases pass Q as a one-element view of its shape: those calls read `q_abs_max`, not Q, so the rotating pool is sized by what the call reads.

PR state

  • PASS — pull request is marked ready for review

Copilot findings

  • PASS — no active Copilot finding lacks a substantive author reply
  • ADVISORY — Copilot did not review the current head SHA

Code and op-test hygiene

  • PASS — no committed artifact or conflict marker detected

Required CI

  • PASS — Black: passed
  • PASS — Ruff: passed
  • PASS — Repository dependency: passed
  • PASS — Aiter Test Gate: passed

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Critical unresolved issues can collapse rank-2 results to rank 1, cause out-of-bounds writes when block and tile sizes mismatch, and expose uninitialized rotation data across graph and eager calls.

4 open issues
What changed in this PR

This PR adds Triton preparation operators for Sol-Attn’s pooled block-sparse attention path. It prepares routing, pooled operands and low-rank corrections for ASM consumers planned in the next PR.

Changes:

  • Add block pooling, routing, LUT/bitmap generation and quantized operand preparation.
  • Add Jensen caps, low-rank tilt factors and planes, plus gfx950 tuning configs.
  • Add reference and full-graph compilation tests, a tilt benchmark and a reusable MXFP6 scale-tail helper.
File Description
op_tests/​triton_tests/​attention/​test_sol_tilt.py Tests caps, tilt formats, scale padding and compilation parity.
op_tests/​triton_tests/​attention/​test_sol_prepare.py Tests routing, pooled values, output contracts and compilation.
op_tests/​op_benchmarks/​triton/​bench_sol_tilt.py Benchmarks tilt and cap wrappers on Wan shapes.
aiter/​ops/​triton/​quant/​mxfp6_fmha_pack.py Extracts a public MXFP6 K scale-tail writer.
aiter/​ops/​triton/​configs/​gfx950/​triton/​attention/​sol_tilt_factor/​DEFAULT.json Adds factor-kernel launch schedules.
aiter/​ops/​triton/​configs/​gfx950/​triton/​attention/​sol_attn_pool/​DEFAULT.json Adds pooling schedules by statistic, dtype size and block size.
aiter/​ops/​triton/​attention/​utils.py Adds Sol-Attn routing and pooled-operand preparation.
aiter/​ops/​triton/​attention/​sol_tilt.py Adds public cap, factor and plane wrappers.
aiter/​ops/​triton/​attention/​sol_attn_pool.py Adds the public block-pooling wrapper and config loading.
aiter/​ops/​triton/​_triton_kernels/​attention/​sol_tilt.py Implements maxima, caps, factorization and plane encoding.
aiter/​ops/​triton/​_triton_kernels/​attention/​sol_attn_pool.py Implements block means, variance and mean of squares.

Review effort: Balanced

Comment thread aiter/ops/triton/attention/sol_tilt.py Resolved
Comment thread aiter/ops/triton/attention/sol_tilt.py Resolved
…lock mismatch

Build the q_abs_max rotation signs in the kernel. A first
sol_q_abs_max(rotate=True) call inside a CUDA graph capture put the
rotation signs into a device-wide cache before their initialization
kernels ran, so an eager call or another graph before the first replay
read uninitialized signs. The packers' hd128 rotation is the Sylvester
Hadamard matrix, H[i, j] = (-1)^popcount(i & j), so the kernel now makes
it from the row and column indices, and the cache is removed. Rotated
outputs are byte-identical, and the rotated q_abs_max is 20% faster on
MI355X (55.7 -> 44.5 us at 720p, Ulysses 8).

Refuse pooled K/V of another kv_tile. sol_tilt_factors and
sol_tilt_planes took the block count from mean_k, but the factor kernel
writes one plane row per full kv_tile block of K, unmasked. Means pooled
at sol_prepare's default 128-token blocks used with kv_tile=64 allocated
two plane rows and wrote four, which corrupted the next rank's plane and
the B planes after it. Both wrappers now check, before anything is
allocated, that mean_k, mean_v and the pooled BF16 rows have
ceil(seqlen_k / kv_tile) blocks. The pack kernel reads mean_v over
mean_k's blocks, so a short mean_v is refused too.

Add tests for a first rotated call inside a graph capture, and for
pooled K/V of another kv_tile or a short mean_v in both wrappers.

Signed-off-by: Niko Säkkinen <[email protected]>
@zufayu
zufayu requested review from a team and Dewei-Wang-sh November 11, 2026 00:53
…ng pool

sol_jensen_cap and sol_tilt_factors read q_abs_max and take only Q's
shape, but the benchmark passed the full Q, and the rotating pool counts
every tensor in the kwargs. At 720p with Ulysses 8, Q's 46-92 MB made
each Jensen-cap entry look about 100 MB against the 1.6-3.1 MB the call
reads. The 256 MB target then gave 4-6 entries, and the read set stayed
in cache.

Pass Q as a one-element view of its shape in those two cases. The
Jensen-cap pool grows from 4-6 to 84-165 entries, and its times rise by
1-2 us to uncached values. Outputs are bit-identical, and the factors
case, which reads 93 MB of K/V, does not change.

Signed-off-by: Niko Säkkinen <[email protected]>
@nsakkine nsakkine mentioned this pull request Nov 11, 2026
5 of 10 tasks
@azaidy
azaidy requested a review from cagrikymk November 12, 2026 06:39
@nsakkine
nsakkine merged commit 07d1b2a into ROCm:main Nov 12, 2026
vpietila-amd pushed a commit that referenced this pull request Nov 12, 2026
…tors (#7729)

* [Triton/Gluon] Sol-Attn: block pooling, routing and low-rank tilt factors

Add the Triton side of Sol-Attn. The mha_v4 Sol-Attn rows read these
operands; that ASM change follows in a separate PR.

- sol_prepare() in attention/utils.py builds the LUT, the block bitmap
  and the pooled K/V from one block selection. The selection is routed
  from beta or supplied as a mask. It can also give the Jensen K
  variance.
- sol_attn_pool pools a BSHD tensor into one row per block: the block
  mean and, optionally, the variance or the mean of squares, in one
  read.
- attention/sol_tilt.py builds the Jensen cap and the low-rank tilt
  factors and planes for each Sol recipe.
- mxfp6_fmha_pack.fill_fp6_k_scale_tails writes the MXFP6 K scale
  tails; reorder_fp6_k_lds_order_triton and sol_tilt use it.
- Tuned gfx950 configs for the pool and the tilt factor kernels.

Tests: test_sol_prepare.py and test_sol_tilt.py check each wrapper
against a Torch reference and under torch.compile(fullgraph=True).
Benchmark: bench_sol_tilt.py.

Signed-off-by: Niko Säkkinen <[email protected]>

* [Triton/Gluon] Sol-Attn: make the tilt safe under graph capture and block mismatch

Build the q_abs_max rotation signs in the kernel. A first
sol_q_abs_max(rotate=True) call inside a CUDA graph capture put the
rotation signs into a device-wide cache before their initialization
kernels ran, so an eager call or another graph before the first replay
read uninitialized signs. The packers' hd128 rotation is the Sylvester
Hadamard matrix, H[i, j] = (-1)^popcount(i & j), so the kernel now makes
it from the row and column indices, and the cache is removed. Rotated
outputs are byte-identical, and the rotated q_abs_max is 20% faster on
MI355X (55.7 -> 44.5 us at 720p, Ulysses 8).

Refuse pooled K/V of another kv_tile. sol_tilt_factors and
sol_tilt_planes took the block count from mean_k, but the factor kernel
writes one plane row per full kv_tile block of K, unmasked. Means pooled
at sol_prepare's default 128-token blocks used with kv_tile=64 allocated
two plane rows and wrote four, which corrupted the next rank's plane and
the B planes after it. Both wrappers now check, before anything is
allocated, that mean_k, mean_v and the pooled BF16 rows have
ceil(seqlen_k / kv_tile) blocks. The pack kernel reads mean_v over
mean_k's blocks, so a short mean_v is refused too.

Add tests for a first rotated call inside a graph capture, and for
pooled K/V of another kv_tile or a short mean_v in both wrappers.

Signed-off-by: Niko Säkkinen <[email protected]>

* [Triton/Gluon] Sol-Attn: keep unread Q out of the tilt bench's rotating pool

sol_jensen_cap and sol_tilt_factors read q_abs_max and take only Q's
shape, but the benchmark passed the full Q, and the rotating pool counts
every tensor in the kwargs. At 720p with Ulysses 8, Q's 46-92 MB made
each Jensen-cap entry look about 100 MB against the 1.6-3.1 MB the call
reads. The 256 MB target then gave 4-6 entries, and the read set stayed
in cache.

Pass Q as a one-element view of its shape in those two cases. The
Jensen-cap pool grows from 4-6 to 84-165 entries, and its times rise by
1-2 us to uncached values. Outputs are bit-identical, and the factors
case, which reads 93 MB of K/V, does not change.

Signed-off-by: Niko Säkkinen <[email protected]>

---------

Signed-off-by: Niko Säkkinen <[email protected]>
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.

5 participants