Skip to content

[inductor][NVGEMM] Use direct CuTeDSL lowering for dense epilogues - #191515

Closed
mlazos wants to merge 46 commits into
gh/mlazos/280/basefrom
gh/mlazos/280/head
Closed

mlazos wants to merge 46 commits into
gh/mlazos/280/basefrom
gh/mlazos/280/head

Conversation

@mlazos

@mlazos mlazos commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Enable shared Loop IR to CuTeDSL lowering for dense NVGEMM epilogues. The
scheduler selects generated CuTeDSL source when the complete captured
expression is supported and retains CUTLASS EVT lowering as the fallback.

Preserve captured input dtypes and broadcast layouts, compose bias through
the same epilogue plan, reuse common subexpressions, and reject unsupported
operand swaps or reduction layouts before selecting the direct path.

Example

result = (a @ b).float()
return torch.relu(result), result + bias

Both stores are generated from one captured Loop IR program. Expressions that
cannot be represented by the direct path continue through EVT.

Test Plan

PYTORCH_WORKTREE=$PWD env -u PYTHONPATH python agent_space/run_worktree_python.py test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
lintrunner -a

Description drafted with an AI assistant.

cc @albanD @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @ipiszy @kadeng @muchulee8 @amjames @chauhang @aakhundov @coconutruben @jataylo

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/191515

Note: Links to docs will display an error until the docs builds have been completed.

✅ You can merge normally! (1 Unrelated Failure)

As of commit 2eea81a with merge base 3ee461f (image):

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

mlazos added a commit that referenced this pull request Jul 29, 2026
Enable the shared loop-body-to-CuTeDSL lowering for dense NVGEMM providers now
that the vendored EFC implementation accepts its fragments. Bias-only addmm
epilogues use the same direct argument contract, while unsupported expressions
retain the existing EVT fallback.

Update source assertions to verify that dense pointwise, multi-store, dynamic,
and broadcast epilogues select the direct path.

Test Plan:

```text
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_swap_ab_captured_epilogue -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k flex_gemm_baddbmm_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_reduce_supports_post_reduction_pointwise TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_supports_post_reduction_pointwise -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_flex_gemm.py -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_cutedsl_template.py -v
lintrunner -a
```

Authored with an AI assistant.


ghstack-source-id: 90384f3
Pull-Request: #191515
[ghstack-poisoned]
mlazos added a commit that referenced this pull request Jul 29, 2026
Enable the shared loop-body-to-CuTeDSL lowering for dense NVGEMM providers now
that the vendored EFC implementation accepts its fragments. Bias-only addmm
epilogues use the same direct argument contract, while unsupported expressions
retain the existing EVT fallback.

Update source assertions to verify that dense pointwise, multi-store, dynamic,
and broadcast epilogues select the direct path.

Test Plan:

```text
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_swap_ab_captured_epilogue -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k flex_gemm_baddbmm_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_reduce_supports_post_reduction_pointwise TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_supports_post_reduction_pointwise -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_flex_gemm.py -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_cutedsl_template.py -v
lintrunner -a
```

Authored with an AI assistant.


ghstack-source-id: 31fb04f
Pull-Request: #191515
[ghstack-poisoned]
mlazos added a commit that referenced this pull request Jul 29, 2026
Enable the shared loop-body-to-CuTeDSL lowering for dense NVGEMM providers now
that the vendored EFC implementation accepts its fragments. Bias-only addmm
epilogues use the same direct argument contract, while unsupported expressions
retain the existing EVT fallback.

Update source assertions to verify that dense pointwise, multi-store, dynamic,
and broadcast epilogues select the direct path.

Test Plan:

```text
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_swap_ab_captured_epilogue -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k flex_gemm_baddbmm_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_reduce_supports_post_reduction_pointwise TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_supports_post_reduction_pointwise -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_flex_gemm.py -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_cutedsl_template.py -v
lintrunner -a
```

Authored with an AI assistant.


ghstack-source-id: cdceef3
Pull-Request: #191515
@mlazos

mlazos commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor Author

AI-Review

Automated multi-agent review (2 Claude + 2 Codex + GPT-5.6 verification). This is AI-generated — please verify findings manually.


Verified Issues

  • [medium] Swapped MTB choice with a fused reduction crashes at runtime — Location: nv_universal_gemm_scheduling.py:126-133,358-361; nv_universal_gemm_kernel.py:891-898. Trigger: enable nvgemm_swap_ab, disable benchmark_epilogue_fusion, and compile a 2D GEMM with a grouped-reduction epilogue where a swapped NVGEMM choice wins. Failure sequence: the unfinalized MultiTemplateBuffer has _render_caller=None, so _uses_swap_ab() misses the swapped choice and permits fusion; later autotuning selects that choice without executing it; the first model execution reaches _nvgemm_run() with both swap_ab and an enabled local reduction and raises NotImplementedError. Impact: the compiled model crashes instead of falling back to a supported choice. Reviewers: Claude Bug Review, Codex Bug Review.

[ghstack-poisoned]
mlazos added a commit that referenced this pull request Jul 29, 2026
Enable the shared loop-body-to-CuTeDSL lowering for dense NVGEMM providers now
that the vendored EFC implementation accepts its fragments. Bias-only addmm
epilogues use the same direct argument contract, while unsupported expressions
retain the existing EVT fallback.

Update source assertions to verify that dense pointwise, multi-store, dynamic,
and broadcast epilogues select the direct path.

Test Plan:

```text
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_swap_ab_captured_epilogue -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k flex_gemm_baddbmm_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_reduce_supports_post_reduction_pointwise TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_supports_post_reduction_pointwise -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_flex_gemm.py -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_cutedsl_template.py -v
lintrunner -a
```

Authored with an AI assistant.


ghstack-source-id: fa1e89e
Pull-Request: #191515
@mlazos
mlazos requested a review from drisspg July 29, 2026 21:30
[ghstack-poisoned]
mlazos added a commit that referenced this pull request Jul 30, 2026
Enable the shared loop-body-to-CuTeDSL lowering for dense NVGEMM providers now
that the vendored EFC implementation accepts its fragments. Bias-only addmm
epilogues use the same direct argument contract, while unsupported expressions
retain the existing EVT fallback.

Update source assertions to verify that dense pointwise, multi-store, dynamic,
and broadcast epilogues select the direct path.

Test Plan:

```text
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k matmul_swap_ab_captured_epilogue -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py -k flex_gemm_baddbmm_pointwise_epilogue_fusion -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_reduce_supports_post_reduction_pointwise TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_supports_post_reduction_pointwise -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_flex_gemm.py -v
CUDA_VISIBLE_DEVICES=0 TORCHINDUCTOR_COMPILE_THREADS=1 python test/inductor/test_cutedsl_template.py -v
lintrunner -a
```

Authored with an AI assistant.

ghstack-source-id: 9e8dcdb
Pull-Request: #191515
[ghstack-poisoned]
[ghstack-poisoned]
mlazos added 2 commits August 28, 2026 14:08
[ghstack-poisoned]
[ghstack-poisoned]
mlazos added 2 commits August 28, 2026 19:08
[ghstack-poisoned]
[ghstack-poisoned]
mlazos added 2 commits August 31, 2026 21:56
[ghstack-poisoned]
[ghstack-poisoned]
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #192928

1 similar comment
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Starting merge as part of PR stack under #192928

pytorchmergebot pushed a commit that referenced this pull request Sep 2, 2026
> Add focused parity coverage for generated CuTeDSL callbacks across dense and
> block-scaled grouped reductions. The tests cover both reduction axes,
> primitive and pointwise-transformed sources, multiple reductions in one
> epilogue, reduction consumers, and finalization after cross-warp combination.
>
> Keep the transposed output layout explicit when NVGEMM swaps the GEMM operands.
> Let FlexGEMM request the broader tuned NVGEMM configuration while rejecting
> unsupported NVGEMM options.
>
> ## Test Plan
>
> ```bash
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmHeuristics -v
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_finalizes_after_cross_warp_combine TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_composite_reduction_fusion TestNVUniversalGemmEpilogueFusion.test_scaled_mm_grouped_n_composite_reduction_fusion TestNVUniversalGemmEpilogueFusion.test_scaled_mm_grouped_m_reduce_finalizes_after_cross_warp_combine -v
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_reduce_epilogue_fusion_axis_1_group_4_sum TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_reduce_epilogue_fusion_axis_0_group_64_abs_amax TestNVUniversalGemmEpilogueFusion.test_flex_gemm_grouped_n_reduce_epilogue_fusion_feeds_main_True -v
> lintrunner -a
> ```
>
> Description drafted with an AI assistant.

Pull Request resolved: #190825
Approved by: https://github.com/karthickai
ghstack dependencies: #192298, #190822, #191514, #191515
pytorchmergebot pushed a commit that referenced this pull request Sep 2, 2026
doesn't run hese tests in fbcode until we add operator API internally

> This skips two low-level tests only in fbcode because fbcode does not include
> the optional CUTLASS package those tests use to construct and run kernel
> objects directly. The tests fail while importing or creating the operator,
> before they exercise the NVGEMM behavior they are intended to check.
>
> The tests still run in the open-source build, and the higher-level
> `torch.compile` tests remain enabled in fbcode.
>
> ## Architecture
>
> This is a test-only environment boundary. The two tests that directly import
> the optional CUTLASS Operator API are skipped individually when `IS_FBCODE` is
> true. No production lowering, provider registration, or generated-kernel
> behavior changes. The tests continue running in open source, while fbcode
> retains the higher-level compiler coverage.
>
> ## Example
>
> The affected tests directly compile a grouped-reduction provider and a
> unit-dimension epilogue on a non-current CUDA stream. In fbcode, the required
> operator-construction API is absent, so skipping those two tests avoids
> reporting an environment limitation as an NVGEMM correctness failure.
>
>
> ```python
> @unittest.skipIf(
>     IS_FBCODE,
>     "CUTLASS Operator API is not available in fbcode",
> )
> def test_scaled_gemm_grouped_n_reduce_provider(self):
>     ...
> ```
>
> ## Test Plan
>
> ```bash
> PYTORCH_TEST_FBCODE=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemm.test_scaled_gemm_grouped_n_reduce_provider TestNVUniversalGemm.test_scaled_gemm_unit_dim_epilogue_non_current_stream -v
> python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemm.test_scaled_gemm_grouped_n_reduce_provider TestNVUniversalGemm.test_scaled_gemm_unit_dim_epilogue_non_current_stream -v
> lintrunner -a
> ```
>
> Description drafted with an AI assistant.

Pull Request resolved: #192928
Approved by: https://github.com/karthickai
ghstack dependencies: #192298, #190822, #191514, #191515, #190825
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
…ytorch#191515)

> Enable shared Loop IR to CuTeDSL lowering for dense NVGEMM epilogues. The
> scheduler selects generated CuTeDSL source when the complete captured
> expression is supported and retains CUTLASS EVT lowering as the fallback.
>
> Preserve captured input dtypes and broadcast layouts, compose bias through
> the same epilogue plan, reuse common subexpressions, and reject unsupported
> operand swaps or reduction layouts before selecting the direct path.
>
> ## Example
>
> ```python
> result = (a @ b).float()
> return torch.relu(result), result + bias
> ```
>
> Both stores are generated from one captured Loop IR program. Expressions that
> cannot be represented by the direct path continue through EVT.
>
> ## Test Plan
>
> ```bash
> PYTORCH_WORKTREE=$PWD env -u PYTHONPATH python agent_space/run_worktree_python.py test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_matmul_multi_store_epilogue_fusion -v
> lintrunner -a
> ```
>
> Description drafted with an AI assistant.

Pull Request resolved: pytorch#191515
Approved by: https://github.com/drisspg
ghstack dependencies: pytorch#192298, pytorch#190822, pytorch#191514
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
> Add focused parity coverage for generated CuTeDSL callbacks across dense and
> block-scaled grouped reductions. The tests cover both reduction axes,
> primitive and pointwise-transformed sources, multiple reductions in one
> epilogue, reduction consumers, and finalization after cross-warp combination.
>
> Keep the transposed output layout explicit when NVGEMM swaps the GEMM operands.
> Let FlexGEMM request the broader tuned NVGEMM configuration while rejecting
> unsupported NVGEMM options.
>
> ## Test Plan
>
> ```bash
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmHeuristics -v
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_m_reduce_finalizes_after_cross_warp_combine TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_n_composite_reduction_fusion TestNVUniversalGemmEpilogueFusion.test_scaled_mm_grouped_n_composite_reduction_fusion TestNVUniversalGemmEpilogueFusion.test_scaled_mm_grouped_m_reduce_finalizes_after_cross_warp_combine -v
> PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_reduce_epilogue_fusion_axis_1_group_4_sum TestNVUniversalGemmEpilogueFusion.test_bf16_grouped_reduce_epilogue_fusion_axis_0_group_64_abs_amax TestNVUniversalGemmEpilogueFusion.test_flex_gemm_grouped_n_reduce_epilogue_fusion_feeds_main_True -v
> lintrunner -a
> ```
>
> Description drafted with an AI assistant.

Pull Request resolved: pytorch#190825
Approved by: https://github.com/karthickai
ghstack dependencies: pytorch#192298, pytorch#190822, pytorch#191514, pytorch#191515
Sanskaaar1 pushed a commit to Sanskaaar1/pytorch that referenced this pull request Sep 8, 2026
doesn't run hese tests in fbcode until we add operator API internally

> This skips two low-level tests only in fbcode because fbcode does not include
> the optional CUTLASS package those tests use to construct and run kernel
> objects directly. The tests fail while importing or creating the operator,
> before they exercise the NVGEMM behavior they are intended to check.
>
> The tests still run in the open-source build, and the higher-level
> `torch.compile` tests remain enabled in fbcode.
>
> ## Architecture
>
> This is a test-only environment boundary. The two tests that directly import
> the optional CUTLASS Operator API are skipped individually when `IS_FBCODE` is
> true. No production lowering, provider registration, or generated-kernel
> behavior changes. The tests continue running in open source, while fbcode
> retains the higher-level compiler coverage.
>
> ## Example
>
> The affected tests directly compile a grouped-reduction provider and a
> unit-dimension epilogue on a non-current CUDA stream. In fbcode, the required
> operator-construction API is absent, so skipping those two tests avoids
> reporting an environment limitation as an NVGEMM correctness failure.
>
>
> ```python
> @unittest.skipIf(
>     IS_FBCODE,
>     "CUTLASS Operator API is not available in fbcode",
> )
> def test_scaled_gemm_grouped_n_reduce_provider(self):
>     ...
> ```
>
> ## Test Plan
>
> ```bash
> PYTORCH_TEST_FBCODE=1 python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemm.test_scaled_gemm_grouped_n_reduce_provider TestNVUniversalGemm.test_scaled_gemm_unit_dim_epilogue_non_current_stream -v
> python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemm.test_scaled_gemm_grouped_n_reduce_provider TestNVUniversalGemm.test_scaled_gemm_unit_dim_epilogue_non_current_stream -v
> lintrunner -a
> ```
>
> Description drafted with an AI assistant.

Pull Request resolved: pytorch#192928
Approved by: https://github.com/karthickai
ghstack dependencies: pytorch#192298, pytorch#190822, pytorch#191514, pytorch#191515, pytorch#190825
pytorchmergebot pushed a commit that referenced this pull request Sep 10, 2026
Orient generated reduction geometry, output layouts, and runtime tensors when NVGEMM swaps GEMM operands. Dense and block-scaled epilogues continue to use the shared generated source, combine, and finalizer callbacks.

Keep the kernel reduction mechanism unchanged. Candidate validation filters physical tile layouts that cross CTA or warp ownership, leaving valid configurations in the normal autotuning set and falling back safely when a layout cannot implement the reduction.

## Test Plan

```bash
PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py -k swap_ab
PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py -k grouped_reduce
spin quicklint
lintrunner -a
```

Authored with an AI assistant.

Pull Request resolved: #195538
Approved by: https://github.com/karthickai
ghstack dependencies: #192298, #190822, #191514, #191515, #190825, #192928
pytorchmergebot pushed a commit that referenced this pull request Sep 10, 2026
Generate vendored dense EFC variants for the validated SM100 N-tile widths through 256, including 160, 192, and 224. This makes the configurations available to nvMatmulHeuristics without retaining them unconditionally.

Keep the existing supplemented benchmark space unchanged. Wider candidates enter autotuning only when nvMatmulHeuristics selects them, avoiding additional profiling by default.

## Test Plan

```bash
PYTHONPATH=/data/users/mlazos/pytorch/agent_space/runtime_overlay PYTORCH_BOUNDARY_ROOT=$PWD python test/inductor/test_nv_universal_gemm.py TestNVUniversalGemm.test_vendored_dense_efc_exposes_wide_n_tiles -v
lintrunner -a
```

Authored with an AI assistant.

Pull Request resolved: #195539
Approved by: https://github.com/karthickai
ghstack dependencies: #192298, #190822, #191514, #191515, #190825, #192928, #195538
@github-actions
github-actions Bot deleted the gh/mlazos/280/head branch November 14, 2026 01:42
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.

3 participants