Skip to content

[DOC] Python 3.14 issues #1024

@HaoZeke

Description

@HaoZeke

Location of the issue

N/A.

Description of the issue

gh repo clone metatensor/metatrain
cd metatrain
uv venv -p 3.14
. .venv/bin/activate
uv pip install -e .
mtt export https://huggingface.co/lab-cosmo/upet/resolve/main/models/pet-mad-s-v1.0.2.ckpt

Which generates an error log.

`error.log`
❯ cat error.log
Traceback (most recent call last):
  File "/home/rgoswami/Git/Github/epfl/pixi_envs/orgs/metatensor/metatrain/metatrain/src/metatrain/__main__.py", line 95, in main
    export_model(**args.__dict__)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/rgoswami/Git/Github/epfl/pixi_envs/orgs/metatensor/metatrain/metatrain/src/metatrain/cli/export.py", line 221, in export_model
    model.save(path, collect_extensions=extensions_path)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/metatomic/torch/model.py", line 539, in save
    module = torch.jit.script(module)
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/torch/jit/_script.py", line 1437, in script
    ret = _script_impl(
        obj=obj,
    ...<3 lines>...
        example_inputs=example_inputs,
    )
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/torch/jit/_script.py", line 1146, in _script_impl
    return torch.jit._recursive.create_script_module(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        obj, torch.jit._recursive.infer_methods_to_compile
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/torch/jit/_recursive.py", line 556, in create_script_module
    AttributeTypeIsSupportedChecker().check(nn_module)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/torch/jit/_check.py", line 77, in check
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rgoswami/Git/Github/epfl/tmp/.venv/lib/python3.14/site-packages/torch/nn/modules/module.py", line 1964, in __getattr__
    raise AttributeError(
        f"'{type(self).__name__}' object has no attribute '{name}'"
    )
AttributeError: 'AtomisticModel' object has no attribute '__annotations__'. Did you mean: '__annotate_func__'?

Suggested fix or improvement (optional)

This actually is a version error, for example, downgrading to Python 3.12 works.

Additional context

I don't think it's much of a bug, but we might want to have better logging / documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions