_run_torchbench_model() — pytorch Function Reference
Architecture documentation for the _run_torchbench_model() function in cachebench.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD e689bf38_d776_1fe3_5224_2226c424159c["_run_torchbench_model()"] 0888c17f_2107_6a74_1c6a_de217ecb2d2a["_run_torchbench_from_args()"] e689bf38_d776_1fe3_5224_2226c424159c -->|calls| 0888c17f_2107_6a74_1c6a_de217ecb2d2a style e689bf38_d776_1fe3_5224_2226c424159c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/cachebench.py lines 94–143
def _run_torchbench_model(
cmd_args: argparse.Namespace,
results: list[RunResult],
model: str,
) -> None:
cur_file = os.path.abspath(__file__)
torchbench_file = os.path.join(
os.path.dirname(cur_file), BENCHMARK_FILE[cmd_args.benchmark]
)
if not os.path.exists(torchbench_file):
raise AssertionError(f"Torchbench does not exist at {torchbench_file}")
dynamic = cmd_args.dynamic
dynamic_args = ["--dynamic-shapes", "--dynamic-batch-only"] if dynamic else []
args = (
[
sys.executable,
torchbench_file,
f"--only={model}",
"--repeat=1",
"--performance",
"--backend=inductor",
f"--device={cmd_args.device}",
]
+ MODE_ARGS_DICT[cmd_args.mode]
+ dynamic_args
)
logger.info(f"Command: {args}") # noqa: G004
try:
cold_compile_t, warm_compile_t = _run_torchbench_from_args(
cmd_args, model, args
)
speedup_pct = (1 - (sum(warm_compile_t) / sum(cold_compile_t))) * 100
results.append(
RunResult(
model=model,
mode=cmd_args.mode,
benchmark=cmd_args.benchmark,
dynamic=dynamic,
device=cmd_args.device,
cold_compile_s=cold_compile_t,
warm_compile_s=warm_compile_t,
speedup_pct=speedup_pct,
)
)
except Exception:
logger.info("fail", exc_info=True)
return None
Domain
Subdomains
Source
Frequently Asked Questions
What does _run_torchbench_model() do?
_run_torchbench_model() is a function in the pytorch codebase.
What does _run_torchbench_model() call?
_run_torchbench_model() calls 1 function(s): _run_torchbench_from_args.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free