Skip to content

feat(09): in-kernel SM profiler + CuTe DSL line-info & ncu profiling - #22

Merged
ArthurinRUC merged 2 commits into
mainfrom
feat/cutedsl-09-inkernel-profile
Jun 8, 2026
Merged

feat(09): in-kernel SM profiler + CuTe DSL line-info & ncu profiling#22
ArthurinRUC merged 2 commits into
mainfrom
feat/cutedsl-09-inkernel-profile

Conversation

@ArthurinRUC

Copy link
Copy Markdown
Owner

What

Two pieces of work on the 09 CuTe DSL track.

1. In-kernel SM timeline profiler (e00197a)

  • cutedsl_sm_profiler.py — reusable, kernel-agnostic in-kernel profiler: per-(block,warp) append buffer, %globaltimer range events, Perfetto export. Callers register their own event types and close events by type (event_end(PROF_X)) via a compile-time open-id map (zero runtime cost); a fused event_switch shares one timer read at adjacent boundaries.
  • cutedsl_pipelining_profiled.py — the pipelining GEMM instrumented with it, compile-time gated so the production kernel is unchanged when profiling is off (kept diff-aligned with cutedsl_pipelining.py).
  • Hot-path overhead halved: 721 → 360 ns/k-tile on B200. The decisive optimization is per-warp counter cache-line padding, which eliminates cross-warp false sharing on the append-counter RMW. Streaming-store (.cs) and smem-counter variants were ablated on G5 and found neutral-or-worse (376 / 414 ns/k-tile), so they were removed — only the optimal implementation remains. Verified RE 0.01% with a stable Perfetto slice count throughout.

2. line-info + ncu profiling across all CuTe DSL impls (74ef8e1)

  • Added --generate-line-info to every cutedsl_*.py cute.compile, so Nsight Compute can map SASS back to the Python source (use with ncu --import-source yes).
  • Each chapter's profile.sh now profiles the CuTe DSL implementation: the old C++/reference ncu line is commented out and a CuTe DSL one is added, e.g. ncu -o ncu_prof_9 --import-source 1 --set full --kernel-name "regex:.*pipelining.*" -f python cutedsl_pipelining.py (10-gemm-api has no CuTe DSL impl, left as-is).

Verification

All cutedsl_*.py py_compile clean; the profiler path validated on G5/B200 (RE 0.01%, 1081344 Perfetto slices, 360 ns/k-tile).

🤖 Generated with Claude Code

ArthurinRUC and others added 2 commits June 8, 2026 15:21
Reusable, kernel-agnostic in-kernel profiler (cutedsl_sm_profiler.py) plus a profiled pipelining GEMM (cutedsl_pipelining_profiled.py): %globaltimer-stamped phase/per-tile events exported as a Perfetto trace, gated by a compile-time flag so the production kernel is unchanged when profiling is off.

Hot-path overhead cut ~50% (721 -> 360 ns/k-tile on B200) by per-warp counter cache-line padding (eliminates cross-warp false sharing); type-keyed event pairing via a compile-time open-id map (zero runtime cost) and a fused event_switch. Verified RE 0.01% with stable Perfetto slice count.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…dsl in profile.sh

Add --generate-line-info to every cutedsl_*.py cute.compile so Nsight Compute can map SASS back to the Python source (pair with ncu --import-source yes). Each profile.sh now comments out the C++/reference ncu command and adds a CuTe DSL one targeting cutedsl_<stem>.py via --kernel-name regex:.*<stem>.*.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ArthurinRUC
ArthurinRUC merged commit 5515af5 into main Jun 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant