MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / ncu_run

Function ncu_run

src/fused_mm_sampling/modal_lib/modal_ncu.py:32–87  ·  view source on GitHub ↗
(name: str, n_hidden_states: str, case: str, n_procs: int, mode: str, gpu_name: str)

Source from the content-addressed store, hash-verified

30
31@app.function(gpu=cfg.gpu_spec, image=ncu_image, volumes=make_volumes(), timeout=cfg.timeout)
32def ncu_run(name: str, n_hidden_states: str, case: str, n_procs: int, mode: str, gpu_name: str):
33 set_volume_caches()
34 cmd = [
35 "ncu",
36 "--set",
37 "full",
38 "--target-processes",
39 "all",
40 ]
41 if n_procs > 1:
42 # Symmetric memory breaks kernel replay (can't save/restore memory).
43 # Use application replay (re-runs the whole app per metric pass) and
44 # filter by kernel name instead of NVTX (NVTX ranges aren't stable
45 # across application re-runs due to autotuning).
46 cmd += [
47 "--replay-mode",
48 "application",
49 "-k",
50 "fused_mm_sample_triton_kernel",
51 ]
52 else:
53 cmd += ["--nvtx", "--nvtx-include", "kernel/"]
54 if mode == "profile":
55 ncu_dir = f"{volume_path}/ncu-rep/{gpu_name}/tp{n_procs}/case-{case}/bsz{n_hidden_states}"
56 out_path = f"{ncu_dir}/{name}"
57 os.makedirs(ncu_dir, exist_ok=True)
58 cmd += [
59 "--source-folders",
60 "/opt/fmms/src/fused_mm_sampling",
61 "--import-source",
62 "yes",
63 "-fo",
64 out_path,
65 ]
66 cmd += [
67 "python",
68 "/opt/fmms/speed_test.py",
69 "--name",
70 name,
71 "--n_hidden_states",
72 n_hidden_states,
73 "--n_runs_benchmark",
74 "1",
75 "--bench_fn=own",
76 f"--case={case}",
77 f"--n_procs={n_procs}",
78 ]
79 print(f"Running: {' '.join(cmd)}")
80 result = subprocess.run(cmd, capture_output=True, text=True)
81 print("=== stdout ===")
82 print(result.stdout)
83 print("=== stderr ===")
84 print(result.stderr[-5000:] if len(result.stderr) > 5000 else result.stderr)
85 print(f"=== returncode: {result.returncode} ===")
86 if mode == "profile":
87 modal.Volume.from_name("fused-mm-sample").commit()
88
89

Callers

nothing calls this directly

Calls 1

set_volume_cachesFunction · 0.85

Tested by

no test coverage detected