Skip to content

optimze-elect-one-compilation-hint - #504

Merged
yanqinz2 merged 1 commit into
NVIDIA:developfrom
yanqinz2:blackwell-gemm-inference-optimization
Aug 7, 2026
Merged

optimze-elect-one-compilation-hint#504
yanqinz2 merged 1 commit into
NVIDIA:developfrom
yanqinz2:blackwell-gemm-inference-optimization

Conversation

@yanqinz2

@yanqinz2 yanqinz2 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Before submitting

  • I agree to license this contribution under the terms of LICENSE.txt.
  • I ran pre-commit run and committed any formatting changes.
  • I added GitHub labels: one cat-*, one or more mod-*, and one orig-* (see label list).

Affected area

Summary

Remove repeated elect_sync call to optimize the compilation to avoid BSSY/BSYNC emission

Related issues

Non-optimal perf for small inference cases

API and compatibility impact

Testing

Summary by CodeRabbit

  • Performance Improvements
    • Improved GPU kernel efficiency by reducing redundant thread-election operations across matrix multiplication and grouped computation workloads.
    • Preserved existing synchronization, data movement, and computation behavior while streamlining execution.
    • Improved blocked scale-factor handling for padded matrix dimensions.
    • Enhanced diagnostic reporting when reference scaled matrix multiplication is unavailable or fails.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1e17ee66-02ee-4531-9ae0-f990c0fda148

📥 Commits

Reviewing files that changed from the base of the PR and between ab9efe1 and cbdc296.

📒 Files selected for processing (18)
  • benchmark/gemm/frost/benchmark_block_scale_matmul.py
  • benchmark/gemm/frost/benchmark_block_scale_matmul_swiglu.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_block_scale_matmul_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_block_scale_matmul_1ctamma_static.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_block_scale_matmul_2ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_block_scale_matmul_2ctamma_static.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_1ctamma_static.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_2ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_2ctamma_static.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_mainloop_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_matmul_mainloop_2ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_moe_grouped_block_scale_matmul_fwd_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_moe_grouped_block_scale_matmul_fwd_2ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_moe_grouped_matmul_fwd_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm100_moe_grouped_matmul_fwd_2ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm103_block_scale_matmul_1ctamma.py
  • python/cudnn/gemm/frost/kernel_templates/sm103_block_scale_matmul_2ctamma.py

📝 Walkthrough

Walkthrough

The changes update blocked-scale benchmark shape handling and reference diagnostics. They also replace repeated nvvm.elect_sync() calls across FROST GEMM, block-scale GEMM, and MoE kernel templates with cached election predicates.

Changes

FROST kernel and benchmark updates

Layer / File(s) Summary
Blocked scale reference preparation
benchmark/gemm/frost/benchmark_block_scale_matmul.py, benchmark/gemm/frost/benchmark_block_scale_matmul_swiglu.py
Reference and SwiGLU scale tensors now use padded blocked-layout dimensions. The reference path uses separate swizzles, forwards verbosity, and reports explicit scaled_mm failures.
SM100 and SM103 election reuse
python/cudnn/gemm/frost/kernel_templates/sm100_*, python/cudnn/gemm/frost/kernel_templates/sm103_*
Kernel templates compute elect_one once and reuse it for barrier, TMA, MMA, PDL, CLC, and epilogue operations.
MoE election reuse
python/cudnn/gemm/frost/kernel_templates/sm100_moe_*
Grouped MoE kernels reuse one elected-thread predicate across data transfers, tensor-memory operations, scheduler signaling, synchronization, and epilogues.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested labels: cat-feature, orig-nv-eng, mod-cutedsl, mod-frost

Suggested reviewers: anerudhan

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes the summary and motivation but leaves the affected area, API impact, and testing details incomplete. Select the affected area, state the API and compatibility impact, and provide exact testing commands with results or explain why testing was not performed.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the elect-one compilation optimization, which matches the main change despite a spelling error and awkward phrasing.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@Adnios Adnios added orig-nv-eng Reported or requested by NVIDIA engineering. cat-perf-bug Performance regressions or cases where behavior is correct but too slow. mod-frost labels Aug 7, 2026
@Anerudhan Anerudhan added this to the Frontend 1.28.0 milestone Aug 7, 2026
@Anerudhan

Copy link
Copy Markdown
Collaborator

@cudnn-ci-bot run frost

@cudnn-ci-bot

Copy link
Copy Markdown

🚀 Running mirror pipeline

Branch: cudnn-gh/pr-504-cbdc296
Pipeline: 61530048
Targets: frost

@yanqinz2
yanqinz2 merged commit ad6f8ba into NVIDIA:develop Aug 7, 2026
1 check passed
@yanqinz2
yanqinz2 deleted the blackwell-gemm-inference-optimization branch August 7, 2026 18:04
@coderabbitai coderabbitai Bot mentioned this pull request Aug 7, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cat-perf-bug Performance regressions or cases where behavior is correct but too slow. mod-frost orig-nv-eng Reported or requested by NVIDIA engineering.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants