highpairformer 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- highpairformer/__init__.py +76 -0
- highpairformer/_precision.py +27 -0
- highpairformer/benchmark.py +1050 -0
- highpairformer/jax/__init__.py +62 -0
- highpairformer/jax/_ops.py +375 -0
- highpairformer/jax/_runtime.py +2223 -0
- highpairformer/kernels/__init__.py +1 -0
- highpairformer/kernels/metal/__init__.py +27 -0
- highpairformer/kernels/metal/_shaders.py +991 -0
- highpairformer/mlx/__init__.py +41 -0
- highpairformer/mlx/_metal.py +62 -0
- highpairformer/mlx/_normalize.py +84 -0
- highpairformer/mlx/_tensorops.py +263 -0
- highpairformer/mlx/attention.py +78 -0
- highpairformer/mlx/swiglu.py +254 -0
- highpairformer/mlx/triattn.py +236 -0
- highpairformer/mlx/trimul.py +568 -0
- highpairformer/py.typed +0 -0
- highpairformer/torch/__init__.py +19 -0
- highpairformer/torch/_mps.py +479 -0
- highpairformer/torch/_ops.py +662 -0
- highpairformer-0.1.0.dist-info/METADATA +175 -0
- highpairformer-0.1.0.dist-info/RECORD +26 -0
- highpairformer-0.1.0.dist-info/WHEEL +4 -0
- highpairformer-0.1.0.dist-info/entry_points.txt +2 -0
- highpairformer-0.1.0.dist-info/licenses/LICENSE +161 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""highpairformer: Apple Silicon Metal/MLX drop-in for cuEquivariance across JAX, PyTorch, and MLX.
|
|
2
|
+
|
|
3
|
+
- ``import highpairformer as cueq`` or ``import highpairformer.jax as cueq``:
|
|
4
|
+
drop-in for ``cuequivariance_jax`` plus a zero-patch Jaxpr-to-MLX GPU runtime
|
|
5
|
+
(``jit``, ``filter_jit``, ``grad``, ``value_and_grad``, ``compile_stage``).
|
|
6
|
+
- ``import highpairformer.torch as cueq``:
|
|
7
|
+
drop-in for ``cuequivariance_torch`` with ``torch.mps.compile_shader`` Metal kernels.
|
|
8
|
+
- ``import highpairformer.mlx as hpf``:
|
|
9
|
+
native MLX array ops with zero JAX or PyTorch dependency.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
from importlib import import_module
|
|
13
|
+
from typing import TYPE_CHECKING, Any
|
|
14
|
+
|
|
15
|
+
from highpairformer._precision import Precision
|
|
16
|
+
|
|
17
|
+
if TYPE_CHECKING:
|
|
18
|
+
from highpairformer import jax, mlx, torch
|
|
19
|
+
from highpairformer.jax import (
|
|
20
|
+
available,
|
|
21
|
+
biased_attention,
|
|
22
|
+
compile_stage,
|
|
23
|
+
filter_jit,
|
|
24
|
+
grad,
|
|
25
|
+
jit,
|
|
26
|
+
swiglu_transition,
|
|
27
|
+
triangle_attention,
|
|
28
|
+
triangle_multiplicative_update,
|
|
29
|
+
value_and_grad,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
__all__ = [
|
|
33
|
+
"Precision",
|
|
34
|
+
"available",
|
|
35
|
+
"biased_attention",
|
|
36
|
+
"compile_stage",
|
|
37
|
+
"filter_jit",
|
|
38
|
+
"grad",
|
|
39
|
+
"jax",
|
|
40
|
+
"jit",
|
|
41
|
+
"mlx",
|
|
42
|
+
"swiglu_transition",
|
|
43
|
+
"torch",
|
|
44
|
+
"triangle_attention",
|
|
45
|
+
"triangle_multiplicative_update",
|
|
46
|
+
"value_and_grad",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
_SUBMODULES = frozenset({"jax", "mlx", "torch"})
|
|
50
|
+
_JAX_EXPORTS = frozenset(
|
|
51
|
+
{
|
|
52
|
+
"available",
|
|
53
|
+
"biased_attention",
|
|
54
|
+
"compile_stage",
|
|
55
|
+
"filter_jit",
|
|
56
|
+
"grad",
|
|
57
|
+
"jit",
|
|
58
|
+
"swiglu_transition",
|
|
59
|
+
"triangle_attention",
|
|
60
|
+
"triangle_multiplicative_update",
|
|
61
|
+
"value_and_grad",
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def __getattr__(name: str) -> Any:
|
|
67
|
+
if name in _SUBMODULES:
|
|
68
|
+
mod = import_module(f".{name}", __name__)
|
|
69
|
+
globals()[name] = mod
|
|
70
|
+
return mod
|
|
71
|
+
if name in _JAX_EXPORTS:
|
|
72
|
+
jax_mod = import_module(".jax", __name__)
|
|
73
|
+
value = getattr(jax_mod, name)
|
|
74
|
+
globals()[name] = value
|
|
75
|
+
return value
|
|
76
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""Framework-independent precision enum mirroring ``cuequivariance_jax.Precision``."""
|
|
2
|
+
|
|
3
|
+
import enum
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
__all__ = ["Precision"]
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Precision(enum.IntEnum):
|
|
10
|
+
"""Precision modes for matrix multiplication operations."""
|
|
11
|
+
|
|
12
|
+
DEFAULT = 0
|
|
13
|
+
TF32 = 1
|
|
14
|
+
TF32x3 = 2
|
|
15
|
+
IEEE = 3
|
|
16
|
+
|
|
17
|
+
def to_jax(self) -> Any:
|
|
18
|
+
"""Convert to a JAX ``PrecisionLike`` value."""
|
|
19
|
+
import jax
|
|
20
|
+
|
|
21
|
+
if self == Precision.DEFAULT:
|
|
22
|
+
return jax.lax.Precision.DEFAULT
|
|
23
|
+
if self == Precision.TF32:
|
|
24
|
+
return jax.lax.DotAlgorithmPreset.TF32_TF32_F32
|
|
25
|
+
if self == Precision.TF32x3:
|
|
26
|
+
return jax.lax.DotAlgorithmPreset.TF32_TF32_F32_X3
|
|
27
|
+
return jax.lax.DotAlgorithmPreset.F32_F32_F32
|