microsoft / microsoft/mattergen

TypeError: Optimizer.converged() missing 1 required positional argument: 'gradient'

Open
#223 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
351
Avg merge
1h 3m
Merged PRs (30d)
4

Description

Hi,
i would like to evaluate the model as after generation of the structure:
mattergen-evaluate --structures_path=$RESULTS_PATH --relax=True --structure_matcher='disordered' --save_as="$RESULTS_PATH/metrics.json"

but got the following error:

(.venv) bpp@bpp:/mattergen-1.0.3/checkpoints/mattergen_base$ mattergen-evaluate --structures_path=$RESULTS_PATH --relax=True --structure_matcher='disordered' --save_as="$RESULTS_PATH/metrics.json"
MODELS_PROJECT_ROOT: /home/bpp/mattergen-1.0.3/mattergen
/home/bpp/.venv/lib/python3.10/site-packages/lightning_fabric/init.py:36: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import("pkg_resources").declare_namespace(name)
2025-10-31 15:33:47.816 | INFO | mattersim.forcefield.potential:from_checkpoint:877 - Loading the pre-trained mattersim-v1.0.0-1M.pth model
0%| | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
File "/home/bpp/.venv/bin/mattergen-evaluate", line 10, in
sys.exit(_main())
File "/home/bpp/mattergen-1.0.3/mattergen/scripts/evaluate.py", line 60, in _main
fire.Fire(main)
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/bpp/mattergen-1.0.3/mattergen/scripts/evaluate.py", line 45, in main
metrics = evaluate(
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/evaluate.py", line 49, in evaluate
relaxed_structures, energies = relax_structures(
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/utils/relaxation.py", line 45, in relax_structures
relaxed_atoms, total_energies = relax_atoms(atoms, device=device, potential_load_path=potential_load_path, output_path=output_path, **kwargs)
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/utils/relaxation.py", line 26, in relax_atoms
relaxation_trajectories = batch_relaxer.relax(atoms)
File "/home/bpp/.venv/lib/python3.10/site-packages/mattersim/applications/batch_relax.py", line 162, in relax
self.insert(
File "/home/bpp/.venv/lib/python3.10/site-packages/mattersim/applications/batch_relax.py", line 80, in insert
atoms.calc = calc
NameError: name 'calc' is not defined
0%| | 0/1 [00:00<?, ?it/s]
(.venv) bpp@bpp:
/mattergen-1.0.3/checkpoints/mattergen_base$ mattergen-evaluate --structures_path=$RESULTS_PATH --relax=True --structure_matcher='disordered' --save_as="$RESULTS_PATH/metrics.json"
MODELS_PROJECT_ROOT: /home/bpp/mattergen-1.0.3/mattergen
/home/bpp/.venv/lib/python3.10/site-packages/lightning_fabric/init.py:36: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
import("pkg_resources").declare_namespace(name)
2025-10-31 15:35:19.286 | INFO | mattersim.forcefield.potential:from_checkpoint:877 - Loading the pre-trained mattersim-v1.0.0-1M.pth model
0%| | 0/1 [00:00<?, ?it/s]/home/bpp/.venv/lib/python3.10/site-packages/mattersim/applications/batch_relax.py:80: FutureWarning: Please use atoms.calc = calc
atoms.set_calculator(DummyBatchCalculator())

Traceback (most recent call last):
File "/home/bpp/.venv/bin/mattergen-evaluate", line 10, in
sys.exit(_main())
File "/home/bpp/mattergen-1.0.3/mattergen/scripts/evaluate.py", line 60, in _main
fire.Fire(main)
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 135, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 468, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/bpp/.venv/lib/python3.10/site-packages/fire/core.py", line 684, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/bpp/mattergen-1.0.3/mattergen/scripts/evaluate.py", line 45, in main
metrics = evaluate(
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/evaluate.py", line 49, in evaluate
relaxed_structures, energies = relax_structures(
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/utils/relaxation.py", line 45, in relax_structures
relaxed_atoms, total_energies = relax_atoms(atoms, device=device, potential_load_path=potential_load_path, output_path=output_path, **kwargs)
File "/home/bpp/mattergen-1.0.3/mattergen/evaluation/utils/relaxation.py", line 26, in relax_atoms
relaxation_trajectories = batch_relaxer.relax(atoms)
File "/home/bpp/.venv/lib/python3.10/site-packages/mattersim/applications/batch_relax.py", line 166, in relax
self.step_batch()
File "/home/bpp/.venv/lib/python3.10/site-packages/mattersim/applications/batch_relax.py", line 122, in step_batch
if opt.converged():
TypeError: Optimizer.converged() missing 1 required positional argument: 'gradient'
100%|█████████████████████████████████████████████| 1/1 [00:00<00:00, 1.63it/s]
(.venv) bpp@bpp:~/mattergen-1.0.3/checkpoints/mattergen_base$

Sorry for long posting outputfile. I could not able to find the source of error except one thing it is printed Atoms.calc = calc required as highlighted in bold.
Kindly help me in this regards.
Thanks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with mattergen/scripts/evaluate.py, mattergen/evaluation/evaluate.py, and mattergen/evaluation/utils/relaxation.py, then inspect the installed mattersim/applications/batch_relax.py referenced by the trace. Compare the MatterGen relaxation calls with the installed MatterSim optimizer API and reproduce the command. Done means mattergen-evaluate completes with --relax=True and writes the requested metrics file without the calculator or converged errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.