fix(slurm): scrub SLURM_*/SBATCH_* from the sbatch submission env#955
Merged
Conversation
Submitting from inside a SLURM allocation (agent sessions, dev pods) leaked the caller's SLURM_CPUS_PER_TASK into the new job, whose srun then died with 'cpus-per-task set by two different environment variables' (the same leak the btdr launch wrapper works around by hand). sbatch now submits with a clean env so the job's SLURM state comes only from its own allocation.
The June 2026 fleet-wide slowdown (jobs sbatch'd from tmux windows inherited step-scoped SLURM_CPU_BIND and ran all ranks on the dev pod's 4 cores) is the silent variant of the same leak; its root-cause fix also stripped PMIX_*. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E34cK5BaVr6ZFAwRidNp6n
Collaborator
Author
|
Tested with a 6-arm matrix across clusters, submission methods, and dp (full 8L-slice llama8b runs, 30 steps each):
Two side findings: (1) the and-gmi login node's CPU lacks AVX so jax cannot import there — on gmi every Logs archived: 🤖 Generated with Claude Code |
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
sbatchpropagates the submitting shell's env into the new job, and SLURM readsSLURM_*vars as directives — so submitting from inside an allocation (dev pod, launcher job, agent session, a tmux server created in an srun step) carries the caller's step/allocation state into the new job. Two observed failure modes of the same leak:SLURM_CPUS_PER_TASKconflicts with the new job's own allocation and its innersrundies in ~2s with "cpus-per-task set by two different environment variables".SLURM_CPU_BINDpins every rank to the originating pod's few cores. This was the root cause of the June 2026 fleet-wide ~3× slowdown — jobs sbatch'd from tmux windows (the tmux server was created inside ansrun --overlapstep) ran 8 ranks + dataloaders on 4 cores, cost days of debugging and nearly a vendor escalation before being root-caused on our side.One line of substance in
infra/slurm.py::_submit_script: thesbatchsubprocess runs withos.environminusSLURM_*/SBATCH_*/PMIX_*, so the new job's SLURM state comes only from its own allocation. Covers everypd-*submitter (they share_submit_script). The June incident's fix scrubbed one source (the tmux server env); this scrubs at the sink, sopd-*submissions are immune regardless of what launched them.PMIX_*is included to match what the June root-cause fix stripped.Nothing the ranks rely on travels via inheritance: the run env is exported explicitly in the generated sbatch script from
runtime.launch_env(the config-captured single source of truth); ambient inheritance of everything else (PATH, HOME, tokens) is untouched. One deliberate behavior change: exportingSBATCH_*option-vars (e.g.SBATCH_PARTITION) in your shell no longer steerspd-*submissions — submissions are config-driven by design.Extracted from #941 (same base commit); #941/#954 dedupe on rebase once this merges.
Related Issue
Extracted from #941. Sink-side counterpart of the June 2026 CPU-affinity incident (Slack thread).
Motivation and Context
Launching from anywhere other than a bare login shell currently fails in ~2s with a confusing srun error — and the same leak class already caused a silent fleet-wide 3× slowdown once.
How Has This Been Tested?
All of this week's compile-probe launches (~15
pd-lmsubmissions, incl. an 8-node dp64 run) were submitted from inside 1-CPU launcher jobs on and-btdr with theSLURM_*/SBATCH_*scrub — every submission's inner srun started cleanly, which fails without it.Does this PR introduce a breaking change?
No (aside from the deliberate
SBATCH_*note above).🤖 Generated with Claude Code
https://claude.ai/code/session_01E34cK5BaVr6ZFAwRidNp6n