|
9 | 9 | import argparse |
10 | 10 | import logging |
11 | 11 | import time |
| 12 | +from typing import Final |
12 | 13 |
|
13 | 14 | import numpy as np |
14 | 15 |
|
|
18 | 19 | from param_bench.train.comms.pt import comms_utils |
19 | 20 | from param_bench.train.comms.pt.comms_utils import ( |
20 | 21 | bootstrap_info_holder, |
21 | | - commsParamsHolder, |
22 | 22 | commsParamsHolderBase, |
23 | 23 | ensureTensorFlush, |
24 | 24 | MultilineFormatter, |
|
33 | 33 | commsQuantCollPerfMetrics, |
34 | 34 | customized_perf_loggers, |
35 | 35 | ) |
36 | | - |
37 | 36 | from param_bench.train.comms.pt.pytorch_backend_utils import ( |
38 | | - backendFunctions, |
39 | 37 | pt2ptPatterns, |
40 | 38 | supportedC10dBackends, |
41 | 39 | supportedCollectives, |
@@ -174,6 +172,16 @@ def readArgs(self, parser): |
174 | 172 | default=None, |
175 | 173 | help="execute pytorch profiler at specified size", |
176 | 174 | ) # execute pytorch profiler at specified size if applicable |
| 175 | + parser.add_argument( |
| 176 | + "--profiler-active-iters", |
| 177 | + "--pa", |
| 178 | + type=int, |
| 179 | + required=False, |
| 180 | + help=( |
| 181 | + "If set, profiler will only record these many iters. " |
| 182 | + "Otherwise it records the full --num_iters across one benchmark size iteration." |
| 183 | + ), |
| 184 | + ) |
177 | 185 | parser.add_argument( |
178 | 186 | "--tag", |
179 | 187 | type=str, |
@@ -1319,14 +1327,20 @@ def benchComm(self, index, commsParams, backendFuncs): |
1319 | 1327 | results["numElements"] = numElements |
1320 | 1328 |
|
1321 | 1329 | self.collectiveArgs.data_type = commsParams.data_type |
| 1330 | + profiler_active_iters = commsParams.profiler_active_iters |
| 1331 | + if profiler_active_iters is None: |
| 1332 | + # not specified in arg |
| 1333 | + profiler_active_iters = ( |
| 1334 | + self.collectiveArgs.graph_launches |
| 1335 | + if self.collectiveArgs.graph_launches |
| 1336 | + else self.collectiveArgs.numIters |
| 1337 | + ) |
1322 | 1338 | if commsParams.size_start_profiler == curSize: |
1323 | 1339 | self.collectiveArgs.enable_profiler = comms_utils.startProfiler( |
1324 | 1340 | rank=self.backendFuncs.get_global_rank(), |
1325 | 1341 | device=self.collectiveArgs.device, |
1326 | 1342 | numWarmupIters=self.collectiveArgs.numWarmupIters, |
1327 | | - numIters=self.collectiveArgs.graph_launches |
1328 | | - if self.collectiveArgs.graph_launches |
1329 | | - else self.collectiveArgs.numIters, |
| 1343 | + numIters=profiler_active_iters, |
1330 | 1344 | ) |
1331 | 1345 |
|
1332 | 1346 | # self.collectiveArgs has all the information on the experiment. |
|
0 commit comments