Skip to content

Add BAM-MP-core Preview model#371

Open
Godorina wants to merge 6 commits into
janosh:mainfrom
Godorina:bam-mp-core
Open

Add BAM-MP-core Preview model#371
Godorina wants to merge 6 commits into
janosh:mainfrom
Godorina:bam-mp-core

Conversation

@Godorina

@Godorina Godorina commented Jul 8, 2026

Copy link
Copy Markdown

Description

Could a maintainer please apply the ingest-model label to run the full upstream ingest for bam-mp-core?

This PR replaces/continues #355, and the branch has been updated with latest main.

Checklist

Please open PRs as draft and only mark as ready to review after checking off the following items:

  • I created a new folder and YAML metadata file models/BAM/bam-mp-core.yml for my submission. BAM is the name of the architecture and bam-mp-core.yml includes things like author details, training set names and important hyperparameters.
  • I added the new model as a new attribute Model.bam_mp_core enum on the Model enum in enums.py.
  • I uploaded the energy/force/stress model prediction file for the WBM test set to Figshare or another cloud storage service (2026-05-09-wbm-IS2RE.csv.gz).
  • I uploaded the model-relaxed structures file to Figshare or another cloud storage service in JSON lines format (2026-05-09-wbm-geo-opt-FIRE.jsonl.gz).
  • I uploaded the phonon predictions to Figshare or another cloud storage service (2026-05-09-kappa-103-FIRE-dist=0.03-fmax=1e-4-symprec=1e-5.json.gz).
  • I have uploaded the diatomic predictions to Figshare or another cloud storage service (<yyyy-mm-dd>-diatomics.json.gz). Not submitted for BAM-MP-core.
  • I included the urls to the Figshare files in the YAML metadata file (models/BAM/bam-mp-core.yml).
  • I included the test scripts (test_bam_mp_core_discovery.py and test_bam_mp_core_kappa.py) that generated the prediction files.
  • I have run uv run python scripts/ingest_model.py bam-mp-core to check metadata and generate the plots needed for submission.
  • I have installed/run the pre-commit hooks (uvx prek) and ensured all checks are passing.

Marking your PR as ready to review will trigger an automated code review, please address any issues raised by the automated review. For the maintainers minimizing the final human review process enables us to merge your submissions much faster!

Additional Information (Optional)

  • I included a training script (train_<arch_name>.py) if I trained a model specifically for this benchmark.
  • I included a readme.md with additional details about my model.

Summary by CodeRabbit

  • New Features
    • Added BAM-MP-core to the supported model set and surfaced its results across the site’s evaluation views and figures.
    • Added end-to-end discovery and thermal conductivity evaluation scripts for BAM-MP-core, including generation of the associated CSV/JSONL artifacts.
  • Documentation
    • Published a complete BAM-MP-core model card with metadata, requirements, and reported benchmark/performance metrics.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a1a6db9f-f270-43b9-af08-47e915784057

📥 Commits

Reviewing files that changed from the base of the PR and between d8a0bd2 and 6270782.

📒 Files selected for processing (1)
  • models/BAM/test_bam_mp_core_discovery.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • models/BAM/test_bam_mp_core_discovery.py

📝 Walkthrough

Walkthrough

Adds BAM-MP-core to the benchmark through model registration, a YAML model card, discovery and thermal-conductivity evaluation scripts, and BAM-MP-core records in site metric datasets.

Changes

BAM-MP-core model addition

Layer / File(s) Summary
Model enum registration and model card metadata
matbench_discovery/enums.py, models/BAM/bam-mp-core.yml
Adds the bam_mp_core enum member and model-card metadata, requirements, hyperparameters, and phonon, geometry-optimization, and discovery metrics.
Discovery evaluation workflow
models/BAM/test_bam_mp_core_discovery.py
Adds checkpoint validation, resumable split-aware WBM relaxation, BAM calculator integration, progress persistence, and discovery artifact generation.
Kappa evaluation workflow
models/BAM/test_bam_mp_core_kappa.py
Adds checkpoint normalization, BAM-based relaxation, phonon3py force-constant calculations, thermal-conductivity evaluation, and compressed result output.
Published BAM-MP-core site metrics
site/src/figs/*.jsonl, site/src/routes/models/per-element-each-errors.jsonl
Adds BAM-MP-core records to figure and per-element error datasets.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested labels: site, phonons, model update, tests, ingest-model

Suggested reviewers: janosh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: adding the BAM-MP-core preview model.
Description check ✅ Passed The description matches the template and is mostly complete; only the noncritical diatomic submission item remains unchecked.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
models/BAM/test_bam_mp_core_kappa.py (1)

175-197: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Record the model package version in run_params for reproducibility.

versions captures only numpy and torch. For a benchmark submission, the model package (bam-torch) and ideally ase/phono3py versions materially affect reproducibility of the kappa numbers.

♻️ Suggested change
-        "versions": {dep: version(dep) for dep in ("numpy", "torch")},
+        "versions": {
+            dep: version(dep)
+            for dep in ("numpy", "torch", "ase", "phono3py", "bam-torch")
+        },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@models/BAM/test_bam_mp_core_kappa.py` around lines 175 - 197, The run_params
metadata in test_bam_mp_core_kappa.py is missing the model package version, so
update the versions field in the run_params dictionary to also record bam-torch
and, if available in this benchmark environment, ase and phono3py alongside
numpy and torch. Use the existing version(...) pattern in the run_params
construction so the resulting run_params.json captures all key package versions
needed for reproducibility.
models/BAM/test_bam_mp_core_discovery.py (1)

93-124: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Checkpoint download has no checksum verification.

ensure_checkpoint only checks Content-Length matches the downloaded size, unlike DataFiles.path (enums.py maybe_auto_download_file(..., md5=expected_md5)) which verifies an md5 checksum. A truncated-but-matching-length or corrupted download of the model checkpoint would silently proceed to load a bad checkpoint. Consider adding an md5/sha256 check against a known value, mirroring the existing DataFiles pattern in the codebase.

🛡️ Sketch of adding checksum verification
-def ensure_checkpoint(path: Path) -> Path:
+def ensure_checkpoint(path: Path, expected_md5: str | None = None) -> Path:
     if path.is_file():
         print(f"Using BAM-MP-core checkpoint: {path}")
         return path
     ...
         tmp_path.replace(path)
     finally:
         tmp_path.unlink(missing_ok=True)
+    if expected_md5 is not None:
+        import hashlib
+        actual = hashlib.md5(path.read_bytes()).hexdigest()  # noqa: S324
+        if actual != expected_md5:
+            path.unlink(missing_ok=True)
+            raise OSError(f"Checkpoint md5 mismatch: expected {expected_md5}, got {actual}")
     print("Download complete.")
     return path
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@models/BAM/test_bam_mp_core_discovery.py` around lines 93 - 124, The
ensure_checkpoint helper currently validates only file size, so a corrupted BAM
checkpoint can still be accepted. Update ensure_checkpoint to verify the
downloaded file against a known checksum (md5 or sha256) before replacing the
final path, ideally by mirroring the existing DataFiles path /
maybe_auto_download_file pattern in enums.py and using the same checksum value
source for the BAM checkpoint. Keep the current Content-Length and empty-file
checks, but add a checksum validation step in ensure_checkpoint so bad downloads
are rejected before the checkpoint is loaded.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@models/BAM/test_bam_mp_core_discovery.py`:
- Around line 358-406: The per-structure blanket exception handling in the
relaxation loop can hide a systemic failure and let the job finish with almost
no successful structures. Update the try/except around the
FIRE/FrechetCellFilter relaxation block to fail fast when failures become
repetitive or exceed an early threshold, using the existing n_failed/n_success
counters in the main loop to detect a run-wide problem. Keep the first few
traceback prints for debugging, but re-raise or abort after too many consecutive
or total failures so the workflow cannot continue silently into downstream
artifact writing with an empty result set.
- Around line 371-374: The relaxation test currently relies on
dyn.optimizable.gradient_norm(...), which depends on ASE’s internal Optimizable
API and can fail on older ase releases. Update the test to avoid that
dyn.optimizable dependency by using only stable Optimizer/Atoms methods, or
explicitly raise the minimum ASE version so the Optimizable interface is
guaranteed. Keep the existing dyn.get_number_of_steps() usage and adjust the
final_fmax calculation in the BAM test helper accordingly.

---

Nitpick comments:
In `@models/BAM/test_bam_mp_core_discovery.py`:
- Around line 93-124: The ensure_checkpoint helper currently validates only file
size, so a corrupted BAM checkpoint can still be accepted. Update
ensure_checkpoint to verify the downloaded file against a known checksum (md5 or
sha256) before replacing the final path, ideally by mirroring the existing
DataFiles path / maybe_auto_download_file pattern in enums.py and using the same
checksum value source for the BAM checkpoint. Keep the current Content-Length
and empty-file checks, but add a checksum validation step in ensure_checkpoint
so bad downloads are rejected before the checkpoint is loaded.

In `@models/BAM/test_bam_mp_core_kappa.py`:
- Around line 175-197: The run_params metadata in test_bam_mp_core_kappa.py is
missing the model package version, so update the versions field in the
run_params dictionary to also record bam-torch and, if available in this
benchmark environment, ase and phono3py alongside numpy and torch. Use the
existing version(...) pattern in the run_params construction so the resulting
run_params.json captures all key package versions needed for reproducibility.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bd5bfe0f-70c8-4cd1-93d3-70e6baa29a64

📥 Commits

Reviewing files that changed from the base of the PR and between 3a30f1d and d8a0bd2.

📒 Files selected for processing (15)
  • matbench_discovery/enums.py
  • models/BAM/bam-mp-core.yml
  • models/BAM/test_bam_mp_core_discovery.py
  • models/BAM/test_bam_mp_core_kappa.py
  • site/src/figs/box-hull-dist-errors.jsonl
  • site/src/figs/cumulative-precision-recall.jsonl
  • site/src/figs/element-prevalence-vs-error.jsonl
  • site/src/figs/hist-clf-pred-hull-dist.jsonl
  • site/src/figs/hist-largest-each-errors-fp-diff.jsonl
  • site/src/figs/kappa-103-analysis.jsonl
  • site/src/figs/roc-models.jsonl
  • site/src/figs/rolling-mae-vs-hull-dist.jsonl
  • site/src/figs/scatter-largest-each-errors-fp-diff.jsonl
  • site/src/figs/scatter-largest-fp-diff-each-error.jsonl
  • site/src/routes/models/per-element-each-errors.jsonl

Comment thread models/BAM/test_bam_mp_core_discovery.py
Comment thread models/BAM/test_bam_mp_core_discovery.py Outdated
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