refactor(infra): worktree-safe shallow snapshot fetch, drop $HOME/param-decomp#963
Merged
Merged
Conversation
… drop $HOME/param-decomp generate_git_snapshot_setup (harvest/autointerp/investigate SLURM jobs) cloned "$HOME/param-decomp" and did a full `git fetch <ref>:<ref>` — an unblessed hack from the torch era whose motivation (sbatch generated from inside a SLURM job) is dead on feature/jax. #960 already returned the pd-lm trainer launch to the same job-side setup pattern these jobs never left, and resolved the fetch source with `git rev-parse --path-format=absolute --git-common-dir` (worktree-safe: the main checkout's .git on shared FS even under a linked worktree). Rather than duplicate that helper, promote it to `infra.git.snapshot_source_repo()` as the single source of truth and have BOTH launchers use it: - infra.git: new `snapshot_source_repo()`. - infra.slurm.generate_git_snapshot_setup: `git init` + `git fetch --depth 1 "file://<common-dir>" <ref>` + `git checkout FETCH_HEAD`, replacing the clone of $HOME/param-decomp. file:// is required — git silently ignores --depth on the bare-path local transport. `.env` (untracked secrets) now comes from the durable main checkout (the common git dir's parent worktree), not the possibly-ephemeral submitting worktree. - experiments.lm.launch: drop its private `_snapshot_source_repo`, import the shared one. Adds param_decomp_lab/tests/test_slurm.py. Crew-Address: task/harvest-fragment-drop-home-checkout
d793fd5 to
b3e17d9
Compare
ocg-goodfire
approved these changes
Jul 8, 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.
What
generate_git_snapshot_setupinparam_decomp_lab/infra/slurm.py(harvest /autointerp / investigate SLURM jobs) cloned
"$HOME/param-decomp"and did a fullgit fetch <ref>:<ref>. That$HOME/param-decomphardcode is an unblessed hack fromcommit
24190c261(torch era), whose motivation — generating an sbatch from inside aSLURM job (async slow-eval via
sink.on_save), whereREPO_ROOTpoints at a node-local/tmp/.../workspace-*— is dead onfeature/jax.Reconsidered in light of #960
#960 already returned the pd-lm trainer launch to the same job-side setup pattern
these jobs never left, and resolved the fetch source with
git rev-parse --path-format=absolute --git-common-dir(the main checkout's.gitonshared FS, worktree-safe). So rather than land a second copy of that helper, this PR
promotes it to a single shared home and points both launchers at it:
infra/git.py: newsnapshot_source_repo()— the one definition (it already hoststhe other
REPO_ROOT-based git utilities both launchers import).infra/slurm.py:generate_git_snapshot_setupnow doesgit init+git fetch --quiet --depth 1 "file://<common-dir>" <ref>+git checkout --quiet FETCH_HEAD, replacing the$HOME/param-decompclone + tag/head fetch.file://isrequired — git silently ignores
--depthon the bare-path local transport..env(untracked secrets) is copied from the durable main checkout (the common git dir's
parent worktree), not the possibly-ephemeral submitting worktree.
experiments/lm/launch.py: drops its private_snapshot_source_repo(added inrefactor(pd-lm): job-side node workspaces, drop the submit-time shared-FS build #960), imports the shared one — net −16 lines there.
Result: one implementation of "where does a job fetch its snapshot from", used by both
the trainer launch and the shared SLURM fragment, instead of two.
Testing
param_decomp_lab/tests/test_slurm.pyasserts the fragment shape (shallowfile://fetch from the common dir,
FETCH_HEADcheckout, durable.env, nogit clone, no$HOME/param-decomp).pytest test_slurm.py test_launch.py→ 9 passed;ruff check/formatclean;basedpyright0 errors on all four touched files.slurm.snapshot_source_repo is git.snapshot_source_repo(singleobject), and rendering the fragment from inside a linked worktree resolves the common
dir to the main checkout
/mnt/home/pd-user/param-decomp/.git(worktree-safety).Follow-up from #960. Board task
harvest-fragment-drop-home-checkout.Crew-Address: task/harvest-fragment-drop-home-checkout