Skip to content

fix(ml): keep mixed stage-B data, batch and base model on resume - #29

Merged
Mani212005 merged 3 commits into
mainfrom
fm/digisim-t5-resume-fix
Nov 17, 2026
Merged

Mani212005 merged 3 commits into
mainfrom
fm/digisim-t5-resume-fix

Conversation

@Mani212005

Copy link
Copy Markdown
Owner

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

  • Resuming a run in ml/train.py and ml/kaggle/train_kaggle.py now keeps the run's recorded base model and total batch size (unless --batch overrides it). It also passes the rebuilt mixed/oversampled data yaml 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.json now records resumed_from and dataset.data_effective (the effective data yaml actually used for training).
  • Added resume regression tests in ml/tests/test_train_harness.py and updated agent_docs/ml-pipeline.md to 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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Resume a relocated stage-B mixed run via ml/train.py: it trains on the oversampled data_mixed.yaml, loads last.pt, keeps the original base model and batch in config.yaml and metrics, and records resum… ✅ pass live pytest tests/test_train_harness.py::test_resume_of_relocated_mixed_run_keeps_data_config_and_metrics passes on the fix and fails on base 15d7052 (coco8.yaml fallback)
Resume a copied Kaggle stage-B run via ml/kaggle/train_kaggle.py: same guarantees (mixed data yaml passed, base model and total batch inherited, resumed_from and data_effective recorded) ✅ pass live pytest tests/test_train_harness.py::test_kaggle_resume_of_relocated_mixed_run_keeps_data_config_and_metrics passes on the fix and fails on base (coco8.yaml fallback)
Existing resume behaviour still works: oversampling is kept on a plain resume, and a first run records resumed_from as null ✅ pass live pytest tests/test_train_harness.py -k resume (5 passed) and the full file (33 passed, 1 skipped)
Evidence: Pre-fix vs post-fix regression result
base code: FAILED test_resume_of_relocated_mixed_run_keeps_data_config_and_metrics (coco8.yaml != moved/b/data_mixed.yaml); FAILED test_kaggle_resume_of_relocated_mixed_run_keeps_data_config_and_metrics (coco8.yaml != moved/kaggle/data.yaml)
fixed code: 33 passed, 1 skipped in tests/test_train_harness.py

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 metrics settings.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 pass data. 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 feeds YOLO(plan["model"]) the base model and never loads last.pt. The Kaggle summary at line 513 also lacks the resumed_from and data_effective fields that train.py now records. The Kaggle resume test only asserts that resume is 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.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Resume a relocated stage-B mixed run via ml/train.py: it trains on the oversampled data_mixed.yaml, loads last.pt, keeps the original base model and batch in config.yaml and metrics, and records resum… ✅ pass live pytest tests/test_train_harness.py::test_resume_of_relocated_mixed_run_keeps_data_config_and_metrics passes on the fix and fails on base 15d7052 (coco8.yaml fallback)
Resume a copied Kaggle stage-B run via ml/kaggle/train_kaggle.py: same guarantees (mixed data yaml passed, base model and total batch inherited, resumed_from and data_effective recorded) ✅ pass live pytest tests/test_train_harness.py::test_kaggle_resume_of_relocated_mixed_run_keeps_data_config_and_metrics passes on the fix and fails on base (coco8.yaml fallback)
Existing resume behaviour still works: oversampling is kept on a plain resume, and a first run records resumed_from as null ✅ pass live pytest tests/test_train_harness.py -k resume (5 passed) and the full file (33 passed, 1 skipped)
  • 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 sources
  • uv run pytest tests/test_train_harness.py full file on the fixed code (33 passed, 1 skipped)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

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.
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
digisim Ready Ready Preview Nov 17, 2026 10:10pm UTC

@netlify

netlify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for digisim canceled.

Name Link
🔨 Latest commit 8eccd47
🔍 Latest deploy log https://app.netlify.com/projects/digisim/deploys/6afcd07f0844c96676ec8936

@Mani212005
Mani212005 merged commit 8008b3f into main Nov 17, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — 8eccd47b Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant