Repository navigation
fix(tensilelite): infer StreamKNoBatch for StreamK custom kernels without an explicit grid - #13361
Merged
Merged
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
talumbau
self-requested a review
October 8, 2026 21:25
talumbau
requested changes
Oct 8, 2026
talumbau
left a comment
Collaborator
There was a problem hiding this comment.
Please add a test that would fail on this situation in the future.
Contributor
Author
Added root cause to the PR description. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #13361 +/- ##
===========================================
+ Coverage 71.86% 71.91% +0.05%
===========================================
Files 2876 2876
Lines 475301 474734 -567
Branches 70235 70221 -14
===========================================
- Hits 341564 341399 -165
+ Misses 109956 109557 -399
+ Partials 23781 23778 -3
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
talumbau
approved these changes
Oct 9, 2026
…clusive Stream-K grid
Add a unit test that the three SK3 gfx950 custom kernels infer a StreamKNoBatch grid, and a gfx950 gtest for the batch-1492 TF32 NN shape that overflowed the 32-bit global work size. Co-authored-by: Cursor <cursoragent@cursor.com>
yenong-amd
force-pushed
the
users/yenong-amd/change-custom-kernel-batch
branch
from
October 9, 2026 17:18
266af80 to
509d0a8
Compare
…hout an explicit grid The host's Stream-K grid already counts every batch's tiles, so inferring StreamKWithBatch for batched problems launched sk.grid * batch work groups and overflowed the 32-bit global work size for the SK3 gfx950 TF32 kernels. Infer StreamKNoBatch regardless of Batched, and restore Batched: True in the three SK3 custom.config blocks and in custom_xfp32.yaml so the benchmark problem type matches the kernels again. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
TheRock Submodule Bump ActivityNewest first
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: #13361
Motivation
Batched TF32 GEMMs that select the handwritten SK3 gfx950 custom kernels fail to launch:
Reproducer (MI350X): f32 in/out, compute
xf32_r, NN, M=256 N=1856 K=320, batch_count=1492.Root cause
These three custom kernels carry no explicit
CustomKernel.grid, soCustomKernels.pyinfers one. ForStreamK kernels it picked the grid from
ProblemType.Batched:Batched: TruestampedStreamKWithBatch.On the custom-kernel launch path (
generateCustomCall),StreamKWithBatchlaunchessk.grid * tiles.z.sk.gridalready includes the batch:resolveStreamKSettingscounts tiles asx * y * z, and Origamisizes the grid against
problem.batch. Multiplying bytiles.zapplies the batch twice:The kernels' assembly expects the batch-inclusive count.
StreamKIdx = WorkGroup0, the SKGrid kernarg,TotalIters, and the per-WG split all form one flat problem-wide space, and the batch index is recoveredfrom the tile ID via
NumWorkGroups0 * NumWorkGroups1. The extra* tiles.zonly inflates the launch.Technical details
CustomKernels._buildCustomKernelFromMetadatanow infersStreamKNoBatchfor every StreamK custom kernelthat has no explicit grid, regardless of
Batched.StreamKNoBatchlaunchessk.gridworkgroups, whichmatches what the assembly computes.
custom.confighas noCustomKernel.grid. Today that is exactlythe three SK3 gfx950 kernels:
Custom_Cijk_Ailk_Bljk_S_MX_B_BIAS_HA_S_SAV_NTD_SK3_UserArgs_MT256x256x32_MI16x16x1_shortname0_gfx950.sCustom_Cijk_Ailk_Bjlk_S_MX_B_BIAS_HA_S_SAV_NTD_SK3_UserArgs_MT256x256x32_MI16x16x1_shortname0_gfx950.sCustom_Cijk_Alik_Bljk_S_MX_B_BIAS_HA_S_SAV_NTD_SK3_UserArgs_MT256x256x32_MI16x16x1_shortname0_gfx950.sStreamKWithBatchexplicitly (c_tensile_sk_Cijk_Ailk_Bjlk_HHS_BH_UserArgs_MT128x256x64_MI16x16x1.s,Tests/custom/custom_tensile_sk.yaml) keep it, andgenerateCustomCallis unchanged..sfiles keepBatched: True, so theircustom.configproblem type still matches the batchedproblems they serve. No assembly, host code, or logic YAML changes.
An earlier revision of this PR set
Batched: Falsein the three.sfiles instead. That broke the Tensilebenchmark flow:
custom_xfp32.yamlfailed the problem-type match against the kernels, and switching the testto non-batched exposed an unrelated
id2codegen bug inKernelWriterConversion.py. The current revisionreverts both and makes the fix in the inference.
Tests added
test_CustomKernelMetadata.pytest_build_from_metadata_streamk_grid_excludes_batch: replaces the test that expectedStreamKWithBatch.It now expects
StreamKNoBatchforBatchedtrue and false.test_sk3_tf32_custom_kernel_launches_batch_inclusive_grid: asserts the three bundled SK3 kernels inferStreamKNoBatch.clients/tests/data/matmul_gtest.yaml:matmul_tf32_streamk_custom_large_batch(gfx950,pre_checkin),the batch-1492 NN reproducer with
norm_check.Test plan
tensilelitePython unit tests (tensilelite/Tests/unit).tox -e py3 -- -k custom_xfp32on gfx950, which builds and benchmarks all three SK3 kernels.hipblaslt-bench --verify, and runhipblaslt-test --gtest_filter='*tf32_streamk_custom_large_batch*'.Test result
custom_xfp32.yaml: passed.norm_error0.00570796 with--verify(hpl init, summed per-batch relative Frobenius error over 1492 batches, about 3.8e-6 per batch).matmul_tf32_streamk_custom_large_batch: passed.Submission Checklist