Skip to content

write git version into the run dir for reproducibility - #637

Merged
RyanPCo merged 1 commit into
mainfrom
ryanco/phase4-git-provenance
Oct 19, 2026
Merged

RyanPCo merged 1 commit into
mainfrom
ryanco/phase4-git-provenance

Conversation

@RyanPCo

@RyanPCo RyanPCo commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Rank-0, once per process: on fit start, or on validation start for
validate-only (eval) runs; enabled in callbacks/defaults.yaml so every shipped
top-level config gets it. Writes git_sha.txt, git.diff (git diff HEAD --submodule=diff, raw bytes so non-UTF-8 edits neither crash training nor stop
the patch applying; includes file diffs inside external/openpi) and
git_untracked.txt (names only). A failed diff or listing leaves
.error with the reason instead of an empty file, so it never reads as a
clean tree. A process that finds git_sha.txt already in the run dir (Slurm
requeue, resume) writes git_sha..txt etc. beside it, keeping the
first launch's record. No-op with one warning when git is missing or egomimic
is not a checkout; write errors are logged, never raised. wandb records the sha
online; this covers offline runs and keeps provenance next to the checkpoints.

The git helper lives in egomimic/utils/git_info.py (every call bounded by a
30 s timeout, up from zarr_writer's old 5 s); zarr_writer's and norm_cache's
provenance stamps now use it, so norm_cache no longer imports zarr_writer.

Co-Authored-By: Claude Fable 5.1 [email protected]
Claude-Session: https://claude.ai/code/session_01MWtR1x5tjREwoxQZAnUGrh
Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01BbQNNaMAbTNMypegmJkv4s

🤖 Generated with Claude Code

https://claude.ai/code/session_01MWtR1x5tjREwoxQZAnUGrh
https://claude.ai/code/session_01BbQNNaMAbTNMypegmJkv4s

RyanPCo commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@RyanPCo
RyanPCo force-pushed the ryanco/phase4-git-provenance branch from ad0260c to 6eda7a6 Compare September 13, 2026 21:59
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-resume-without-base-weights branch from ed4bc94 to 3d8ffd1 Compare September 13, 2026 21:59
@RyanPCo RyanPCo changed the title callbacks: GitProvenance writes git_sha.txt + git.diff into the run dir write git version into the run dir for reproducibility Sep 14, 2026
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-resume-without-base-weights branch from 3d8ffd1 to d25f8ca Compare September 15, 2026 13:31
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-git-provenance branch from 6eda7a6 to 7a242b3 Compare September 15, 2026 13:31
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-git-provenance branch from 7a242b3 to fd3fecb Compare September 15, 2026 15:04
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-resume-without-base-weights branch 2 times, most recently from 4a8be78 to 677a62d Compare September 15, 2026 15:14
@RyanPCo
RyanPCo force-pushed the ryanco/phase4-git-provenance branch from 4b49d7c to 0ce439f Compare September 15, 2026 15:14
@RyanPCo
RyanPCo marked this pull request as ready for review September 15, 2026 15:16
@RyanPCo

RyanPCo commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai

@greptile-apps

greptile-apps Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds git provenance logging to training runs.

The PR should not merge until untracked files used outside egomimic/utils are included in the provenance record.

Findings

  1. P1 Untracked files are missed ▶
  2. P2 CSV reuse skips provenance ▶
  3. P2 Resume records can collide ▶

Summary

The PR adds a Git-provenance callback to the default training callbacks, records tracked changes and untracked filenames beside run checkpoints, and shares the Git SHA helper with the norm cache.

  • The untracked-file listing misses files outside the helper directory.
  • One eval route bypasses the callback's hooks, and closely spaced resumes can collide on filenames.

Reviews (1) · Last reviewed commit: "callbacks: GitProvenance writes git_sha...."

def git_untracked() -> bytes:
"""Newline-separated paths of untracked, non-ignored files (names only;
untracked files inside submodules are not listed). Raises GitError."""
return _git("ls-files", "--others", "--exclude-standard")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Untracked files are missed

If a run uses a new, untracked file outside egomimic/utils, such as a training config, this command lists only files beneath the helper's working directory. The file is omitted from git_untracked.txt, leaving the run's provenance incomplete. Run the listing from the work-tree root.

Comment on lines +38 to +40
def on_validation_start(self, trainer, pl_module) -> None:
# Validate-only (eval) runs never reach on_fit_start.
self._write_once(trainer)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 CSV reuse skips provenance

Latent evaluation can reuse existing CSVs, render outputs, and return without calling trainer.validate(). Because this callback records eval provenance only when validation starts, that eval path produces outputs without a Git record.

Comment on lines +65 to +67
if (root / "git_sha.txt").exists():
tag = "." + datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%SZ")
(root / f"git_sha{tag}.txt").write_text(sha + "\n", encoding="utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Resume records can collide

If two launches write to the same run directory within one second, they use the same timestamped filenames. The later launch can overwrite the earlier launch's SHA and diff, so the earlier provenance is lost. Use a collision-resistant tag or create the files exclusively.

RyanPCo commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Oct 19, 7:23 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Oct 19, 7:27 PM UTC: Graphite rebased this pull request as part of a merge.
  • Oct 19, 7:27 PM UTC: @RyanPCo merged this pull request with Graphite.

@RyanPCo
RyanPCo changed the base branch from ryanco/phase4-resume-without-base-weights to graphite-base/637 October 19, 2026 19:24
@RyanPCo
RyanPCo changed the base branch from graphite-base/637 to main October 19, 2026 19:25
Rank-0, once per process: on fit start, or on validation start for
validate-only (eval) runs; enabled in callbacks/defaults.yaml so every shipped
top-level config gets it. Writes git_sha.txt, git.diff (`git diff HEAD
--submodule=diff`, raw bytes so non-UTF-8 edits neither crash training nor stop
the patch applying; includes file diffs inside external/openpi) and
git_untracked.txt (names only). A failed diff or listing leaves
<file>.error with the reason instead of an empty file, so it never reads as a
clean tree. A process that finds git_sha.txt already in the run dir (Slurm
requeue, resume) writes git_sha.<UTC time>.txt etc. beside it, keeping the
first launch's record. No-op with one warning when git is missing or egomimic
is not a checkout; write errors are logged, never raised. wandb records the sha
online; this covers offline runs and keeps provenance next to the checkpoints.

The git helper lives in egomimic/utils/git_info.py (every call bounded by a
30 s timeout, up from zarr_writer's old 5 s); zarr_writer's and norm_cache's
provenance stamps now use it, so norm_cache no longer imports zarr_writer.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MWtR1x5tjREwoxQZAnUGrh
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01BbQNNaMAbTNMypegmJkv4s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant