feat: unified resume system with checkpoint_utils - #187
Merged
Merged
Conversation
added 19 commits
March 9, 2026 18:00
Replace dual-path resume logic (ResumeConfig + setup_resume) with a single source of truth: local_checkpoint_state.jsonl via checkpoint_utils. - Add checkpoint_utils.py: ResumeState, resolve_resume(), load_dcp(), save_loop_state(), dataset_fingerprint(), validate_dataset() - Delete resume.py and ResumeConfig dataclass - Track data_consumed in SFT and RL loops for dataset position persistence - Add init_from_checkpoint config for loading pretrained DCP weights on a fresh dataset (supports cross-job "job_id:checkpoint_name" format) - Make ref_logprobs optional in RL losses (grpo, dapo, gspo, cispo) so kl_beta=0 works without a reference model - Log perf/dcp_load_time to wandb on resume - Update all 4 recipe loops (rl, sft, dpo, orpo) and e2e resume tests Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
…h override Made-with: Cursor
Made-with: Cursor
…= 2 steps Made-with: Cursor
Made-with: Cursor
Made-with: Cursor
When init_from_checkpoint is explicitly set, it now takes priority over the existing local_checkpoint_state.jsonl. The old state file is cleared so the new run starts fresh from step=0 with the specified DCP weights. Previously, resolve_resume checked the state file first (priority 1), which silently ignored init_from_checkpoint when a state file existed. This caused resumed runs to complete immediately with no new training. Made-with: Cursor
…step 0) Made-with: Cursor
- Add save_weights_for_sampler_ext() to ReconnectableClient wrapper so recipes never need to reach into client.inner - Replace all client.inner.save_state() with client.save_state() (SFT loop had 2 occurrences) - Replace all client.inner.save_weights_for_sampler_ext() with client.save_weights_for_sampler_ext() (SFT + ORPO) - Add missing DCP save to ORPO final checkpoint (was only saving sampler/HF format, no optimizer state for resume) - Add missing DCP save to DPO final checkpoint (was conditional on hotload interval, now always saves DCP for resume) Made-with: Cursor
Made-with: Cursor
- Fix test_smoke_imports: replace deleted training.utils.resume with training.utils.checkpoint_utils - Fix test_shape_override_paths: validated path now passes max_context_length from profile (not None) - Add 22 unit tests for checkpoint_utils: resolve_resume (fresh start, state file resume, init_from_checkpoint, cross-job, override), data_consumed slicing, dataset_fingerprint, validate_dataset, validate_training_shape, save_loop_state Made-with: Cursor
Made-with: Cursor
mayinghan
reviewed
Mar 10, 2026
| wandb_log({"train/step": 0, "infra/total_boot_time": infra_boot_time}, step=0) | ||
|
|
||
| step_offset, _ = setup_resume(policy, ResumeConfig()) | ||
| from training.utils.checkpoint_utils import resolve_resume, load_dcp |
Contributor
There was a problem hiding this comment.
maybe move this to the top
mayinghan
reviewed
Mar 10, 2026
|
|
||
| step_offset, _ = setup_resume(policy, ResumeConfig()) | ||
| from training.utils.checkpoint_utils import resolve_resume, load_dcp | ||
| state = resolve_resume("./frozen_lake_logs") |
Contributor
There was a problem hiding this comment.
where is this path defined
mayinghan
approved these changes
Mar 10, 2026
added 8 commits
March 10, 2026 00:14
Made-with: Cursor
This reverts commit eda0f23.
Switch checkpoint persistence from custom local_checkpoint_state.jsonl to tinker_cookbook's checkpoints.jsonl format. Import get_last_checkpoint from tinker_cookbook for reading; implement sync save_checkpoint that stores cross-job refs resolvable by any future trainer job. - Rewrite checkpoint_utils.py: ResumeState -> ResumeInfo, save_loop_state -> save_checkpoint, load_dcp -> resolve_resume (loads directly) - SFT loop: use SupervisedDatasetFromHFDataset for batch-indexed iteration with per-epoch reshuffling via set_epoch() - RL loop: add RLPromptDataset for batch-indexed iteration, pass fw_api_key to ReconnectableClient (fixes shared dev auth) - Remove backward-compat fallbacks in supervised.py (datum_from_tokens_weights) - Pin tinker-cookbook to latest commit (d7fb423) - Update all recipe files, examples, and tests Made-with: Cursor
Phase 2 was missing deployment_shape, causing creation failure. Now captures Phase 1's deployment_id and reuses it. Added try/finally to scale deployment to zero after test completes. Made-with: Cursor
Made-with: Cursor
Remove hardcoded log_path defaults from SFT, RL, DPO, and ORPO Config dataclasses. Callers must now provide log_path explicitly, preventing checkpoint collisions between runs and test pollution. Matches tinker_cookbook's pattern. Add log_path to FrozenLakeConfig and replace the inline hardcoded string. Update all __main__ blocks, examples, and test Configs. Made-with: Cursor
Verify all 4 recipe Configs reject construction without log_path, accept it when provided, and test the full save -> resume roundtrip with directory creation. Made-with: Cursor
Made-with: Cursor
Hecate0821
force-pushed
the
chengxili/unified-resume
branch
from
March 10, 2026 22:13
0e5709c to
134db61
Compare
Delete dataset_fingerprint, validate_dataset, validate_training_shape from checkpoint_utils -- these were Fireworks-specific validation checks that added complexity without real value. Remove dataset_fingerprint and training_shape_id from ResumeInfo and all loop_state dicts in save_checkpoint calls. Made-with: Cursor
Hecate0821
pushed a commit
that referenced
this pull request
Mar 11, 2026
ResumeConfig was removed in #187. Update configuration reference to describe log_path + checkpoints.jsonl resume pattern. Made-with: Cursor
1 task
Hecate0821
added a commit
that referenced
this pull request
Mar 11, 2026
ResumeConfig was removed in #187. Update configuration reference to describe log_path + checkpoints.jsonl resume pattern. Made-with: Cursor Co-authored-by: Chengxi Li <chengxili@Chengxis-MacBook-Pro.local>
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.
Summary
Replaces the dual-path resume logic (
ResumeConfig+setup_resumeregex parsing) with a single source of truth:checkpoints.jsonl(tinker_cookbook format) via a rewrittencheckpoint_utilsmodule. Also adoptsSupervisedDatasetFromHFDatasetfor SFT and addsRLPromptDatasetfor batch-indexed RL iteration.What we import from tinker_cookbook
get_last_checkpoint(log_dir)checkpoints.jsonlat resume timeCHECKPOINTS_BASE_NAME"checkpoints.jsonl"SupervisedDatasetFromHFDatasetget_batch(i)+set_epoch(seed)renderers(already used)What we implement ourselves (and why)
save_checkpointsave_checkpoint_asyncstores logical names asstate_path; Fireworks cross-job resume needscross_job://refs resolved viaresolve_checkpoint_pathat save timeresolve_resumeTrainingClientfrom checkpoint; Fireworks RLOR loads into an existing client bound to a trainer job viaload_state_with_optimizersave_checkpoint_asyncrequires async context; our RL callbacks (finish_step) run sync viaasyncio.to_thread; tinker_cookbook's sync wrapper usesasyncio.run()which fails inside an existing event loopRLPromptDatasetRLDataset.get_batch()returnsEnvGroupBuilder(RL gymnasium types we don't use); ours returns raw row dictsCheckpoint format
checkpoints.jsonl— append-only JSONL inlog_path. Each line written after every DCP save:{"name": "step-2", "step": 2, "data_consumed": 16, "source_job_id": "abc123", "state_path": "cross_job://abc123/step-2"}The
state_pathis across_job://reference resolved at save time, so any future trainer job can load it directly.Key changes
checkpoint_utils.py(rewritten, 115 lines):ResumeInfo,resolve_resume(),save_checkpoint(). No validation helpers (removeddataset_fingerprint,validate_dataset,validate_training_shape).resume.py(deleted): oldsetup_resume+ResumeConfigremovedsft_loop.py: UsesSupervisedDatasetFromHFDatasetfor batch-indexed iteration with per-epoch reshufflingrl_loop.py: UsesRLPromptDatasetfor batch-indexed iteration; passesfw_api_keytoReconnectableClient(fixes shared dev auth)supervised.py: Removed backward-compattry/except ImportErrorfallbacks fordatum_from_tokens_weightslog_path: Required field (no default) on all recipe Configs — prevents checkpoint collisionspyproject.toml: tinker-cookbook pinned tod7fb423(latest)Files changed (38)
checkpoint_utils.py(rewrite),resume.py(delete)config.py,__init__.py,validation.py,client.py,infra.pyrl_loop.py,sft_loop.py,dpo_loop.py,orpo_loop.pydata.py(addRLPromptDataset),supervised.py(remove fallbacks)grpo.py,dapo.py,gspo.py,cispo.py,losses.pytrain_frozen_lake.py,train_deepmath.py,train_sft.pyE2E test results
SFT: Phase 1 trained 5 steps (loss 4.11 → 0.00001), saved to
checkpoints.jsonlwithcross_job://refs. Phase 2 created a new job, loaded checkpoint, continued from step 5 to step 8.data_consumedincreased from 40 to 64 (dataloader continued, not restarted).GRPO: Phase 1 trained 3 steps with hotloading + deployment on qwen3-30b-a3b (MoE). Phase 2 reused the deployment, loaded cross-job checkpoint, continued training.
data_consumedincreased correctly.Test plan