Repository navigation
Key the DCP conversion cache on the checkpoint, not its iteration name - #23
Merged
YuxiLiu-921 merged 1 commit intoOct 26, 2026
Merged
Conversation
resolve_ckpt_root cached a converted DCP checkpoint as assets/_ckpts/<iter>_ema.pt, so run_A/iter_N and run_B/iter_N shared one file and the second request silently got the first run's weights (AlibabaResearch#22). A checkpoint rewritten in place also kept its stale conversion. The cache name now carries a hash of the shard directory's real path and its file names, sizes and mtimes. The converter writes to a temporary file that is renamed when it finishes, so an interrupted conversion is never reused. An iteration directory whose shards sit under model/ is accepted by _rc_is_dcp_dir, but the converter was given the iteration directory and failed to find .metadata; it now gets the directory holding the shards.
|
|
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.
Fixes #22.
resolve_ckpt_rootcached a converted DCP checkpoint asassets/_ckpts/<iter>_ema.pt. As the issue shows,run_A/iter_000000001/modelandrun_B/iter_000000001/modeltherefore shared one file, and the second request got the first run's weights. The same happened when a checkpoint was rewritten in place.Change (
scripts/inference/_resolve_ckpt.shonly)The cache name now carries a key:
assets/_ckpts/<iter>_<key>_ema.pt. The key is the first 16 hex digits of a SHA-256 over the shard directory's real path and its file names, sizes and mtimes.using cached ... (from <dir>)).dcp_to_pth.pywrites to<file>.tmp.<pid>, which is renamed when the conversion finishes. An interrupted conversion therefore never leaves a file that a later run would take as cached.Iteration directories now convert.
_rc_is_dcp_diraccepts a directory whose shards are undermodel/, but the converter was given that parent directory and failed:It now gets the directory that holds the shards. That directory also feeds the key, so
.../iter_Nand.../iter_N/modelshare one cached file.Check
The check uses tiny real DCP checkpoints, written with
torch.distributed.checkpoint.saveon the CPU. In each onenet_ema.wholds a marker:run_X/iter_000000001/model;iter_000000001.Each scenario starts from an empty working directory with a copy of
scripts/(the resolver uses repo-relative paths). It callsresolve_ckpt_rootwithDIT_PATH=<dcp dir>and valid auxiliary paths, and readsnet.w[0]back from the resolvedDIT_PATH. Both trees were exported withgit archive, with LF line endings.6149ac5(main)using cached)run_A/iter_000000001).metadatanot found)When the same calls run at the top level under
set -euo pipefail(aseval_student_*.shdoes), the resolver logs three things:No
.tmpfile is left behind.Environment: GNU bash 5.2.37 (Git for Windows), Python 3.12, PyTorch 2.12.0. No GPU or full model was used. The new code uses only the Python interpreter the resolver already calls for
dcp_to_pth.py, pluscompgenandmv.Note: caches written before this change keep their old names. They are no longer picked up, and can be deleted from
assets/_ckpts/.🤖 Generated with Claude Code