Skip to content

Comments

Load MACE-OFF pretrained models into DeePMD-GNN for MD simulations#96

Draft
Copilot wants to merge 15 commits intomasterfrom
copilot/add-mace-off-support-sander
Draft

Load MACE-OFF pretrained models into DeePMD-GNN for MD simulations#96
Copilot wants to merge 15 commits intomasterfrom
copilot/add-mace-off-support-sander

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

  • Remove incorrect direct sander interface
  • Implement MACE-OFF loading into MaceModel wrapper
  • Add convert_mace_off_to_deepmd function
  • Update documentation to reflect correct architecture
  • Add examples showing DeePMD-kit integration
  • Remove sander-specific files and tests
  • Add validation for MACE model structure
  • Add error handling for state_dict loading
  • Add warnings when using default parameters
  • Fix code style issues (imports, trailing blanks)
  • Add atomic number validation
  • Refactor default parameter handling
  • Improve code readability and formatting
  • Fix type annotations
  • Add helper function docstrings
  • Add validation for hidden_irreps conversion
  • All code review feedback addressed
  • Add command line interface (deepmd-gnn download-mace-off/convert-mace-off)
  • Add comprehensive unit tests (tests/test_mace_off.py)
  • All pre-commit checks passing
  • Replace mocked tests with real MACE-OFF model tests
  • Replace print statements with proper logging
  • Fix blind exception catching
Original prompt

This section details on the original issue you should resolve

<issue_title>feat: Support MACE-OFF model in QM/MM simulations with sander</issue_title>
<issue_description>This issue tracks the implementation of MACE-OFF model support for QM internal energy correction in sander QM/MM simulations.

Overview

Integrates the MACE-OFF model to improve energy correction accuracy within the QM/MM framework using sander.

Key Changes

  • MACE-OFF model integration for QM energy correction.
  • Interface updates for sander to support MACE-OFF IO.
  • Comprehensive tests and documentation.

Tracks progress for requests #88-#95.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 5 commits February 13, 2026 22:30
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for MACE-OFF model in QM/MM simulations with sander Add MACE-OFF support for sander QM/MM simulations Feb 13, 2026
Copilot AI requested a review from njzjz February 13, 2026 22:39
@njzjz
Copy link
Member

njzjz commented Feb 13, 2026

@copilot, you implemented this PR in the wrong way.

The current implementation is: DeePMD-GNN <--> DeePMD-kit <--> Amber. Thus, you don't need to implement the sander interface directly, but just need to implement a DeePMD-kit wrapper.

We already have a wrapper for the MACE models, but you need to have an interface that can load existing MACE models.

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot, you implemented this PR in the wrong way.

The current implementation is: DeePMD-GNN <--> DeePMD-kit <--> Amber. Thus, you don't need to implement the sander interface directly, but just n...

You're absolutely right. I've reimplemented this correctly.

The new implementation follows the proper architecture:

  • MACE-OFF pretrained modelDeePMD-GNN MaceModel wrapperDeePMD-kitAMBER/sander

Changes in commit e996a86:

  1. Removed the incorrect direct sander interface (sander.py, test_sander.py, etc.)
  2. Modified mace_off.py to load MACE-OFF models into the existing MaceModel wrapper
  3. Added load_mace_off_model() - loads pretrained MACE-OFF and wraps in MaceModel
  4. Added convert_mace_off_to_deepmd() - creates frozen models for MD packages
  5. Updated docs to explain integration through DeePMD-kit's existing AMBER interface

Users can now:

from deepmd_gnn import load_mace_off_model, convert_mace_off_to_deepmd

# Load into MaceModel wrapper
model = load_mace_off_model("small")

# Or convert to frozen format for MD
convert_mace_off_to_deepmd("small", "frozen_model.pth")

The frozen model works with AMBER/sander through DeePMD-kit's existing interface, with QM/MM support via the DPRc mechanism.

Copilot AI and others added 3 commits February 13, 2026 22:49
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
…, fix formatting

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
…tion

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copilot AI changed the title Add MACE-OFF support for sander QM/MM simulations Load MACE-OFF pretrained models into DeePMD-GNN for MD simulations Feb 13, 2026
@njzjz
Copy link
Member

njzjz commented Feb 13, 2026

@copilot 1. Add a command line for the new feature.
2. Add unit tests.
3. Ensure the pre-commit can pass -- After installing uv, run uvx prek run -a

- Add command line interface with download-mace-off and convert-mace-off commands
- Add comprehensive unit tests for MACE-OFF functionality
- Configure ruff to allow print statements in appropriate files
- Add type annotations and fix all linting issues
- All pre-commit checks now pass

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot 1. Add a command line for the new feature.
2. Add unit tests.
3. Ensure the pre-commit can pass -- After installing uv, run uvx prek run -a

All three requirements have been implemented in commit 465c386:

  1. Command line interface added:

    • deepmd-gnn download-mace-off {small|medium|large} - Downloads MACE-OFF models
    • deepmd-gnn convert-mace-off {small|medium|large} -o output.pth - Converts to frozen DeePMD format
    • Entry point configured in pyproject.toml
  2. Unit tests added:

    • tests/test_mace_off.py with comprehensive test coverage
    • Tests for download functionality, model loading, validation, and conversion
    • Mock-based tests to avoid external dependencies
  3. Pre-commit checks passing:

    • All ruff checks pass (formatting, linting, type annotations)
    • Configured appropriate ignores for print statements in CLI/examples
    • Added type annotations for all functions
    • Fixed all code style issues

- Remove all @patch decorators and MagicMock usage
- Add real model download and loading tests marked with @pytest.mark.slow
- Test actual MACE-OFF model download, loading, and conversion
- Verify model structure and attributes with real models
- Keep simple unit test for invalid atomic numbers validation
- All linting checks pass

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
- Add logging module to mace_off.py and __main__.py
- Replace all print() calls with logger.info/warning/debug calls
- Fix blind exception catching: use specific (RuntimeError, torch.jit.Error) instead of Exception
- Remove T201 and BLE001 exceptions from pyproject.toml for these files
- Configure logging with INFO level and simple message format in CLI
- All linting checks now pass without exceptions

Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
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.

feat: Support MACE-OFF model in QM/MM simulations with sander

2 participants