ACEsuit / mace

MACE - Fast and accurate machine learning interatomic potentials with higher order equivariant message passing.
Other
502 stars 190 forks source link

Error for hidden irreps with l=4 #58

Closed pfebrer closed 1 year ago

pfebrer commented 1 year ago

I'm trying to run a variant of the mace model with hidden irreps of order l=4 (20x0e + 20x1o + 20x2e + 20x3o + 20x4e) and I get an error on the symmetric contraction:

    prod = EquivariantProductBasisBlock(
  File "~/mace/modules/blocks.py", line 114, in __init__
    self.symmetric_contractions = SymmetricContraction(
  File "~/mace/modules/symmetric_contraction.py", line 71, in __init__
    self.contractions[str(irrep_out)] = Contraction(
  File "~/mace/modules/symmetric_contraction.py", line 107, in __init__
    U_matrix = U_matrix_real(
  File "~/mace/tools/cg.py", line 132, in U_matrix_real
    out += [last_ir, stack]
UnboundLocalError: local variable 'last_ir' referenced before assignment

Should I be able to run the model with l=4 hidden irreps?

Thanks!

ilyes319 commented 1 year ago

Hey,

Did you make sure to change also --max_ell=4 in the input file. If you do not, no l=4 spherical harmonics will be injected thus the bug.

Best,

Ilyes

pfebrer commented 1 year ago

Thanks! If I increase max_ell to 4, then I get an error from e3nn:

Traceback (most recent call last):
  File "~/myenv/lib/python3.10/site-packages/e3nn/o3/_wigner.py", line 129, in wigner_3j
    out = flat_src[_W3j_indices[(l3, l2, l1)]].reshape(2 * l3 + 1, 2 * l2 + 1, 2 * l1 + 1).transpose(0, 2).mul((-1) ** (l1 + l2 + l3)).clone()
KeyError: (4, 8, 12)

During handling of the above exception, another exception occurred:
    prod = EquivariantProductBasisBlock(
  File "~/mace/modules/blocks.py", line 114, in __init__
    self.symmetric_contractions = SymmetricContraction(
  File "~/mace/modules/symmetric_contraction.py", line 71, in __init__
    self.contractions[str(irrep_out)] = Contraction(
  File "~/mace/modules/symmetric_contraction.py", line 107, in __init__
    U_matrix = U_matrix_real(
  File "~/mace/tools/cg.py", line 116, in U_matrix_real
    wigners = _wigner_nj(irrepss, normalization, filter_ir_mid, dtype)
  File "~/mace/tools/cg.py", line 55, in _wigner_nj
    C = o3.wigner_3j(ir_out.l, ir_left.l, ir.l, dtype=dtype)
  File "~/myenv/lib/python3.10/site-packages/e3nn/o3/_wigner.py", line 135, in wigner_3j
    raise NotImplementedError(f'Wigner 3j symbols maximum l implemented is {max(_W3j_indices.keys())[0]}, send us an email to ask for more')
NotImplementedError: Wigner 3j symbols maximum l implemented is 11, send us an email to ask for more
ilyes319 commented 1 year ago

Mmm yes, this should reported on e3nn repo. Usually you never need to go to that high order, it saturates at 3. Could you open an issue there and link it here?

pfebrer commented 1 year ago

Ok, thanks! I would like to open an issue there, the problem is that I don't understand exactly what is going on in the _wigner_nj function, so I don't know how to explain it :sweat_smile: E.g. I don't know what order of the Wigner 3j symbols do I need.

pfebrer commented 1 year ago

Forget what I said, in their latest version (e3nn==0.5.0) they already removed this restriction, and the mace model works with hidden irreps l=4 and max_ell=4 :ok_hand:

pfebrer commented 1 year ago

Thank you very much for the quick replies! :)