Skip to content

Unconstrained e3nn dependency allows a broken install (import fails under e3nn 0.4.4 + torch >= 2.6) #109

Closed

Description

@xieziren

Summary

skala declares e3nn with no version bound, so a resolver is free to install e3nn < 0.5. Under torch >= 2.6 that combination makes skala unimportable. Nothing warns at install time — pip/uv report success, and the failure only surfaces at import skala.pyscf.

Reproduction

uv venv .venv --python 3.11
uv pip install --python .venv/bin/python "skala==2026.8" "e3nn==0.4.4"
.venv/bin/python -c "from skala.pyscf import SkalaKS"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File ".../site-packages/skala/pyscf/__init__.py", line 17, in <module>
    from skala.functional import ExcFunctionalBase, load_functional
  File ".../site-packages/skala/functional/__init__.py", line 20, in <module>
    from skala.functional.model import SkalaFunctional
  File ".../site-packages/skala/functional/model.py", line 15, in <module>
    from e3nn import o3
  File ".../site-packages/e3nn/o3/__init__.py", line 31, in <module>
    from ._wigner import wigner_D, wigner_3j
  File ".../site-packages/e3nn/o3/_wigner.py", line 10, in <module>
    _Jd, _W3j_flat, _W3j_indices = torch.load(os.path.join(os.path.dirname(__file__), 'constants.pt'))
  File ".../site-packages/torch/serialization.py", line 1609, in load
    raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
_pickle.UnpicklingError: Weights only load failed. [...]
	WeightsUnpickler error: Unsupported global: GLOBAL slice was not an allowed global by default.
	Please use `torch.serialization.add_safe_globals([slice])` [...]

Root cause

  1. pyproject.toml lists "e3nn" with no specifier, so e3nn 0.4.4 satisfies the requirement.
  2. e3nn 0.4.4 loads its own Wigner constants at import time, in e3nn/o3/_wigner.py:10, via torch.load(...'constants.pt') without passing weights_only.
  3. PyTorch 2.6 flipped the default of weights_only from False to True. slice is not on the default allowlist, so the load raises UnpicklingError.
  4. e3nn >= 0.5 is unaffected — it dropped constants.pt and computes the Wigner matrices analytically, so there is no torch.load on the import path at all.

How you actually end up on e3nn 0.4.4

Not by choice. mace-torch (0.3.16, current release) hard-pins it:

Requires-Dist: e3nn==0.4.4

and that pin is load-bearing for MACE — its pretrained weights are serialized with the 0.4.4 codegen format and e3nn >= 0.5 cannot read them. So in any environment where skala and mace-torch are co-installed — a natural combination when benchmarking a learned functional against MLIPs — the resolver silently pulls e3nn down to 0.4.4 and skala stops importing.

The resulting failure is import-order dependent, which makes it look flaky. mace/__init__.py:5 sets os.environ["TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD"] = "1" as a global side effect, which reverts the torch.load default process-wide. Same venv, same packages, only statement order differs:

from skala.pyscf import SkalaKS   # UnpicklingError
import mace
import mace                       # sets TORCH_FORCE_NO_WEIGHTS_ONLY_LOAD=1
from skala.pyscf import SkalaKS   # imports fine

So whether skala works depends on whether something else happened to import mace first.

Suggested fix

-    "e3nn",
+    "e3nn>=0.5",

The goal isn't only to land on a working e3nn. With a lower bound present, the resolver reports the conflict against mace-torch loudly at install time, instead of producing an environment that installs cleanly and then fails at import — or worse, one that works or not depending on import order.

The bump appears numerically inert. Same molecule, same basis, same functional, only e3nn differs:

e3nn from skala.pyscf import SkalaKS H2O / def2-SVP / skala-1.1
0.4.4 UnpicklingError —
0.6.0 ok -76.32239149 Ha

-76.32239149 Ha is bit-identical to what I get on e3nn 0.4.4 with torch.serialization.add_safe_globals([slice]) applied before import, so the constraint change doesn't move any numbers.

If you would rather be conservative than open-ended, e3nn>=0.5,<0.7 would also work — I only tested 0.5.9 and 0.6.0.

Workaround for anyone who has to keep e3nn 0.4.4

For the mace-torch co-install case, allowlisting the one global that constants.pt needs is enough, and doesn't require MACE's process-wide env var:

import torch.serialization
torch.serialization.add_safe_globals([slice])   # before importing skala or e3nn
from skala.pyscf import SkalaKS

Environment

  • Python 3.11.15, macOS 26.6.1, arm64 (Apple silicon)
  • skala 2026.8, torch 2.13.0, pyscf 2.13.1, numpy 2.4.6, ase 3.29.0
  • mace-torch 0.3.16 for the co-install case

Happy to send a PR for the constraint if you agree with the bound.

Activity

  1. JensWehner commented on Aug 17, 2026

    @JensWehner
    Contributor

    thanks, that is a very nice description and we are happy with a PR on this. Thanks a lot!

  2. JensWehner commented on Oct 4, 2026

    @JensWehner
    Contributor

    fixed in #137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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