[PR #2492] [Engine] add opt-in gfx12 grid padding for selected decode matvecs #4075

Open
opened 2026-11-07 15:33:02 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2492
Author: @i-Vladimir-i
Created: 10/14/2026
Status: 🔄 Open

Base: main ← Head: grid-pad


📝 Commits (1)

  • 9273f1b [Codex]: add opt-in gfx12 grid padding for decode matvecs

📊 Changes

6 files changed (+179 additions, -12 deletions)

View changed files

📝 CMakeLists.txt (+3 -0)
📝 docs/AMD_HIP.md (+9 -0)
➕ include/strata/kernels/grid_pad.hpp (+81 -0)
📝 src/kernels/cuda/native_bf16.cu (+5 -2)
📝 src/kernels/cuda/native_mmvq.cu (+31 -10)
➕ src/kernels/grid_pad_test.cpp (+50 -0)

📄 Description

Problem and result

Selected T=1 decode matvec launches on gfx12 stall near full-die wave-slot boundaries.
STRATA_GRID_PAD=1 adds empty workgroups that return before indexing output rows.
Padding remains off by default; T>1, CUDA and non-gfx12 launch geometry is unchanged.

This refreshes the existing #2492, without VMM, ISA, copy-stream or MCP changes.
The current wave MMVQ path can bypass padded fallbacks, so default-wave and explicit
STRATA_MMVQ_WAVE=0 controls are reported separately.

Approach

Use a per-device gfx12 geometry check and a bounded padding rule for the selected
single-token launchers. Extra blocks return before signed row indexing. Host tests
cover stall boundaries, no-op multi-token cases, overflow bounds and idempotence.

Validation

Linux AMD Radeon AI PRO R9700/gfx1201; official GGML
3cf03257f219afbe7334045ff7c6a06ac68c627d.
Tested base 9f7d977d220e9fdf2ec53cf2620cdadac1cfb24e, candidate tree
398c5ffedbe7162a7d8eb54f747e45c5b903463e.
Published base 54828c7e only adds eight sponsor README files; the tested feature diff
is byte-identical, SHA256
5db2f0beca7cec0bd5184f29760cc5752144f9d29cf5f5ab7d8a8d0b03b34f4b.
The separate evidence package records command arrays and all individual measurements.

Passed:

  • CPU/HIP/CUDA/SYCL builds for main and candidate. Server suite on each:
    python -B -m unittest discover -s serve -p 'test_*.py' -v, 1450 tests/17 skips, exit 0.

  • Qualified CPU CTest: main 88 passed/5 skipped; candidate 89/5. Full HIP CTest:
    main 211 passed/13 skipped, candidate 212/13, exit 0; numeric PLE/stock MMQ included.

  • ctest --test-dir "$QUALIFIED_DIR" --output-on-failure --timeout 180 -j1 --output-junit "$XML". Test-only ISA/copy/PLE supports and four scratch redirects
    are disclosed separately; no support patch enters this feature diff.

  • 24 numeric comparisons against main: unset/0/1 padding, default wave/fallback,
    TSUM0/1 and EXACT0/1. Output inventory, finite/nonzero/sentinel checks and equality pass.

  • 120 synthetic timing rows, three interleaved process repeats and five raw samples
    per process. Selected T=1 medians, padding0→1, microseconds:

    Kernel Default wave Forced fallback
    Q8 6144→2560 41.470→30.288 41.471→30.295
    Q8 2560→512, row 16 16.865→5.109 16.843→5.110
    BF16 2560→512 19.552→7.123 19.579→7.142
  • Independent readback exit 0; all owned windows restored, health ok/loaded,
    source/native/production invariants unchanged. Whitespace check exit 0, added lines ≤118.

Failed:

  • Stock CPU ISA checker fails identically on main/candidate; separate checker-only
    qualification passes. Initial read-only fixture-path and CRLF evidence-export
    harness failures are retained; the qualified readback did not replay GPU tests.
  • Not every timing row improves. Worst descriptive median MMVQ gain is −1.83%
    default-wave/−1.81% fallback, including unchanged T>1 controls. All individual
    repeats and variability are retained; these ranges are not confidence intervals.

Not run:

Local Metal build/runtime; NVIDIA, Intel Arc and Windows hardware execution;
whole-model token throughput or latency improvement; other gfx12 cards.

Limits

The measurements are synthetic kernels on one R9700. They do not establish an
end-to-end model speedup or justify enabling padding by default. The previous public
Metal CI ran on an older head. This updated head has its own build/link result below.

Published candidate and evidence

Head 9273f1bb04e5173b03826aae0ffd19b69a472f0f, parent 54828c7efbcdf9474697e70922d851f6707f4b32.

Reconstruct the SHA256-verified evidence ZIP.
ZIP SHA256: 4f795ed12c1091b6d9394c6e4e0935a1e19684d389fb8fa120abee8d9a7b8756. All three public raw files and decoded ZIP were read back exactly.

CI on the updated head

Head 9273f1bb04e5173b03826aae0ffd19b69a472f0f.

Metal CI compiled and linked the engine. It did not execute Metal inference or establish runtime GPU-kernel compilation/correctness. Local Metal hardware and the other Not run items above remain unavailable/unverified.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2492 **Author:** [@i-Vladimir-i](https://github.com/i-Vladimir-i) **Created:** 10/14/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `grid-pad` --- ### 📝 Commits (1) - [`9273f1b`](https://github.com/Niko1221/Strata/commit/9273f1bb04e5173b03826aae0ffd19b69a472f0f) [Codex]: add opt-in gfx12 grid padding for decode matvecs ### 📊 Changes **6 files changed** (+179 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+3 -0) 📝 `docs/AMD_HIP.md` (+9 -0) ➕ `include/strata/kernels/grid_pad.hpp` (+81 -0) 📝 `src/kernels/cuda/native_bf16.cu` (+5 -2) 📝 `src/kernels/cuda/native_mmvq.cu` (+31 -10) ➕ `src/kernels/grid_pad_test.cpp` (+50 -0) </details> ### 📄 Description ## Problem and result Selected T=1 decode matvec launches on gfx12 stall near full-die wave-slot boundaries. `STRATA_GRID_PAD=1` adds empty workgroups that return before indexing output rows. Padding remains off by default; T>1, CUDA and non-gfx12 launch geometry is unchanged. ## Related discussion This refreshes the existing #2492, without VMM, ISA, copy-stream or MCP changes. The current wave MMVQ path can bypass padded fallbacks, so default-wave and explicit `STRATA_MMVQ_WAVE=0` controls are reported separately. ## Approach Use a per-device gfx12 geometry check and a bounded padding rule for the selected single-token launchers. Extra blocks return before signed row indexing. Host tests cover stall boundaries, no-op multi-token cases, overflow bounds and idempotence. ## Validation Linux AMD Radeon AI PRO R9700/gfx1201; official GGML `3cf03257f219afbe7334045ff7c6a06ac68c627d`. Tested base `9f7d977d220e9fdf2ec53cf2620cdadac1cfb24e`, candidate tree `398c5ffedbe7162a7d8eb54f747e45c5b903463e`. Published base `54828c7e` only adds eight sponsor README files; the tested feature diff is byte-identical, SHA256 `5db2f0beca7cec0bd5184f29760cc5752144f9d29cf5f5ab7d8a8d0b03b34f4b`. The separate evidence package records command arrays and all individual measurements. **Passed:** - CPU/HIP/CUDA/SYCL builds for main and candidate. Server suite on each: `python -B -m unittest discover -s serve -p 'test_*.py' -v`, 1450 tests/17 skips, exit 0. - Qualified CPU CTest: main 88 passed/5 skipped; candidate 89/5. Full HIP CTest: main 211 passed/13 skipped, candidate 212/13, exit 0; numeric PLE/stock MMQ included. - `ctest --test-dir "$QUALIFIED_DIR" --output-on-failure --timeout 180 -j1 --output-junit "$XML"`. Test-only ISA/copy/PLE supports and four scratch redirects are disclosed separately; no support patch enters this feature diff. - 24 numeric comparisons against main: unset/0/1 padding, default wave/fallback, TSUM0/1 and EXACT0/1. Output inventory, finite/nonzero/sentinel checks and equality pass. - 120 synthetic timing rows, three interleaved process repeats and five raw samples per process. Selected T=1 medians, padding0→1, microseconds: | Kernel | Default wave | Forced fallback | | --- | --- | --- | | Q8 6144→2560 | 41.470→30.288 | 41.471→30.295 | | Q8 2560→512, row 16 | 16.865→5.109 | 16.843→5.110 | | BF16 2560→512 | 19.552→7.123 | 19.579→7.142 | - Independent readback exit 0; all owned windows restored, health ok/loaded, source/native/production invariants unchanged. Whitespace check exit 0, added lines ≤118. **Failed:** - Stock CPU ISA checker fails identically on main/candidate; separate checker-only qualification passes. Initial read-only fixture-path and CRLF evidence-export harness failures are retained; the qualified readback did not replay GPU tests. - Not every timing row improves. Worst descriptive median MMVQ gain is −1.83% default-wave/−1.81% fallback, including unchanged T>1 controls. All individual repeats and variability are retained; these ranges are not confidence intervals. **Not run:** Local Metal build/runtime; NVIDIA, Intel Arc and Windows hardware execution; whole-model token throughput or latency improvement; other gfx12 cards. ## Limits The measurements are synthetic kernels on one R9700. They do not establish an end-to-end model speedup or justify enabling padding by default. The previous public Metal CI ran on an older head. This updated head has its own build/link result below. ## Published candidate and evidence Head `9273f1bb04e5173b03826aae0ffd19b69a472f0f`, parent `54828c7efbcdf9474697e70922d851f6707f4b32`. [Reconstruct the SHA256-verified evidence ZIP](https://gist.github.com/i-Vladimir-i/2dfdbaf7e63c94a01020062fe3f5ed2a). ZIP SHA256: `4f795ed12c1091b6d9394c6e4e0935a1e19684d389fb8fa120abee8d9a7b8756`. All three public raw files and decoded ZIP were read back exactly. ## CI on the updated head Head `9273f1bb04e5173b03826aae0ffd19b69a472f0f`. - [Metal build/link](https://github.com/Niko1221/Strata/actions/runs/42300280600/job/128175957320): passed; the log contains the final engine link. - [Title area](https://github.com/Niko1221/Strata/actions/runs/42300403255/job/128176376797): passed. - [Intake check](https://github.com/Niko1221/Strata/actions/runs/42300403918/job/128176381562): passed. - Intake sweep: skipped by the workflow; no sweep result is claimed. Metal CI compiled and linked the engine. It did not execute Metal inference or establish runtime GPU-kernel compilation/correctness. Local Metal hardware and the other Not run items above remain unavailable/unverified. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4075
No description provided.