Skip to content

Parallelize 5-fold CV and disable QSVC/VQC baselines in quantum classification example#2

Merged
varunccf merged 2 commits into
mainfrom
copilot/parallelize-sequential-folds
Jun 30, 2026
Merged

Parallelize 5-fold CV and disable QSVC/VQC baselines in quantum classification example#2
varunccf merged 2 commits into
mainfrom
copilot/parallelize-sequential-folds

Conversation

Copilot AI commented Jun 30, 2026

Copy link
Copy Markdown

The 5-fold cross-validation in examples/quantum/classification.py ran folds sequentially and unconditionally trained QSVC and VQC baselines. This PR runs all folds concurrently and comments out the QSVC/VQC paths.

Parallel folds

  • Extracted the per-fold body (checkpoint load, classical D=10000, classical D=32, quantum HDC, checkpoint save) into a module-level run_fold(...) so it can be pickled.
  • Replaced the for ... in kf.split(...) loop with a ProcessPoolExecutor(max_workers=N_SPLITS) that submits all 5 folds at once and collects results via as_completed.
  • Aggregation into the classical_* / quantum_* lists happens after the pool drains, sorted by fold number, so downstream summaries are byte-identical to the sequential run.
  • Processes (not threads) because the work is CPU/simulator-bound; expect ~5× memory.
with ProcessPoolExecutor(max_workers=N_SPLITS) as executor:
    futures = [
        executor.submit(run_fold, fold_num, train_idx, test_idx,
                        X_cv_pool, y_cv_pool, X_cv_pool_np, y_cv_pool_np,
                        dimensionality, N_SPLITS)
        for fold_num, (train_idx, test_idx) in fold_splits
    ]
    for future in as_completed(futures):
        fold_num, fold_data = future.result()
        results_by_fold[fold_num] = fold_data

Disabled QSVC/VQC

  • Commented out the qiskit imports used only by these baselines (COBYLA, Z/ZZFeatureMap, RealAmplitudes, VQC, QSVC, ComputeUncompute, FidelityQuantumKernel, StatevectorSampler).
  • Commented out the QSVC and VQC blocks in run_fold, the corresponding entries in the fold_data checkpoint dict, and — in __main__ — the vqc_* / qsvc_* list inits, aggregation, print_cv_summary calls, ROC data prints (section 6), and ROC plot-point calculations (section 7).
  • Classical (D=10000, D=32) and Quantum HDC paths are untouched.

@varunccf varunccf marked this pull request as ready for review June 30, 2026 20:13
@varunccf varunccf merged commit 30fd0fa into main Jun 30, 2026
8 checks passed
@varunccf varunccf deleted the copilot/parallelize-sequential-folds branch June 30, 2026 20:14
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