Repository navigation
fix: skip rewriting an up-to-date dataset metrics sidecar - #2634
Merged
Merged
Conversation
validate_samples_and_aggregate_metrics rewrote <dataset>_metrics.json next to the dataset unconditionally, even when the on-disk sidecar already matched the freshly computed metrics. When the dataset lives in a shared, read-only directory (e.g. a project-wide pre-staged benchmark workspace bind-mounted into the container), that redundant open(..., "w") raises PermissionError for any user who does not own the file, aborting the run before rollout collection begins. Skip the write when the sidecar already exists and no conflict was reported; keep writing when it is missing or is being overwritten on a conflict. In the skipped case the write is provably a no-op (identical bytes), so on-disk output is unchanged. Add a regression test that makes the sidecar read-only between two passes (reproducing the shared read-only dataset dir) and update the sanity test, whose bundled sidecar already matches and is therefore no longer rewritten. Signed-off-by: Grzegorz Chlebus <gchlebus@nvidia.com>
bxyu-nvidia
approved these changes
Aug 20, 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.
Problem
TrainDataProcessor.validate_samples_and_aggregate_metricswrites the aggregate-metrics sidecar (<dataset>_metrics.json) next to the dataset unconditionally β even when the on-disk sidecar already exists and matches the freshly computed metrics:_validate_aggregate_metricsalready returnsNoneboth when the sidecar is missing and when it matches, so a matching sidecar still gets truncated and rewritten with identical bytes.That redundant
open(..., "w")breaks a common multi-user setup: when the dataset lives in a shared, read-only directory β e.g. a project-wide pre-staged benchmark workspace bind-mounted into the eval container β a user who doesn't own the pre-staged sidecar hits:The run aborts during data preparation, before any rollout. This surfaced running SWE-bench Verified P/D on a Slurm cluster where the Gym workspace is shared across a project group.
Fix
Skip the write when the sidecar already exists and no conflict was reported. Missing-file and overwrite-on-conflict paths are unchanged.
overwrite_metrics_conflicts=Trueoverwrite_metrics_conflicts=FalseIn the newly skipped case the write was provably a no-op (identical bytes), so on-disk output is unchanged.
Tests
test_validate_samples_and_aggregate_metrics_skips_rewrite_when_sidecar_matches: copies the bundled example dataset into a tmp dir, runs once to create the sidecar, makes it read-only, and asserts a second pass neither raises nor rewrites it. Verified this fails without the fix (PermissionError) and passes with it.test_validate_samples_and_aggregate_metrics_sanity: its bundled sidecar already matches, so it is no longer rewritten β the write assertion is now[].pytest tests/unit_tests/test_train_data_utils.pyβ 22 passed.ruff+pre-commitclean on the changed files.Note for maintainers
This fixes the redundant-rewrite that breaks the shared-read-only case. The deeper design point β the metrics sidecar is written relative to cwd, which
_resolve_under_cwd_or_installdocuments as needing to be "the user's writable cwd" but which is the shared install root under a bind-mounted workspace β is left as-is. Happy to follow up if you'd prefer the sidecar target to move to an explicit output dir instead.