MCPcopy Index your code
hub / github.com/FlashSampling/FlashSampling / nsys_profile

Function nsys_profile

src/fused_mm_sampling/bench/speed_test.py:131–150  ·  view source on GitHub ↗

Run under nsys: warmup, sync ranks, then profile timed iterations.

(case: Case)

Source from the content-addressed store, hash-verified

129
130
131def nsys_profile(case: Case) -> None:
132 """Run under nsys: warmup, sync ranks, then profile timed iterations."""
133 fn = _prepare_case(case)
134 cache = create_l2_cache()
135 is_distributed = case.tp.size > 1
136 for _ in range(case.n_runs_warmup):
137 clear_l2_cache(cache)
138 fn()
139 synchronize(is_distributed)
140
141 torch.cuda.cudart().cudaProfilerStart()
142 synchronize(is_distributed)
143
144 for _ in range(case.n_runs_benchmark):
145 clear_l2_cache(cache)
146 with torch.cuda.nvtx.range("kernel"):
147 fn()
148
149 synchronize(is_distributed)
150 torch.cuda.cudart().cudaProfilerStop()
151
152
153def benchmark_all(cases: list[Case]) -> pd.DataFrame:

Callers 1

run_own_benchmarkFunction · 0.70

Calls 5

_prepare_caseFunction · 0.85
create_l2_cacheFunction · 0.85
clear_l2_cacheFunction · 0.85
synchronizeFunction · 0.85
fnFunction · 0.70

Tested by

no test coverage detected