Skip to content

Quiet per-epoch logs in quantum classification example; add fold progress bar and aggregated epochs.json#3

Merged
varunccf merged 2 commits into
mainfrom
copilot/store-epochs-in-dictionary
Jul 1, 2026
Merged

Quiet per-epoch logs in quantum classification example; add fold progress bar and aggregated epochs.json#3
varunccf merged 2 commits into
mainfrom
copilot/store-epochs-in-dictionary

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown

examples/quantum/classification.py runs 5 CV folds in parallel and each worker's per-epoch prints interleave chaotically. This PR silences those prints, captures the epoch curves as structured data, and surfaces overall progress via a single progress bar.

Changes

  • QuantumClassificationModel.retrain (hdlib/model/classification.py)

    • New optional verbose: bool = True kwarg — default preserves existing behavior.
    • Records per-epoch error on self.retrain_history_ as [{"epoch": int, "error": float}, ...], including epoch 0 and the early-exit path. Callers no longer need to parse stdout.
  • examples/quantum/classification.py

    • run_fold calls retrain(..., verbose=False) and adds q_epochs, q_final_epoch, q_final_error to each fold's results dict (also persisted in the existing fold_<n>_results.json).
    • Replaced the --- COMPLETED FOLD n/N --- prints with an in-place stderr progress bar driven by as_completed:
      Progress: [################------------------------]  40.00%  (2/5 folds)
      
    • After all folds finish, writes a single aggregated epochs.json keyed by fold_<n> with each fold's epoch curve and final stats.

Resulting output layout

Unchanged except for the added epochs file:

  • fold_1_results.jsonfold_5_results.json (now also include q_epochs)
  • epochs.json — per-fold epoch history in one place

@varunccf varunccf marked this pull request as ready for review July 1, 2026 14:58
@varunccf varunccf merged commit 8fe5831 into main Jul 1, 2026
8 checks passed
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.

2 participants