Conversation
The gate that reloads `best.tar` before exporting ORed `args.export_qonnx` with itself, so running with only `--export_qcdq_onnx` skipped the reload and exported the last-epoch weights instead of the best checkpoint. The two other places in this file that gate on "some ONNX export was requested" already use `export_qonnx or export_qcdq_onnx`. Signed-off-by: Anai-Guo <antai12232931@outlook.com>
This branch has not been deployed
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.
What
In
Trainer.train_model, the gate that reloads the best checkpoint before exporting ORsargs.export_qonnxwith itself:Why it matters
Running
bnn_pynq_train.py --export_qcdq_onnxwithout--export_qonnx:Trainer.__init__creates the ONNX output dir (that check is spelled correctly).Trainer.validateasserts JIT is disabled (also spelled correctly).export_qonnxis inspected.self.export_qcdq_onnx()then exportsself.modelas it stands after the last epoch, not the best checkpoint.So the QCDQ export silently ships the wrong weights, with no error and no warning. Every other place in this file that means "some ONNX export was requested" already writes both flags:
trainer.py:94—if args.export_qonnx or args.export_qcdq_onnx:(create the output dir)trainer.py:215—if args.export_qonnx or args.export_qcdq_onnx:(assert JIT is off)trainer.py:349is the only one that does not, which is what this PR fixes.Not affected
--export_qonnx(alone or with--export_qcdq_onnx): condition was already true, stays true.🤖 Generated with Claude Code