Skip to content

Residency is measured, and cuBLASLt's configuration is read (#80) - #85

Merged
feitreim merged 1 commit into
mainfrom
80-residency
Aug 5, 2026
Merged

feitreim merged 1 commit into
mainfrom
80-residency

Conversation

@feitreim

@feitreim feitreim commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Two instruments and no kernel change. #80 had two open anomalies that were both about what is actually running rather than about the pipeline, and neither could be settled from inside the source.

1. Residency: measured instead of modelled

cuOccupancyMaxActiveClusters puts the shipped cta_group::2 shape at 74 clusters while MAX_CLUSTERS launches 148, and the whole grouped-walk and wave arithmetic in optimized.rs assumes all 296 CTAs are resident. If the driver were right, main has been running two sequential waves of its "single persistent wave" since it was written.

src/residency_probe.rs answers it directly: every CTA takes its tensor-memory columns, reads %smid, holds its SM for a fixed wall-clock interval (%globaltimer — clock64 is per-SM and cannot order two CTAs against each other) and reports the interval. A grid the device runs in one wave takes the hold; one it runs in two takes twice the hold, and the packing and peak overlap come out of the same launch.

src/bin/residency.rs runs that beside every occupancy query the driver will answer, and beside the shipped kernel timed across grid widths (tcgen05_launch_config_over, the only src/ change — the kernel already reads its own grid through Walk::open, so any width computes the same C).

Measured, one B200:

launch CTAs wall ms waves SMs max/SM peak overlap
cg2 × 148 clusters, 114 816 B 296 2.022 1.01 148 2 296
cg2 × 148, 1 024 B 296 2.024 1.01 148 2 296
cg2 × 74, 114 816 B 148 2.019 1.01 148 1 148
cg4 × 74 (the multicast branch's grid) 296 4.020 2.01 142 3 284
cg4 × 71 284 2.018 1.01 142 2 284

All 296 CTAs are co-resident, two an SM. Every wave figure on #80 stands. The driver query answers floor(SMs / cluster CTAs) and does not model two clusters sharing an SM — it reports the same 74 for a 133-register kernel, a 168-register kernel and an 18-register probe, at 114 816 B and at 1 024 B, at every carveout and every grid. That is why the query ships beside the measurement in one binary and not instead of it: on its own it says 74, and 74 is wrong.

The 4-CTA rows are the same instrument answering #80's multicast negative: that grid reaches 142 SMs at two CTAs each, so 71 clusters fit and the 72nd costs a whole second wave. The kernel launched 74.

2. cuBLASLt: read instead of inferred

Nsight Compute does not initialise on the Modal container — Failed to initialize the profiler: LibraryNotLoaded, which is the driver's profiling support and not something an image can install (ncu itself is already at /usr/local/cuda/bin/ncu; modal_app.py grows a profile entry point and NCU=1 ./run.sh anyway, so the next person does not have to find that out).

A launch configuration needs no performance counters. baselines/cublas_decode.cu reads it from CUPTI's callback API — cuLaunchKernelEx parameters, plus cuFuncGetAttribute and cuOccupancyMaxActiveBlocksPerMultiprocessor on the handle the library is passing — at three shallow-K shapes, with describe's own fields printed so the algorithm is confirmed to be the one model_shapes divides by. src/bin/cublas_decode.rs is the same three shapes with both sides launched once, for a profiler that can attach.

Identical at all three shapes:

algo id=66 tile=23 splitk=1 stages=35 cluster=3
grid 6912 CTAs, block 256, cluster 2x1x1, dynamic shared 213 280 B
symbol nvjet_tst_128x256_64x6_2x1_2cta_v_bz_TNT

cluster=3 is 2×1×1, and tile=23 is [256, 256] — our tile, over our cluster, at our BLOCK_K = 64. Outputs over clusters confirms it without trusting the symbol: 65 536 at all three shapes. What differs is six K stages at one CTA an SM against our three at two.

Not in this PR

No kernel behaviour changes. The probe entry points live in optimized::kernels because a binary gets one device artifact (the same reason 80-phase-probe put its two there); they are unreachable from every shipped path and add no register or shared-memory cost to the three shipped entry points.

Gates

--kernel gemm: parity green, budgets unchanged at 133 / 168 / 145, zero spill — the shipped kernels are byte-identical to main's, which is the point.

…read rather than inferred (#80)

cuOccupancyMaxActiveClusters put the shipped cg2 shape at 74 clusters -- half
the 148 MAX_CLUSTERS launches -- which would make the persistent wave two
sequential waves and reinterpret every wave number on #80.

src/residency_probe.rs holds an SM for a fixed globaltimer interval and reports
%smid, so overlap is counted rather than modelled; bin/residency.rs runs that
beside every occupancy query the driver will answer and beside the shipped
kernel timed across grid widths.

baselines/cublas_decode.cu reads the library's own launches through CUPTI's
callback API -- Nsight Compute's counter library will not initialise in this
container, but a launch configuration needs no counters.
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