Add MatterGen crystal diffusion score-core export - #731
justinchuby wants to merge 4 commits into
Conversation
Validate the official mp_20_base score core against pinned MatterGen source and a source-derived golden fixture. Cover PBC invariance and the dft_band_gap adapter's conditional and unconditional score paths. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 332c98c9-cf56-4bab-8552-ac1b6d730556 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Export the pinned official MatterGen GemNet-T score core with Hydra configuration parsing, exhaustive checkpoint routing, a documented dynamic PBC graph ABI, and CLI integration. Add a source-faithful CPU host sampler with the released D3PM/VE/VP schedule and a real ONNX sampling golden while explicitly retaining host orchestration in the partial export report. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 332c98c9-cf56-4bab-8552-ac1b6d730556 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Performance Comparison
|
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of concrete robustness issues (artifact validation in the parity fixture and CLI error handling for save-time failures) that should be fixed before merging.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a first-class Mobius integration for the pinned microsoft/mattergen release by exporting the deterministic float32 GemNet‑T score core to standard ONNX, while explicitly keeping periodic graph construction and the diffusion/sampling loop as host-owned responsibilities (with a provided CPU host runtime).
Changes:
- Add MatterGen score-core model +
MatterGenScoreTaskexporting an explicit periodic-graph + condition-port ABI, plus strict Lightning checkpoint routing. - Add a source-faithful CPU host runtime (
MatterGenHostSampler) including periodic graph/triplet construction and the full 1,000-step schedule around a pluggable score callback. - Add CLI entrypoint support (
--mattergen-checkpoint), documentation, and L3/L4/L5 parity + golden tests.
File summaries
| File | Description |
|---|---|
| tests/integration/mattergen_parity_test.py | Adds pinned-source L3/L4 parity and an L5 host-sampling golden against real weights. |
| tests/cli_test.py | Adds CLI routing/validation tests for MatterGen-specific build behavior. |
| testdata/golden/diffusion/mattergen-mp20-score.json | Adds one-step real-weight score-core golden provenance + outputs. |
| testdata/golden/diffusion/mattergen-mp20-host-sample.json | Adds deterministic 1,000-step host-sampling golden artifact provenance. |
| src/mobius/tasks/_mattergen.py | Introduces MatterGenScoreTask wiring the explicit host ABI and partial export report. |
| src/mobius/tasks/init.py | Registers MatterGenScoreTask and task name mattergen-score. |
| src/mobius/models/mattergen.py | Declares the GemNet‑T score-core graph and strict preprocess/weight-routing behavior. |
| src/mobius/models/init.py | Exposes MatterGen models from the public models package. |
| src/mobius/integrations/mattergen/_weights.py | Adds fail-closed Lightning checkpoint loading + exact initializer routing. |
| src/mobius/integrations/mattergen/_weights_test.py | Unit tests for strict weight loading, routing, and reporting. |
| src/mobius/integrations/mattergen/_runtime.py | Adds the host-owned periodic graph + sampler runtime and ORT callback adapter. |
| src/mobius/integrations/mattergen/_runtime_test.py | Unit tests for periodic graph ordering, CFG call order, and sampler determinism. |
| src/mobius/integrations/mattergen/_contract.py | Defines pinned hub/source commits, host-owned steps, allowlists, and validation helpers. |
| src/mobius/integrations/mattergen/_contract_test.py | Validates the pinned contract constants and helper semantics. |
| src/mobius/integrations/mattergen/_configs.py | Parses expanded Hydra configs into a typed MatterGenConfig without Hydra deps. |
| src/mobius/integrations/mattergen/_builder.py | Adds pinned builder (build_mattergen) supporting Hub or safe local checkpoint roots. |
| src/mobius/integrations/mattergen/_builder_test.py | Tests config parsing, port ABI, pinned revision enforcement, and family coverage. |
| src/mobius/integrations/mattergen/init.py | Adds a lazy public API surface for MatterGen integration symbols. |
| src/mobius/main.py | Adds MatterGen CLI routing and a new --mattergen-checkpoint flag. |
| src/mobius/init.py | Exposes build_mattergen at the package top level. |
| pyproject.toml | Adds PyYAML dependency used for loading pinned Hydra configs. |
| docs/model-catalog.md | Documents MatterGen under periodic crystal diffusion exports. |
| docs/mattergen.md | Adds detailed ABI, host/runtime boundary, and build instructions for MatterGen. |
| docs/index.md | Adds MatterGen docs page to the documentation index. |
Review details
- Files reviewed: 24/24 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
🏗️ Architecture Diff
No architecture changes detected. ✅ Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
Apply the repository Ruff formatting and its equivalent constant attribute assignment cleanup so the MatterGen export passes CI lint. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 332c98c9-cf56-4bab-8552-ac1b6d730556 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Resolve MatterGen review findings by removing the Protocol no-op expression, surfacing existing-destination save errors as CLI errors, and rejecting file paths for the source fixture. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 332c98c9-cf56-4bab-8552-ac1b6d730556 Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Summary
microsoft/mattergen@5244495dd9a979ff71abc7548a0b14b9deb0069asupport for all released checkpoint families.Runtime boundary
ModelPackageremains deliberately partial (end_to_end_runnable: false): periodic neighbor/triplet construction, D3PM/VE/VP scheduling, classifier-free guidance, and crystal validation are host-owned.MatterGenHostSamplersupplies the source-faithful CPU host loop around an explicit ONNX Runtime callback; ONNX Runtime GenAI is not presented as an end-to-end runtime.Evidence
842ffe735f7d06cec89d56aa23d9f001e1124b30.dft_band_gap.mp_20_baseONNX weights and validates the committed deterministic crystal artifact.Limitations
Only CPU/default float32 score-core execution is assessed. f16, bf16, CUDA, and GenAI are explicitly refused. Pymatgen Structure/CIF serialization remains application-owned; the host validates a dependency-free structural artifact.