Skip to content

feature/SOF 7901#318

Open
VsevolodX wants to merge 4 commits into
mainfrom
feature/SOF-7901
Open

feature/SOF 7901#318
VsevolodX wants to merge 4 commits into
mainfrom
feature/SOF-7901

Conversation

@VsevolodX
Copy link
Copy Markdown
Member

@VsevolodX VsevolodX commented May 18, 2026

  • chore: update README
  • update: move mace model getter
  • update: use mace mp switch

Summary by CodeRabbit

  • New Features
    • MACE model selection is now configurable via a dedicated parameter, replacing hardcoded model paths
    • Added support for running structure relaxation in Pyodide (browser-based) environments
    • Dispersion effects can now be enabled during structure relaxation calculations
    • New configuration options for floating-point precision and compute device selection

Review Change Stack

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@VsevolodX has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 37 minutes and 34 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d91bad05-d392-4268-bff3-2cb59dd34c62

📥 Commits

Reviewing files that changed from the base of the PR and between 51b2038 and a3ba0dc.

📒 Files selected for processing (2)
  • .pre-commit-config.yaml
  • other/experiments/jupyterlite/relax_structure_with_mace.ipynb
📝 Walkthrough

Walkthrough

A new Pyodide-compatible MACE model loader utility is introduced, and the relaxation notebook is refactored to use parametrized model selection via MACE_MODEL instead of hardcoded paths. The relaxation logic conditionally applies Pyodide-specific model loading and enables dispersion calculations.

Changes

MACE Pyodide Integration

Layer / File(s) Summary
Pyodide MACE model loading utility
src/py/mat3ra/notebooks_utils/pyodide/packages/mace.py
New module defines MODEL_PATHS_MAP mapping size names to fixed /drive/packages/models/ paths, and get_mace_model_pyodide() validates the model name and constructs a MACECalculator with configurable dispersion, dtype, and device parameters.
Notebook parameter setup and package initialization
other/experiments/jupyterlite/relax_structure_with_mace.ipynb
Parameter cell replaces local MODEL_PATHS_MAP with MACE_MODEL, FOLDER, INTERFACE_NAME, and RELAXATION_PARAMETERS definitions. Package setup cell applies Pyodide torch/MACE patches via apply_all_patches().
Relaxation workflow with Pyodide MACE support
other/experiments/jupyterlite/relax_structure_with_mace.ipynb
Relaxation cell switches from hardcoded MACECalculator with MODEL_PATHS_MAP["large"] to conditional Pyodide support: uses get_mace_model_pyodide under Pyodide or mace_mp otherwise, both with model=MACE_MODEL, dispersion=True, default_dtype="float32", and device="cpu".
Notebook execution outputs and metadata updates
other/experiments/jupyterlite/relax_structure_with_mace.ipynb
Material loading, visualization, interlayer distance, and energy decomposition cells now record execution metadata, captured stdout/stderr, and rendered visualization widget outputs from running the notebook.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Exabyte-io/api-examples#289: Both PRs wire up Pyodide/JupyterLite MACE relaxation by using a MODEL_PATHS_MAP-style model-path selection to construct MACECalculator/mace_mp (main PR via the new get_mace_model_pyodide helper in pyodide/packages/mace.py, retrieved PR via notebook-local Pyodide model loading and relaxation setup).

Suggested reviewers

  • timurbazhirov

Poem

🐰 A MACE so fine, now Pyodide-bound,
Models selected from paths underground,
Dispersion enabled, the atoms relax,
Parameters parametrized, no hardcoded tracks—
The notebook notebooks, the util helps best! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'feature/SOF 7901' is a branch name reference that does not describe the actual changes made in the pull request. Replace the title with a descriptive summary of the main change, such as 'Refactor MACE model initialization for Pyodide support' or 'Add MACE model helper function and update notebook to use mace_mp parameter'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/SOF-7901

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/py/mat3ra/notebooks_utils/pyodide/packages/mace.py`:
- Around line 10-14: The function get_mace_model_pyodide currently defines its
first parameter as model_name which mismatches callers expecting model and will
raise a TypeError; rename the parameter model_name to model (and update any
internal references like MODEL_PATHS_MAP lookup and the variable used to build
model_path) so the signature is def get_mace_model_pyodide(model: str,
dispersion=False, default_dtype="float32", device="cpu") and it still returns
MACECalculator(model_path=model_path, ...); ensure any local variable names and
docstring/comments reflect the new parameter name.
🪄 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: ecdfea09-ffe8-4c9d-a7ef-09307f6cffe6

📥 Commits

Reviewing files that changed from the base of the PR and between f828635 and 51b2038.

📒 Files selected for processing (2)
  • other/experiments/jupyterlite/relax_structure_with_mace.ipynb
  • src/py/mat3ra/notebooks_utils/pyodide/packages/mace.py

Comment on lines +10 to +14
def get_mace_model_pyodide(model_name: str, dispersion=False, default_dtype="float32", device="cpu"):
if model_name not in MODEL_PATHS_MAP:
raise ValueError(f"Invalid model name: {model_name}. Valid options are: {list(MODEL_PATHS_MAP.keys())}")
model_path = MODEL_PATHS_MAP[model_name]
return MACECalculator(model_path=model_path, dispersion=dispersion, default_dtype=default_dtype, device=device)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Parameter name mismatch will cause runtime failure in Pyodide.

The notebook (line 239) calls this function via mace_mp(model=MACE_MODEL, ...) after conditionally assigning get_mace_model_pyodide to mace_mp. Since this function's first parameter is model_name instead of model, the call will raise TypeError: get_mace_model_pyodide() got an unexpected keyword argument 'model'.

Rename model_name to model to match the mace_mp API signature.

🐛 Proposed fix
-def get_mace_model_pyodide(model_name: str, dispersion=False, default_dtype="float32", device="cpu"):
-    if model_name not in MODEL_PATHS_MAP:
-        raise ValueError(f"Invalid model name: {model_name}. Valid options are: {list(MODEL_PATHS_MAP.keys())}")
-    model_path = MODEL_PATHS_MAP[model_name]
+def get_mace_model_pyodide(model: str, dispersion=False, default_dtype="float32", device="cpu"):
+    if model not in MODEL_PATHS_MAP:
+        raise ValueError(f"Invalid model name: {model}. Valid options are: {list(MODEL_PATHS_MAP.keys())}")
+    model_path = MODEL_PATHS_MAP[model]
     return MACECalculator(model_path=model_path, dispersion=dispersion, default_dtype=default_dtype, device=device)
🤖 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 `@src/py/mat3ra/notebooks_utils/pyodide/packages/mace.py` around lines 10 - 14,
The function get_mace_model_pyodide currently defines its first parameter as
model_name which mismatches callers expecting model and will raise a TypeError;
rename the parameter model_name to model (and update any internal references
like MODEL_PATHS_MAP lookup and the variable used to build model_path) so the
signature is def get_mace_model_pyodide(model: str, dispersion=False,
default_dtype="float32", device="cpu") and it still returns
MACECalculator(model_path=model_path, ...); ensure any local variable names and
docstring/comments reflect the new parameter name.

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