Skip to content

Commit 102b0df

Browse files
committed
revert plugin
Signed-off-by: Malay Nagda <malayn@nvidia.com>
1 parent 140cfc1 commit 102b0df

4 files changed

Lines changed: 21 additions & 64 deletions

File tree

scripts/performance/perf_plugins.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535
from nemo_run import Plugin, Script, SlurmExecutor
3636

3737

38-
try:
39-
from utils.utils import configure_slurm_gpu_tuning
40-
except (ImportError, ModuleNotFoundError):
41-
from .utils.utils import configure_slurm_gpu_tuning
42-
43-
4438
logger: logging.Logger = logging.getLogger(__name__)
4539
NSYS_SQLITE_EXPORT_ARG = "--export=sqlite"
4640

@@ -70,26 +64,6 @@ def _ensure_sqlite_nsys_export(nsys_extra_args: list[str]) -> list[str]:
7064
return nsys_extra_args + [NSYS_SQLITE_EXPORT_ARG]
7165

7266

73-
@dataclass(kw_only=True)
74-
class SlurmGpuTuningPlugin(Plugin):
75-
"""Apply GPU tuning after NeMo Run assigns the executor's job directory."""
76-
77-
enable_vboost: bool = False
78-
lock_gpu_freq: int | None = None
79-
peak_mem_clk: int | None = None
80-
81-
def setup(self, task: Union["run.Partial", "run.Script"], executor: "run.Executor") -> None:
82-
"""Add Slurm setup commands using the assigned per-task job directory."""
83-
del task
84-
if isinstance(executor, SlurmExecutor):
85-
configure_slurm_gpu_tuning(
86-
executor,
87-
enable_vboost=self.enable_vboost,
88-
lock_gpu_freq=self.lock_gpu_freq,
89-
peak_mem_clk=self.peak_mem_clk,
90-
)
91-
92-
9367
@dataclass
9468
class NsysPluginScriptArgs:
9569
"""Arguments for NsysPlugin to pass to run.Script."""

scripts/performance/setup_experiment.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
kubeflow_executor,
3939
slurm_executor,
4040
)
41-
from utils.utils import get_exp_name_config, select_config_variant_interactive
41+
from utils.utils import configure_slurm_gpu_tuning, get_exp_name_config, select_config_variant_interactive
4242
except (ImportError, ModuleNotFoundError):
4343
from .argument_parser import NUM_GPUS_PER_NODE_MAP, parse_cli_args
4444
from .utils.executors import (
@@ -47,7 +47,7 @@
4747
kubeflow_executor,
4848
slurm_executor,
4949
)
50-
from .utils.utils import get_exp_name_config, select_config_variant_interactive
50+
from .utils.utils import configure_slurm_gpu_tuning, get_exp_name_config, select_config_variant_interactive
5151

5252
try:
5353
import wandb
@@ -57,9 +57,9 @@
5757
HAVE_WANDB = False
5858

5959
try:
60-
from perf_plugins import NsysPlugin, PreemptionPlugin, PyTorchProfilerPlugin, SlurmGpuTuningPlugin
60+
from perf_plugins import NsysPlugin, PreemptionPlugin, PyTorchProfilerPlugin
6161
except (ImportError, ModuleNotFoundError):
62-
from .perf_plugins import NsysPlugin, PreemptionPlugin, PyTorchProfilerPlugin, SlurmGpuTuningPlugin
62+
from .perf_plugins import NsysPlugin, PreemptionPlugin, PyTorchProfilerPlugin
6363

6464
SCRIPT_DIR = Path(__file__).parent.resolve()
6565
ENTRYPOINT_BOOTSTRAP = "bootstrap.py"
@@ -704,17 +704,15 @@ def main(
704704
packager=packager,
705705
enable_pct_binding=enable_pct_binding,
706706
)
707-
plugins = []
708-
709-
if not kubeflow_namespace and (enable_vboost or lock_gpu_freq is not None or peak_mem_clk is not None):
710-
plugins.append(
711-
SlurmGpuTuningPlugin(
712-
enable_vboost=enable_vboost,
713-
lock_gpu_freq=lock_gpu_freq,
714-
peak_mem_clk=peak_mem_clk,
715-
)
707+
configure_slurm_gpu_tuning(
708+
executor,
709+
enable_vboost=enable_vboost,
710+
lock_gpu_freq=lock_gpu_freq,
711+
peak_mem_clk=peak_mem_clk,
716712
)
717713

714+
plugins = []
715+
718716
# Long-convergence runs are split across walltime slices and resume from the last
719717
# checkpoint each slice. Without a preemption signal, Slurm hard-kills the slice at
720718
# the time limit before a checkpoint is written, so no progress persists and the

scripts/performance/utils/utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,9 @@ def configure_slurm_gpu_tuning(
7979
lock_gpu_freq: int | None,
8080
peak_mem_clk: int | None,
8181
) -> None:
82-
"""Add optional GPU tuning commands to an assigned Slurm executor."""
83-
if not (enable_vboost or lock_gpu_freq is not None or peak_mem_clk is not None):
84-
return
85-
82+
"""Add optional GPU tuning commands to a Slurm executor before submission."""
8683
commands = []
87-
job_dir = executor.job_dir
88-
if not job_dir:
89-
raise ValueError("Slurm executor must be assigned to a job before configuring GPU tuning.")
84+
job_dir = executor.tunnel.job_dir
9085

9186
if enable_vboost:
9287
commands.append(

tests/unit_tests/scripts/performance/test_run_script_entrypoint.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
sys.path.insert(0, str(_PERF_SCRIPTS_DIR))
2626

2727
import bootstrap
28-
import perf_plugins
2928
import run_recipe
3029
import run_script
3130
import setup_experiment
@@ -163,35 +162,26 @@ def test_compatibility_overrides_preserve_legacy_manual_gc_defaults():
163162
assert recipe.train.manual_gc_interval == 100
164163

165164

166-
def test_gpu_tuning_plugin_uses_assigned_slurm_job_dir():
167-
executor = perf_plugins.SlurmExecutor(
168-
account="test",
165+
def test_gpu_tuning_options_are_applied_directly_to_slurm_executor():
166+
executor = SimpleNamespace(
169167
nodes=2,
170-
tunnel=perf_plugins.run.LocalTunnel(job_dir="/experiments"),
168+
tunnel=SimpleNamespace(job_dir="/job/dir"),
171169
setup_lines="existing setup\n",
172170
)
173-
executor.assign(
174-
"name_123",
175-
"/experiments/name/name_123",
176-
task_id="task",
177-
task_dir="task",
178-
)
179-
plugin = perf_plugins.SlurmGpuTuningPlugin(
171+
172+
utils.configure_slurm_gpu_tuning(
173+
executor,
180174
enable_vboost=True,
181175
lock_gpu_freq=1200,
182176
peak_mem_clk=2600,
183177
)
184-
plugin.setup(SimpleNamespace(), executor)
185178

186179
assert executor.setup_lines.startswith("existing setup\n")
187180
assert "sudo nvidia-smi boost-slider --vboost 1" in executor.setup_lines
188181
assert "--ntasks=2" in executor.setup_lines
189182
assert "sudo nvidia-smi -lgc 1200" in executor.setup_lines
190-
assert (
191-
"srun --ntasks=2 --ntasks-per-node=1 "
192-
"--output /experiments/name/name_123/task/peak_mem_clock.out" in executor.setup_lines
193-
)
194-
assert "--error /experiments/name/name_123/task/peak_mem_clock.err" in executor.setup_lines
183+
assert "srun --ntasks=2 --ntasks-per-node=1 --output /job/dir/peak_mem_clock.out" in executor.setup_lines
184+
assert "--error /job/dir/peak_mem_clock.err" in executor.setup_lines
195185
assert "sudo nvidia-smi -lmc 2600,2600" in executor.setup_lines
196186

197187

0 commit comments

Comments
 (0)