fix(tf): accept standard checkpoint inputs in change-bias#5702
fix(tf): accept standard checkpoint inputs in change-bias#5702wanghan-iapcm wants to merge 1 commit into
Conversation
The change-bias dispatcher only routed inputs ending in .pb/.pbtxt/.ckpt/ .meta/.data/.index and rejected everything else with "must be a checkpoint file or frozen model file (.pb)". Standard TensorFlow checkpoint prefixes such as model.ckpt-1000 carry no recognized suffix, and checkpoint directories have none either, so the inputs recommended by the CLI docs and the frozen-model fallback message were rejected before _change_bias_checkpoint_file (which already reads the checkpoint state file) could run. Route directory and suffix-less prefix inputs to the checkpoint handler when a TensorFlow "checkpoint" state file is present in the effective directory, and make _change_bias_checkpoint_file resolve checkpoint_dir for a directory input. Add dispatch tests for a step-suffixed prefix and a checkpoint directory. Fix deepmodeling#5683
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesCheckpoint Input Handling
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant change_bias
participant FileSystem
participant ChangeBiasCheckpointFile as _change_bias_checkpoint_file
User->>change_bias: INPUT (checkpoint dir or prefix)
change_bias->>change_bias: check known file suffixes
alt suffix unrecognized
change_bias->>FileSystem: check checkpoint_dir/checkpoint exists
FileSystem-->>change_bias: exists
change_bias->>ChangeBiasCheckpointFile: forward INPUT and args
ChangeBiasCheckpointFile->>ChangeBiasCheckpointFile: derive checkpoint_dir (dir or parent)
else suffix recognized
change_bias->>change_bias: existing dispatch logic
end
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5702 +/- ##
==========================================
- Coverage 81.97% 81.70% -0.27%
==========================================
Files 959 966 +7
Lines 105748 106151 +403
Branches 4102 4139 +37
==========================================
+ Hits 86684 86731 +47
- Misses 17573 17901 +328
- Partials 1491 1519 +28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
njzjz-bot
left a comment
There was a problem hiding this comment.
Looks good to me. The fallback dispatch now accepts both checkpoint directories and standard TensorFlow checkpoint prefixes when a checkpoint state file is present, while preserving the existing handling for explicit checkpoint component files. The added tests cover both newly accepted input forms. CI is green.
Reviewed by OpenClaw 2026.6.8 (844f405)
Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5)
Problem
The TensorFlow
change-biasdispatcher only accepts inputs ending in.pb,.pbtxt,.ckpt,.meta,.data, or.index, and rejects everything else withRuntimeError("The model provided must be a checkpoint file or frozen model file (.pb)").However, the CLI examples and the frozen-model fallback message recommend passing a checkpoint directory, and real TensorFlow checkpoint prefixes commonly look like
model.ckpt-1000. A checkpoint directory has no recognized suffix, and amodel.ckpt-1000prefix ends in-1000, so both are rejected before_change_bias_checkpoint_file()— which already resolves the checkpoint via thecheckpointstate file — can run.Fix
Route suffix-less inputs to the checkpoint handler when a TensorFlow
checkpointstate file is present in the effective directory (the input itself if it is a directory, otherwise its parent). Inputs without such a state file still raise the original error._change_bias_checkpoint_file()now also resolvescheckpoint_dircorrectly when the input is a directory.Test
source/tests/tf/test_change_bias.pypreviously exercised only.pb,.ckpt, and bad-suffix inputs, never a bare directory or ackpt-<step>prefix. Two new tests mock_change_bias_checkpoint_fileand assert it is invoked for amodel.ckpt-1000prefix and for a checkpoint directory that contain acheckpointstate file. On the current dispatcher both raise the "checkpoint file or frozen model file" RuntimeError before reaching the handler; after the fix both route correctly. The existing rejection tests (e.g. amodel.xyzfile with no checkpoint state file) still raise.Fix #5683
Summary by CodeRabbit
Bug Fixes
Tests