Skip to content

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

@bppece

Description

@bppece

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions