(
name: str,
n_hidden_states: str,
case: str,
n_procs: int,
gpu_name: str,
postfix: str,
n_runs_benchmark: str,
)
| 27 | |
| 28 | @app.function(gpu=cfg.gpu_spec, image=nsys_image, volumes=make_volumes(), timeout=cfg.timeout) |
| 29 | def nsys_profile( |
| 30 | name: str, |
| 31 | n_hidden_states: str, |
| 32 | case: str, |
| 33 | n_procs: int, |
| 34 | gpu_name: str, |
| 35 | postfix: str, |
| 36 | n_runs_benchmark: str, |
| 37 | ): |
| 38 | set_volume_caches() |
| 39 | report_dir = f"{volume_path}/nsys-profiles/{gpu_name}/tp{n_procs}/case-{case}/bsz{n_hidden_states}{postfix}" |
| 40 | os.makedirs(report_dir, exist_ok=True) |
| 41 | report_path = f"{report_dir}/{name}" |
| 42 | |
| 43 | speed_test_args = [ |
| 44 | "/opt/fmms/speed_test.py", |
| 45 | "--name", |
| 46 | name, |
| 47 | "--n_hidden_states", |
| 48 | n_hidden_states, |
| 49 | "--n_runs_warmup", |
| 50 | "25", |
| 51 | "--n_runs_benchmark", |
| 52 | n_runs_benchmark, |
| 53 | "--bench_fn=own", |
| 54 | f"--case={case}", |
| 55 | f"--n_procs={n_procs}", |
| 56 | "--nsys_profile=true", |
| 57 | ] |
| 58 | |
| 59 | if n_procs > 1: |
| 60 | # Per-rank nsys: torchrun launches the wrapper, each rank gets its |
| 61 | # own nsys instance and .nsys-rep file. This avoids the known nsys |
| 62 | # limitation where cudaProfilerApi capture misses child-process GPU |
| 63 | # activity when wrapping torchrun from the outside. |
| 64 | cmd = [ |
| 65 | "torchrun", |
| 66 | f"--nproc_per_node={n_procs}", |
| 67 | "/opt/fmms/nsys_wrapper.py", |
| 68 | "--report-dir", |
| 69 | report_dir, |
| 70 | "--name", |
| 71 | name, |
| 72 | "--", |
| 73 | *speed_test_args, |
| 74 | ] |
| 75 | env = None |
| 76 | else: |
| 77 | cmd = [ |
| 78 | "nsys", |
| 79 | "profile", |
| 80 | "-o", |
| 81 | report_path, |
| 82 | "--force-overwrite=true", |
| 83 | "--capture-range=cudaProfilerApi", |
| 84 | "--cuda-memory-usage=true", |
| 85 | "python", |
| 86 | *speed_test_args, |
nothing calls this directly
no test coverage detected