Tags: microsoft/mattersim
Tags
fix: non-periodic systems in TorchSim graph construction (#161) * fix: normalize non-periodic systems in TorchSim graph construction The TorchSim code path (build_graph_from_simstate) was passing raw pbc=False and a zero cell for non-periodic molecules, while the ASE calculator path (_normalize_atoms) creates a large fake periodic cell and wraps positions into it. This caused the M3GNet model to receive different graph inputs for the same molecule, producing inconsistent energies and forces. Add _normalize_nonperiodic_systems() that replicates the same fake-cell normalization for the TorchSim path, ensuring both code paths feed identical inputs to the model. Fixes #160 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: add regression tests for non-periodic TorchSim normalization Add unit tests for _normalize_nonperiodic_systems() verifying: - Periodic systems pass through unchanged - Non-periodic molecules get a large fake periodic cell - Cell and positions match the ASE _normalize_atoms code path - Original SimState tensors are not mutated Add end-to-end test (test_wrapper_molecule_consistency) comparing TorchSimWrapper vs MatterSimCalculator on a water molecule. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: request full FC format for phono3py v4 compatibility Phono3py v4 defaults to compact force constants format, changing fc2 shape from (n_satom, n_satom, 3, 3) to (n_patom, n_satom, 3, 3). Explicitly pass is_compact_fc=False to produce_fc2() and produce_fc3() to maintain the full format expected by downstream code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
feat: add double precision (float64) inference support (#156) * feat: add double precision (float64) inference support Add dtype='float64' option to MatterSimCalculator for double-precision inference. This improves numerical stability for sensitive properties like thermal conductivity. Changes: - MatterSimCalculator: new dtype parameter ('float32' or 'float64'), converts model weights via model.double() and creates inputs in the matching dtype - m3gnet.py: replace .float() with .to(pos.dtype) for pbc_offsets so it respects the model's precision - calculate(): upcast legacy-path float tensors to match model dtype On equilibrium Si diamond, float64 reduces force noise from ~1e-6 to ~1e-15 eV/Å compared to float32. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: use float64 precision in BTE thermal conductivity tests Switch BTE tests to dtype='float64' for more stable force constants. Update reference kappa values to float64 means verified across 3 runs (rel_std < 0.03%). Tighten tolerance from 8% to 2%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: reject float64 on MPS devices and skip float64 BTE tests on MPS MPS does not support float64 tensors. This commit: - Validates dtype+device combo early in MatterSimCalculator.__init__, raising ValueError before loading the model - Falls back to float32 in the basic BTE test on MPS - Skips the strict BTE test on MPS (reference values require float64) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * test: allow strict BTE test to run on MPS with relaxed tolerances Use float32 with 10% kappa tolerance and 0.5% FC tolerance on MPS, while keeping float64 with tight tolerances (2% / 0.1%) on CUDA. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: alias torch._inductor.config import to avoid shadowing torch The local 'import torch._inductor.config' statement caused Python to treat 'torch' as a local variable in __init__, making earlier references to torch.float32/torch.float64 fail with UnboundLocalError. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: preserve float64 dtype after calculator pickle roundtrip Agent-Logs-Url: https://github.com/microsoft/mattersim/sessions/b2ac740c-f04e-4e6b-a5c0-b3389a4caaf3 Co-authored-by: yanghan234 <32856137+yanghan234@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
PreviousNext