Skip to content

Commit

Permalink
Cleaning up nvFuser's repro script api. (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinstephano authored Oct 3, 2024
1 parent 15753c9 commit 3d7ffac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion thunder/examine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,11 @@ def get_nvfuser_repro(trace: TraceCtx, fusion_name: str, /) -> str:
)

fd = fusion.last_used
get_repro = getattr(fd, "getReproString", None)
# The API for nvFuser version >=2.14
get_repro = getattr(fd, "repro_script_for", None)
# The legacy nvFuser API
if get_repro is None:
get_repro = getattr(fd, "getReproString", None)
if get_repro is None:
raise RuntimeError("The installed version of nvFuser does not support repro generation unless on crash.")

Expand Down
10 changes: 9 additions & 1 deletion thunder/tests/test_nvfuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,16 @@ def sdpa_fn(q, k, v, dropout_p, is_causal, scale):

# Check nv_sdpfa_fwd is not in bwd_fusion -> that would indicate rematerialization
assert "nv_sdpfa_bwd" in bwd_fusion[-1][-1].name and "nv_sdpfa_fwd" not in bwd_fusion[-1][-1].name

nvf_fd = bwd_fusion[-1][-1].last_used
repro_script = None
# Legacy repro script API
if nvfuser_version() < LooseVersion("0.2.14"):
repro_script = nvf_fd.getReproString()
else:
repro_script = nvf_fd.repro_script_for()
assert (
bwd_fusion[-1][-1].last_used.getReproString().count("is_cpu=True") == 2
repro_script.count("is_cpu=True") == 2
), "Expected philox_seed and philox_offset inputs to be CPU scalar tensors."

# Torch reference computation
Expand Down

0 comments on commit 3d7ffac

Please sign in to comment.