parser() — pytorch Function Reference
Architecture documentation for the parser() function in distributed.py from the pytorch codebase.
Entity Profile
Dependency Diagram
graph TD 28abd701_daff_7831_6354_47eeb9f5e68d["parser()"] 0b66073b_10d9_d2e9_f83d_01d82f509823["parse_args()"] 28abd701_daff_7831_6354_47eeb9f5e68d -->|calls| 0b66073b_10d9_d2e9_f83d_01d82f509823 3ea941c9_72e7_2829_0157_0cee5513e057["get_model()"] 28abd701_daff_7831_6354_47eeb9f5e68d -->|calls| 3ea941c9_72e7_2829_0157_0cee5513e057 style 28abd701_daff_7831_6354_47eeb9f5e68d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
benchmarks/dynamo/distributed.py lines 117–177
parser = argparse.ArgumentParser()
parser.add_argument("--device", default="cuda")
parser.add_argument(
"--dynamo",
default=None,
help="if set to a str, uses dynamo[str] backend. else, eager",
)
parser.add_argument("--verbose", action="store_true")
parser.add_argument("--batch-size", "--batch_size", default=None)
parser.add_argument(
"--torchviz", action="store_true", help="Dump autograd graph with torchviz"
)
parser.add_argument("--profile", action="store_true", help="Run the profiler")
parser.add_argument(
"--trace-file", "--trace_file", default="profile.json", help="Run the profiler"
)
parser.add_argument("--repeat", default=10, help="Repeats for timing run")
parser.add_argument(
"--dynamo-no-optimize-ddp",
"--dynamo_no_optimize_ddp",
action="store_true",
help="Disable dynamo's ddp optimizer (enabled by default)",
)
parser.add_argument(
"--fsdp-checkpoint",
"--fsdp_checkpoint",
action="store_true",
help="Use gradient checkpointing via model-specific policy",
)
parser.add_argument(
"--fsdp-wrap",
"--fsdp_wrap",
action="store_true",
help="Apply fsdp to submodules via model-specific policy",
)
dist_arg = parser.add_mutually_exclusive_group()
dist_arg.add_argument("--ddp", action="store_true")
dist_arg.add_argument("--fsdp", action="store_true")
model_arg = parser.add_mutually_exclusive_group(required=True)
model_arg.add_argument(
"--torchbench-model",
"--torchbench_model",
help="name of torchbench model, e.g. BERT_pytorch",
)
model_arg.add_argument(
"--toy-model", "--toy_model", action="store_true", help="use toy model instead"
)
args = parser.parse_args()
model_name = args.torchbench_model
if args.toy_model:
model_name = "ToyModel"
model, inputs = get_model(args)
fn = partial(run_model, args, model, inputs)
world_size = os.getenv("WORLD_SIZE", 1)
t_total = fn(f"{model_name}_{world_size}")
print(f"mean latency {t_total / args.repeat} across {args.repeat} runs")
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does parser() do?
parser() is a function in the pytorch codebase.
What does parser() call?
parser() calls 2 function(s): get_model, parse_args.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free