Skip to content

Consolidate retraining epochs into per-fold JSON and silence parallel fold logs#4

Merged
varunccf merged 1 commit into
mainfrom
copilot/add-epochs-to-json
Jul 1, 2026
Merged

Consolidate retraining epochs into per-fold JSON and silence parallel fold logs#4
varunccf merged 1 commit into
mainfrom
copilot/add-epochs-to-json

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown

The parallel CV runner in examples/quantum/classification.py wrote a redundant epochs.json even though each fold_<n>_results.json already carried the retraining history, and worker processes printed heavily interleaved progress messages to the terminal.

Changes

  • Drop epochs.json: removed the post-run aggregation block. Per-epoch history stays where it already lives — inside each fold's own checkpoint (q_epochs, q_final_epoch, q_final_error).
  • Quiet parallel workers: run_fold now executes its body under contextlib.redirect_stdout(os.devnull), so concurrent folds no longer race for stdout. The main process still renders the stderr progress bar during the run and prints the aggregated CV summary once all folds complete.
# examples/quantum/classification.py
def run_fold(fold_num, ...):
    checkpoint_file = f"fold_{fold_num}_results.json"
    with open(os.devnull, "w") as _devnull, contextlib.redirect_stdout(_devnull):
        return _run_fold_body(fold_num, ..., checkpoint_file)

The fold body is factored into _run_fold_body purely so the redirect wrapper doesn't force re-indenting the whole function; behavior of the fold computation and checkpoint format are otherwise unchanged.

@varunccf varunccf marked this pull request as ready for review July 1, 2026 15:35
@varunccf varunccf merged commit ae92fde 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