Skip to content

Commit ca693c1

Browse files
ocg-goodfireclaude
andcommitted
feat(multipool): forward profiling/trace env vars to the SLURM job
The launch exports only a curated env dict (DDP_ENV + THREE_POOL_SLURM_ENV), so PD_TORCH_PROFILE_* / PD_MEMORY_PROFILE_* / PD_TRACE* set at submit were dropped and the documented profiler env-var interface was a no-op over SLURM. profiling_env_passthrough() collects those from the submit environment; both 2-pool submit sites merge it in. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 6178b8e commit ca693c1

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

param_decomp_lab/experiments/lm/three_pool_run.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@
107107
# cross-pool collectives).
108108
THREE_POOL_SLURM_ENV: dict[str, str] = {"PYTORCH_CUDA_ALLOC_CONF": "expandable_segments:True"}
109109

110+
# Profiling / tracing env vars (read on the compute node by the profiler / trace hooks)
111+
# only reach the job if forwarded explicitly — the SLURM script exports a curated env dict,
112+
# not the submitter's whole environment. `profiling_env_passthrough` collects those set at
113+
# submit so `PD_TORCH_PROFILE_* / PD_MEMORY_PROFILE_* / PD_TRACE*` flow through to the run.
114+
_PROFILE_ENV_PREFIXES = ("PD_TORCH_PROFILE_", "PD_MEMORY_PROFILE_", "PD_TRACE")
115+
116+
117+
def profiling_env_passthrough() -> dict[str, str]:
118+
return {k: v for k, v in os.environ.items() if k.startswith(_PROFILE_ENV_PREFIXES)}
119+
110120

111121
class ThreePoolRuntimeConfig(PooledRuntimeConfig):
112122
"""`PooledRuntimeConfig` (core substrate scalars + the `compile_*` / `checkpoint_ci_fn`

param_decomp_lab/experiments/lm/two_pool_run.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
_install_first_fail_marker,
5858
_maybe_build_torch_profiler,
5959
_maybe_enable_memory_profile,
60+
profiling_env_passthrough,
6061
)
6162
from param_decomp_lab.experiments.utils import (
6263
EXPERIMENT_CONFIG_FILENAME,
@@ -525,7 +526,9 @@ def _submit_slurm(
525526
requeue=True,
526527
)
527528
script = generate_script(
528-
slurm_config, launch.command, env={**launch.env, **THREE_POOL_SLURM_ENV}
529+
slurm_config,
530+
launch.command,
531+
env={**launch.env, **THREE_POOL_SLURM_ENV, **profiling_env_passthrough()},
529532
)
530533
result = submit_slurm_job(script, "lm")
531534

@@ -631,7 +634,9 @@ def submit_slurm_async_consolidate_and_eval(
631634
comment=f"async-consol-eval:{train_run_id}@{step}",
632635
)
633636
script = generate_script(
634-
slurm_config, launch.command, env={**launch.env, **THREE_POOL_SLURM_ENV}
637+
slurm_config,
638+
launch.command,
639+
env={**launch.env, **THREE_POOL_SLURM_ENV, **profiling_env_passthrough()},
635640
)
636641
result = submit_slurm_job(script, "lm")
637642
logger.info(

0 commit comments

Comments
 (0)