@@ -104,8 +104,18 @@ Key constraints to keep in mind:
104104## Testing and correctness
105105
106106``` bash
107+ # Run all tests
107108uv run pytest -q
108- uv run pytest tests/test_copy_transpose.py::test_copy_transpose_correctness -k " float16"
109+
110+ # Run specific test file
111+ uv run pytest tests/test_copy_transpose.py
112+
113+ # Run specific test function
114+ uv run pytest tests/test_copy_transpose.py::test_copy_transpose_correctness
115+
116+ # Filter tests by name pattern with -k (matches test function names)
117+ uv run pytest tests/test_softmax_online.py -k correctness
118+ uv run pytest -k " not correctness and not compile"
109119```
110120
111121Correctness is the primary gate. Use explicit tolerances and document any
@@ -131,6 +141,48 @@ Add new benchmark cases to `bench/suites.yaml` and keep outputs reproducible.
131141Nsight Compute with ` --set full ` can be slow; use lighter sets if needed
132142(` --set=launchstats ` , ` --section=SpeedOfLight ` , etc.).
133143
144+ ### Metric extraction
145+
146+ Extract curated metrics from NCU reports using the ` --extract ` flag or standalone:
147+
148+ ``` bash
149+ # Automatic extraction after profiling
150+ ./scripts/profile.sh ncu --extract -- uv run python bench/benchmark_copy_transpose.py
151+
152+ # Standalone extraction from existing report
153+ ./scripts/ncu_extract.py profiles/ncu_* .ncu-rep
154+
155+ # JSON output
156+ ./scripts/ncu_extract.py profiles/ncu_* .ncu-rep --json
157+
158+ # Filter by kernel name
159+ ./scripts/ncu_extract.py profiles/ncu_* .ncu-rep --kernel " CopyTranspose"
160+ ```
161+
162+ Output includes three metric categories:
163+ - ** GPU Throughput** : Memory and Compute (SM) utilization percentages
164+ - ** Pipe Utilization** : Tensor Core, FMA, ALU activity
165+ - ** Warp Stalls** : Long scoreboard, barrier, memory throttle stalls
166+
167+ ### Profiling tips
168+
169+ ** For NCU profiling** , use minimal iterations since you're analyzing kernel behavior, not
170+ timing variance. The L2 cache flush adds extra kernel launches per iteration.
171+
172+ ``` bash
173+ # Fast profiling (recommended)
174+ ./scripts/profile.sh ncu --extract -- uv run python bench/benchmark_copy_transpose.py --warmup 2 --iterations 1
175+
176+ # Profile only your kernel (skip reference kernels)
177+ ./scripts/profile.sh ncu --kernel-name " copy_transpose" --extract -- uv run python bench/benchmark_copy_transpose.py
178+ ```
179+
180+ | Goal | Warmup | Iterations | Notes |
181+ | ------| --------| ------------| -------|
182+ | Timing benchmarks | 10 | 100 | Default, good for stable p50/p90 |
183+ | Quick profiling | 2 | 1-3 | Sufficient for kernel analysis |
184+ | Deep profiling (` --set full ` ) | 1 | 1 | Full metrics are slow |
185+
134186## Linting and formatting
135187
136188``` bash
0 commit comments