Version
0.1.0
On which installation method(s) does this occur?
Source
Describe the issue
The ConvergenceTreshold requires a threshold even if it's not needed used because we're using a custom operation.
Should we either make it optional if custom_op is set or pass it as an arg to the custom_op? I'd suggest the latter so users can tweak the tolerance of a convergence hook more easily.
Minimum reproducible example
import torch
from nvalchemi.dynamics import ConvergenceHook
def _custom_noop(x: torch.Tensor) -> torch.Tensor:
return torch.ones(1, dtype=torch.bool, device=x.device)
ConvergenceHook = ConvergenceHook(
criteria={"key": "custom_metric", "custom_op": _custom_noop},
)
Relevant log output
Traceback (most recent call last):
File "/mnt/c/Users/lward/Code/nv-open/nv-alchemi/nvalchemi-toolkit/scripts/thr-mre.py", line 8, in <module>
ConvergenceHook = ConvergenceHook(
criteria={"key": "custom_metric", "custom_op": _custom_noop},
)
File "/mnt/c/Users/lward/Code/nv-open/nv-alchemi/nvalchemi-toolkit/nvalchemi/dynamics/base.py", line 2288, in __init__
self.criteria = [_ConvergenceCriterion(**criteria)]
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "/mnt/c/Users/lward/Code/nv-open/nv-alchemi/nvalchemi-toolkit/.venv/lib/python3.13/site-packages/pydantic/main.py", line 250, in __init__
validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for _ConvergenceCriterion
threshold
Field required [type=missing, input_value={'key': 'custom_metric', ...noop at 0x7a7d06ee7100>}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
Environment details
Version
0.1.0
On which installation method(s) does this occur?
Source
Describe the issue
The ConvergenceTreshold requires a threshold even if it's not needed used because we're using a custom operation.
Should we either make it optional if
custom_opis set or pass it as an arg to thecustom_op? I'd suggest the latter so users can tweak the tolerance of a convergence hook more easily.Minimum reproducible example
Relevant log output
Environment details