tilegym-improve-cutile-kernel-perf

작성자: nvidia

반복적인 프로파일링, 병목 분석, IR 비교 및 목표 지향적 튜닝을 통해 cuTile 커널 성능을 최적화합니다. 타일 크기, …를 다룹니다.

npx skills add https://github.com/nvidia/skills --skill tilegym-improve-cutile-kernel-perf

Iterative cuTile Kernel Performance Optimization

Systematically profile, diagnose bottlenecks, and iteratively tune a cuTile kernel's performance in the TileGym repository.

Instructions

Follow the three phases in order: Setup the environment and baseline, run the Experimentation loop with a tracked log, then iterate The experiment loop until perf goals are met or further gains plateau.

Setup

Work with user to prepare optimization environment:

  1. Create a fresh git branch: Propose a branch name, e.g., cutile-perf-<kernel_name>-<date> from current branch. Checkout git checkout -b <branch name>

  2. Locate the target kernel:

    • cuTile kernels live under src/tilegym/suites/<suite>/cutile/ or src/tilegym/ops/cutile/
    • Read the kernel file and identify: the @ct.kernel decorated function(s), the launch wrapper (ct.launch() or ct_experimental.autotune_launch()), the @register_impl registration, and current autotune configs (if any)
  3. Classify the kernel:

    • Arithmetic Intensity < 10 -> Memory-bound
    • Arithmetic Intensity 10-50 -> Balanced
    • Arithmetic Intensity > 50 -> Compute-bound

    Note: classification is only used to pick the optimization priority order in the experiment loop. The core metric is always latency (ms).

  4. Check GPU environment:

    • Ensure a GPU node (Blackwell or Ampere GPU) is available
    • All subsequent benchmark commands should run on the GPU node
  5. Study related references:

    • references/optimization-playbook.md: Step-by-step recipes for each optimization (A through J) with before/after code examples
    • references/perf-knobs-catalog.md: Complete catalog of all tunable parameters (TMA, persistent scheduling, occupancy, tile sizes, latency hints, etc.)
    • references/cutile-api-reference.md: cuTile API reference and 18 critical rules
    • references/performance-model.md: Roofline/performance model, bottleneck diagnosis, autotuning
    • references/ir-dump-guide.md: IR dump, analysis, and error diagnosis
    • references/cutile-patterns-reference.md: Common cuTile patterns and conversion quick-reference
  6. Create @sandbox/perf_results.md to track progress. The first run will write a baseline

  7. Confirm and go: Once you get confirmation, kick off the experimentation

Experimentation

Every experiment iteration applies ONE optimization to the target kernel, verifies correctness, re-benchmarks, and records results. Each iteration should be enforced to finish within 10 minutes.

The goal

  • Improve the core metric: reduce latency (ms)
  • Subject to the core constraint: Correctness shall not regress — every optimization MUST preserve numerical correctness. latency (ms) shall not regress > 2% compared to baseline.

What you can change

  • The target kernel file under src/tilegym/suites/<suite>/cutile/ or src/tilegym/ops/cutile/: kernel body, tile sizes, occupancy, num_ctas, TMA usage, latency hints, flush_to_zero, autotune configs, persistent scheduling, and other cuTile-specific parameters
  • The kernel's launch wrapper: grid computation, autotune config space
  • @sandbox/: Feel free to add new files or modify files created by you, but don't check to git

What you can NOT change

  • Kernel functional semantics (inputs, outputs, and numerical behavior within tolerance)
  • Test infrastructure and benchmark harness
  • Anything not listed above

What to expect from experiment outputs

Correctness test:

python -m pytest tests/suites/.../test_<kernel_name>.py -k "test_ and cutile and not test_perf" -v

Performance benchmark:

For each iteration:

  1. Run pytest benchmark: python -m pytest ... --print-record → extract latency (ms)
  2. Record latency in perf_results.md

Benchmark cmdlines:

python -m pytest tests/suites/.../test_<kernel_name>.py -k "test_perf and cutile" --print-record -v

latency sample:

Cutile: {'forward': {'mean': 3.7903138461538455, 'std': 0.0016941310873207053, 'rel_std': 0.044696327430505396, 'median': 3.789880999999999, 'min': 3.7883389999999992, 'max': 3.7941230000000004, 'nrep': 13, 'peak_mem_mb': 913}} ms

Track experiment progress

Use @sandbox/perf_results.md to record each iteration's results. It should only contain a Markdown table with 5 columns:

  • iteration: iteration number, starting from 0 (baseline)
  • optimization: what was applied (e.g., "baseline", "TMA replace gather", "persistent scheduling")
  • latency_ms: kernel latency in milliseconds, six decimal points
  • correctness: PASS or FAIL
  • status: Whether this iteration was keep, revert, or crash

Example content:

| iteration | optimization       | latency_ms | correctness | status |
|----------:|:-------------------|-----------:|:------------|-------:|
| 0         | baseline           |   0.820000 | PASS        | keep   |
| 1         | TMA replace gather |   0.390000 | PASS        | keep   |

Create the tabular header if the file was empty. Append one line for each iteration.

The baseline

The first iteration (iteration 0) will not change any code and simply run the correctness test and performance benchmark. Results will be listed at the first row as baseline.

The experiment loop

Core methodology is to apply ONE optimization per iteration from the playbook, verify correctness, benchmark, and decide whether to keep or revert. Try one optimization at a time, and have clean experiment records.

LOOP:

  1. Check git status: Current git branch/commit we're on

  2. Select and apply ONE optimization from references/optimization-playbook.md:

  3. Verify correctness — if fails, revert immediately. Common causes: flush_to_zero/rounding_mode=APPROX changed results, tile size OOB, allow_tma=False semantics, persistent loop bound error

  4. Re-benchmark and compare against current baseline

  5. Git commit

  6. Record results to @sandbox/perf_results.md

  7. Decision rules:

    OutcomeAction
    Improvement(latency (ms)) >= 5%Accept as new baseline, continue
    Improvement 2-5%Accept, lower priority for next iteration
    Improvement < 2%Accept but stop unless user wants more
    Regression on any configRevert immediately, try next optimization
    No improvement after 2 consecutive iterationsStop
    Root cause is scheduling or unknownEscalate to user
  8. If keeping, advance the baseline numbers and continue loop

  9. If reverting, git reset back to where you started and try the next optimization in priority order UNTIL: all attempts are finished, or more than 25 iterations have occurred, or the user interrupts

Be autonomous: Ask user clarifications at setup phase. Once stepped into the experiment loop, do not pause to ask user feedback: Use your best judgement for decision making, consult the optimization playbook and perf knobs catalog promptly, and think harder if stuck.

nvidia의 다른 스킬

compileiq-debug
nvidia
무언가 잘못되었을 때 사용: Search()가 멈추거나, 모든 평가가 INVALID_SCORE를 반환하거나, 점수가 개선되지 않거나, 모든 설정이 동일한 숫자를 반환하거나, ptxas 오류 등이 발생할 때
create-github-pr
nvidia
gh CLI를 사용하여 GitHub 풀 리퀘스트를 생성합니다. 사용자가 새 PR을 만들거나, 코드 리뷰를 제출하거나, 풀 리퀘스트를 열고자 할 때 사용합니다. 트리거 키워드 -…
nemoclaw-maintainer-cross-issue-sweep
nvidia
다른 열린 이슈들을 스캔하여 주어진 PR이 함께 수정하거나 실수로 망가뜨릴 수 있는 이슈를 찾습니다. 인접 수정 기회와 모순 위험을 file:line…과 함께 출력합니다.
fhir-basics
nvidia
에이전트에게 FHIR R4 API의 작동 방식, 사용 가능한 리소스, 검색 매개변수를 사용한 쿼리 방법, 모든 응답 형식을 올바르게 파싱하는 방법을 가르칩니다…
compileiq-validate-result
nvidia
검색이 완료된 후, 속도 향상을 청구하거나 ACF를 발송하기 전에 사용합니다. dump_results CSV를 로드하고, 상위 K개 후보(단일 목표)를 추출합니다…
changelog-audit
nvidia
릴리스 전에 Warp CHANGELOG.md를 감사합니다: 누락된 항목 복구, 사용자 영향별 정렬, 항목 언어 다듬기, 줄 바꿈, (릴리스 브랜치 모드) 비교 업데이트…
maintain-dynamic-plugins
nvidia
NeMo Relay 동적 플러그인 로더, 매니페스트, Rust 네이티브 SDK, gRPC 워커 프로토콜, Python 워커 SDK, 문서, 테스트 및 릴리스 워크플로 커버리지를 유지 관리합니다.
dgx-diagnose
nvidia
일반적인 DGX Station GB300 문제 진단 — CUDA 충돌, 잘못된 GPU 타겟팅, vLLM/SGLang 컨테이너 버그, MIG 상태 문제, NVLink/Fabric Manager 오류,…