Skip to content

feat: add HF-backed checkpoint storage#63

Merged
SoheylM merged 8 commits into
mainfrom
codex/hf-checkpoint-backend
Jun 11, 2026
Merged

feat: add HF-backed checkpoint storage#63
SoheylM merged 8 commits into
mainfrom
codex/hf-checkpoint-backend

Conversation

@SoheylM

@SoheylM SoheylM commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add a shared checkpoint backend with HF, W&B, local, and auto resolution paths
  • route training entrypoints through the new checkpoint packaging flow while keeping W&B compatibility
  • update evaluators and surrogate-model loading to prefer HF packages with W&B fallback
  • document the new workflow and add a migration playbook for historical W&B checkpoints

Validation

  • conda run -n engibench python -m py_compile on modified Python files
  • conda run -n engibench ruff check on modified files
  • conda run -n engibench mypy --follow-imports=skip engiopt/checkpoint_store.py engiopt/surrogate_model/run_pe_optimization.py engiopt/vqgan/evaluate_vqgan.py
  • local checkpoint package resolution smoke test

Follow-up

  • run authenticated smoke tests for HF-backed save and legacy W&B restore before review

@SoheylM

SoheylM commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

@mkeeler43 requesting your review on this one. This PR adds an HF-backed checkpoint backend for EngiOpt so new model weights can live on Hugging Face instead of saturating W&B artifact storage, while keeping backward-compatible restore support for existing W&B-hosted checkpoints. It also packages run config and metadata with the checkpoint so new HF-backed runs remain reproducible and tied back to the originating W&B run.

@SoheylM SoheylM requested a review from mkeeler43 April 23, 2026 07:58
Tightens the HF checkpoint backend so HuggingFace is the sole storage
backend for model weights. W&B remains in use for media, scalars, and
run lineage, but no longer receives model artifacts.

- CheckpointBackend -> Literal["hf", "none"]; drop "wandb"/"both" writes
- save_checkpoint_package: drop wandb_artifacts param and W&B-write branch
- resolve_named_checkpoint: add wandb_artifact_alias override so callers
  with custom alias schemes (e.g. LVAE's seed_<s>_rec<r>_perf<p>) can
  reach legacy artifacts during the transition
- _resolve_wandb_package / _build_wandb_artifact_path: parameterize alias
- 15 training scripts: drop the now-unused wandb_artifacts={...} kwarg
- README: document HF-only writes and the transitional W&B read fallback

The W&B read fallback (ModelSource="wandb") is preserved as a safety net
for runs trained before the HF cutover; it will be removed in a later
cleanup pass once in-use artifacts are migrated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mkeeler43 and others added 4 commits May 28, 2026 17:11
The HF-backed checkpoint flow now mirrors the W&B media flow exactly:

  Training:
    --track --wandb-entity X --wandb-project Y    (media to W&B)
    --save-model --hf-entity Z --hf-repo-prefix W (checkpoint to HF)

  Evaluation:
    --hf-entity Z --hf-repo-prefix W              (pull from HF)

Removed flags (rolled into sensible defaults inside the call sites):
  - --checkpoint-backend  (always "hf"; --save-model is the on/off)
  - --hf-private          (always public; create private repos manually
                           if needed -- create_repo(exist_ok=True) won't
                           override an existing repo's visibility)
  - --model-source        (always "auto": HF first, W&B fallback)
  - --local-model-dir     (power-user; can be re-added later)

The W&B read-fallback is still preserved inside checkpoint_store as a
safety net for runs trained before the HF cutover; users no longer need
a CLI flag to reach it.

Also fixed a pre-existing reportUndefinedVariable in
run_pe_optimization.load_model_from_reference (model_source was
referenced without being a parameter; now passed as "auto").

Updated 15 training scripts + 14 evaluator scripts + README.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nce calls

load_model_from_reference does not accept model_source; my earlier
simplification pass left two now-invalid kwargs at the call sites.
The wrapper internally passes model_source="auto" so callers don't
need to specify it.

Fixes mypy CI failure on PR #71.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
refactor(checkpoints): HF-only writes; configurable W&B read alias
…ackend

# Conflicts:
#	README.md
#	engiopt/cgan_cnn_2d/evaluate_cgan_cnn_2d.py
@SoheylM SoheylM marked this pull request as ready for review June 11, 2026 15:23
@SoheylM

SoheylM commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

I re-checked this before merging. Local and remote branch state match exactly, CI is green, the branch is up to date with main with no merge conflicts, and I verified the HF checkpoint flow end to end with a fresh smoke train/upload/load test. I approve the merge and I am merging this now.

@SoheylM SoheylM merged commit 65cb0ee into main Jun 11, 2026
3 checks passed
@SoheylM SoheylM deleted the codex/hf-checkpoint-backend branch June 11, 2026 15:26
AnnaDelbeke pushed a commit to AnnaDelbeke/EngiOpt that referenced this pull request Jun 26, 2026
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