Repository navigation
fix(ml): keep mixed stage-B data, batch and base model on resume - #29
Merged
Merged
Conversation
Resuming relocated stage-B runs fell back to ultralytics' default dataset because resume never passed data; batch was re-resolved from the preset and the config recorded last.pt as the base model. Pass the rebuilt mixed yaml on resume, inherit the saved batch, keep the original model on record and write resumed_from and data_effective to metrics.json.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for digisim canceled.
|
This branch was successfully 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.
Intent
DigiSim is a neglected project. Pull up the latest changes in Linux. It is high time to start training the model for it. I have not been able to provide the data. Figure out, get the data, train a model, make improvements and fix that. Do not come to me until you absolutely need me.
Context: the scout report at ~/linux-fleet-home/data/digisim-ml-scout/report.md found that the only trained detector uses 12 gate-era classes and detects nothing on the transistor-first schematics the app now uses, that the transistor-level training data does not exist yet, and that the wire/net tracing assumes left-to-right gates. It split the work into tasks T1-T11 (section 5). T1 (class schema), T2 (synthetic generator v2), T4 (real data), T5 (training harness) , T6 (evaluation harness v2) and T8 (net tracing v2) are merged on the default branch.
This task is a small follow-up from the T5 review: resuming a mixed stage-B run (the stage-B preset with real-data oversampling) silently loses its oversampling and mis-records the config and metrics. It must be fixed before the T7 training runs rely on resume.
What Changed
ml/train.pyandml/kaggle/train_kaggle.pynow keeps the run's recorded base model and total batch size (unless--batchoverrides it). It also passes the rebuilt mixed/oversampleddatayaml to ultralytics, so a resume no longer silently falls back to coco8 when the checkpoint's dataset yaml is gone. The checkpoint itself is loaded from the resume path.metrics.jsonnow recordsresumed_fromanddataset.data_effective(the effective data yaml actually used for training).ml/tests/test_train_harness.pyand updatedagent_docs/ml-pipeline.mdto describe the resume behavior and the new metrics fields.Risk Assessment
✅ Low: The change is small and symmetrical across ml/train.py and ml/kaggle/train_kaggle.py. It inherits the saved base model and total batch, passes the rebuilt mixed data yaml on the resume call, and loads last.pt. The fix-round Kaggle mirror matches the train.py logic, and the new regression tests run fake-YOLO resumes of relocated mixed runs in both trainers.
Testing
The change is confined to the ML training harness, which has no UI or server. I drove train.train and train_kaggle.build_plan/run end to end with a fake YOLO that follows the ultralytics rule of falling back to the resume call's
data(coco8 by default) when the checkpoint's yaml is gone. The new relocated-run tests for both entry points failed on the base code with the coco8 fallback and pass on the fix, and the whole harness test file passes. Real ultralytics, GPU training and a real Kaggle run were not exercised. No UI, so no screenshots were produced.Evidence: Pre-fix vs post-fix regression result
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
ml/kaggle/train_kaggle.py:400- The fix is applied only to ml/train.py. The single-file Kaggle twin, ml/kaggle/train_kaggle.py, still has all three defects. (1) Line 400:model = str(resume), so a resumed run records the last.pt path as its base model in config.yaml and metricssettings.model. (2) Line 427:resolve_batch(args.batch, ...)ignores the saved total batch, so a resumed run records a different batch than the original run (the per-device preset times the GPU count). (3) Line 474:model.train(resume=True, device=..., batch=..., imgsz=..., workers=...)does not passdata. If the checkpoint's recorded dataset yaml is gone (a relocated run dir, which is the usual Kaggle case of resuming from a copied output), ultralytics falls back to coco8. This is the same silent loss of the oversampled mix this change fixes in train.py. Line 473 also feedsYOLO(plan["model"])the base model and never loads last.pt. The Kaggle summary at line 513 also lacks theresumed_fromanddata_effectivefields that train.py now records. The Kaggle resume test only asserts thatresumeis True, so it would not catch this. The user's intent is to make resume safe before the T7 training runs, which may run on Kaggle. Mirror the same three changes in train_kaggle.py and the metrics fields.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
uv run pytest tests/test_train_harness.py -k resume(5 passed)Reverted ml/train.py and ml/kaggle/train_kaggle.py to base 15d7052, ran-k relocated: both new tests failed with coco8.yaml fallback, then restored the sourcesuv run pytest tests/test_train_harness.pyfull file on the fixed code (33 passed, 1 skipped)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.