3737
3838
3939try :
40- from utils .utils import WorkloadBaseConfig , get_workload_base_config
40+ from utils .utils import WorkloadBaseConfig
4141except (ImportError , ModuleNotFoundError ):
42- from .utils .utils import WorkloadBaseConfig , get_workload_base_config
42+ from .utils .utils import WorkloadBaseConfig
4343
4444logger : logging .Logger = logging .getLogger (__name__ )
4545NSYS_SQLITE_EXPORT_ARG = "--export=sqlite"
@@ -495,16 +495,13 @@ def get_lock_gpu_freq_srun_cmd(job_dir, freq_mhz):
495495 else lock_freq_cmd
496496 )
497497
498- def setup (self , task : Union ["run.Partial" , "run.Script" ], executor : "run.Executor" ):
499- """Enable the performance environment settings"""
500- workload_base_config = get_workload_base_config (
501- self .model_family_name ,
502- self .model_recipe_name ,
503- self .gpu ,
504- self .compute_dtype ,
505- self .train_task ,
506- self .config_variant ,
507- )
498+ def setup_recipe_environment (
499+ self ,
500+ task : Union ["run.Partial" , "run.Script" , None ],
501+ executor : "run.Executor" ,
502+ workload_base_config : WorkloadBaseConfig ,
503+ ) -> None :
504+ """Apply recipe-dependent environment settings inside the training container."""
508505 tp_size = self .tp_size if self .tp_size is not None else workload_base_config .tensor_model_parallel_size
509506 pp_size = self .pp_size if self .pp_size is not None else workload_base_config .pipeline_model_parallel_size
510507 cp_size = self .cp_size if self .cp_size is not None else workload_base_config .context_parallel_size
@@ -554,15 +551,6 @@ def setup(self, task: Union["run.Partial", "run.Script"], executor: "run.Executo
554551 nccl_pp_comm_chunksize = None
555552 self ._set_nccl_pp_comm_chunksize (task , executor , nccl_pp_comm_chunksize , pp_size )
556553
557- # Configure manual garbage collection
558- self ._set_manual_gc (task , executor , self .enable_manual_gc , self .manual_gc_interval )
559-
560- # Improve perf by steering power to tensor cores, may not work on all systems
561- self ._set_vboost (task , executor , self .enable_vboost )
562-
563- # Lock GPU graphics clock frequency for stable performance measurements
564- self ._set_lock_gpu_freq (task , executor , self .lock_gpu_freq )
565-
566554 # Set model-specific environment variables
567555 self ._set_model_specific_environment_variables (
568556 task ,
@@ -582,6 +570,14 @@ def setup(self, task: Union["run.Partial", "run.Script"], executor: "run.Executo
582570 if self .deterministic :
583571 self ._set_determinism_env_vars (executor )
584572
573+ def setup (self , task : Union ["run.Partial" , "run.Script" ], executor : "run.Executor" ):
574+ """Apply launcher-only settings without importing Megatron-Bridge on the login node."""
575+ # Recipe-dependent environment variables are applied by run_script_with_env.py
576+ # inside the training container, where the flat recipe can be imported safely.
577+ self ._set_manual_gc (task , executor , self .enable_manual_gc , self .manual_gc_interval )
578+ self ._set_vboost (task , executor , self .enable_vboost )
579+ self ._set_lock_gpu_freq (task , executor , self .lock_gpu_freq )
580+
585581
586582@dataclass
587583class PyTorchProfilerPluginScriptArgs :
0 commit comments