haliax 1.4.dev330__tar.gz → 1.4.dev332__tar.gz
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.
- {haliax-1.4.dev330 → haliax-1.4.dev332}/PKG-INFO +3 -3
- {haliax-1.4.dev330 → haliax-1.4.dev332}/README.md +2 -2
- {haliax-1.4.dev330 → haliax-1.4.dev332}/mkdocs.yml +1 -0
- haliax-1.4.dev332/src/haliax/__about__.py +1 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/__init__.py +2 -2
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/jax_utils.py +27 -19
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/__init__.py +1 -4
- haliax-1.4.dev332/src/haliax/nn/scan.py +684 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/random.py +0 -1
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_scan.py +56 -3
- haliax-1.4.dev330/src/haliax/__about__.py +0 -1
- haliax-1.4.dev330/src/haliax/nn/scan.py +0 -425
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.coveragerc +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.flake8 +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.github/workflows/publish_dev.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.github/workflows/run_pre_commit.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.github/workflows/run_quick_levanter_tests.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.github/workflows/run_tests.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.gitignore +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.pre-commit-config.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/.readthedocs.yaml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/CONTRIBUTING.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/LICENSE +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/api.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/broadcasting.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/cheatsheet.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/css/material.css +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/css/mkdocstrings.css +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/faq.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/data_parallel_mesh.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/data_parallel_mesh_replicated.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_1d.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_1d_zero.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d_batch_partitioned.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d_data_replicated.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d_data_replicated_mlp_partitioned.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d_intermediate_fully_partitioned.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/figures/device_mesh_2d_zero.png +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/fp8.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/hof.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/index.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/indexing.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/matmul.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/nn.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/partitioning.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/rearrange.ipynb +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/rearrange.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/requirements.txt +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/state-dict.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/docs/tutorial.md +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/pyproject.toml +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/__init__.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/compile_utils.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/dot.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/einsum.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/fp8.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/parsing.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/rearrange.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/state_dict.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/_src/util.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/axis.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/core.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/debug.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/hof.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/activations.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/attention.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/conv.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/dropout.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/embedding.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/linear.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/loss.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/mlp.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/normalization.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/nn/pool.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/ops.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/partitioning.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/quantization.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/specialized_fns.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/state_dict.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/tree_util.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/types.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/util.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/src/haliax/wrap.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/core_test.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_attention.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_axis.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_conv.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_debug.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_dot.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_einsum.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_fp8.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_hof.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_int8.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_nn.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_ops.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_parsing.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_partitioning.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_pool.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_random.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_rearrange.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_specialized_fns.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_state_dict.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_tree_util.py +0 -0
- {haliax-1.4.dev330 → haliax-1.4.dev332}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: haliax
|
|
3
|
-
Version: 1.4.
|
|
3
|
+
Version: 1.4.dev332
|
|
4
4
|
Summary: Named Tensors for Legible Deep Learning in JAX
|
|
5
5
|
Project-URL: Homepage, https://github.com/stanford-crfm/haliax
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/stanford-crfm/haliax/issues/
|
|
@@ -61,8 +61,8 @@ Despite the focus on legibility, Haliax
|
|
|
61
61
|
is also **fast**, typically about as fast as "pure" JAX code.
|
|
62
62
|
Haliax is also built to be **scalable**: it
|
|
63
63
|
can support [Fully-Sharded Data Parallelism (FSDP)](https://engineering.fb.com/2021/07/15/open-source/fsdp/) and Tensor Parallelism with [just a few lines of code](https://colab.research.google.com/drive/1QX4yH3zRFF3Xiibf1aahETcSQ5nbcUMz). Haliax powers [Levanter](https://github.com/stanford-crfm/levanter),
|
|
64
|
-
our companion library for training large language models and other foundation models, with scale proven up to
|
|
65
|
-
and up to
|
|
64
|
+
our companion library for training large language models and other foundation models, with scale proven up to 70B parameters
|
|
65
|
+
and up to TPU v4-2048.
|
|
66
66
|
|
|
67
67
|
## Example: Attention
|
|
68
68
|
|
|
@@ -25,8 +25,8 @@ Despite the focus on legibility, Haliax
|
|
|
25
25
|
is also **fast**, typically about as fast as "pure" JAX code.
|
|
26
26
|
Haliax is also built to be **scalable**: it
|
|
27
27
|
can support [Fully-Sharded Data Parallelism (FSDP)](https://engineering.fb.com/2021/07/15/open-source/fsdp/) and Tensor Parallelism with [just a few lines of code](https://colab.research.google.com/drive/1QX4yH3zRFF3Xiibf1aahETcSQ5nbcUMz). Haliax powers [Levanter](https://github.com/stanford-crfm/levanter),
|
|
28
|
-
our companion library for training large language models and other foundation models, with scale proven up to
|
|
29
|
-
and up to
|
|
28
|
+
our companion library for training large language models and other foundation models, with scale proven up to 70B parameters
|
|
29
|
+
and up to TPU v4-2048.
|
|
30
30
|
|
|
31
31
|
## Example: Attention
|
|
32
32
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.4.dev332"
|
|
@@ -61,7 +61,7 @@ from .core import (
|
|
|
61
61
|
updated_slice,
|
|
62
62
|
)
|
|
63
63
|
from .hof import fold, map, scan, vmap
|
|
64
|
-
from .jax_utils import
|
|
64
|
+
from .jax_utils import tree_checkpoint_name
|
|
65
65
|
from .ops import clip, isclose, pad_left, trace, tril, triu, where
|
|
66
66
|
from .partitioning import auto_sharded, axis_mapping, fsdp, named_jit, shard, shard_with_axis_mapping
|
|
67
67
|
from .specialized_fns import top_k
|
|
@@ -887,7 +887,6 @@ def true_divide(x1: NamedOrNumeric, x2: NamedOrNumeric, /) -> NamedOrNumeric:
|
|
|
887
887
|
# deprecated name
|
|
888
888
|
concat_axis_specs = concat_axes
|
|
889
889
|
|
|
890
|
-
|
|
891
890
|
__all__ = [
|
|
892
891
|
"debug",
|
|
893
892
|
"random",
|
|
@@ -1071,4 +1070,5 @@ __all__ = [
|
|
|
1071
1070
|
"ravel",
|
|
1072
1071
|
"flatten",
|
|
1073
1072
|
"is_named_array",
|
|
1073
|
+
"tree_checkpoint_name",
|
|
1074
1074
|
]
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import functools as ft
|
|
2
2
|
import typing
|
|
3
|
+
import warnings
|
|
3
4
|
from typing import Any, Callable, Optional, Sequence, Union
|
|
4
5
|
|
|
5
6
|
import equinox as eqx
|
|
@@ -8,8 +9,8 @@ import numpy as np
|
|
|
8
9
|
from jax import Array
|
|
9
10
|
from jax import numpy as jnp
|
|
10
11
|
from jax import random as jrandom
|
|
11
|
-
from jax.
|
|
12
|
-
from jax.
|
|
12
|
+
from jax.ad_checkpoint import checkpoint_name
|
|
13
|
+
from jax.typing import DTypeLike
|
|
13
14
|
from jaxtyping import PRNGKeyArray
|
|
14
15
|
|
|
15
16
|
import haliax
|
|
@@ -27,6 +28,7 @@ except ImportError:
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
F = typing.TypeVar("F", bound=Callable[..., Any])
|
|
31
|
+
T = typing.TypeVar("T")
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
class Static(eqx.Module):
|
|
@@ -70,23 +72,9 @@ def filter_eval_shape(*args, **kwargs):
|
|
|
70
72
|
def filter_checkpoint(fun: Callable, *, prevent_cse: bool = True, policy: Optional[Callable[..., bool]] = None):
|
|
71
73
|
"""As `jax.checkpoint`, but allows any Python object as inputs and outputs"""
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
def _fn(_static, _dynamic):
|
|
75
|
-
_args, _kwargs = eqx.combine(_static, _dynamic)
|
|
76
|
-
_out = fun(*_args, **_kwargs)
|
|
77
|
-
_dynamic_out, _static_out = eqx.partition(_out, is_jax_array_like)
|
|
78
|
-
return _dynamic_out, Static(_static_out)
|
|
75
|
+
warnings.warn("filter_checkpoint is deprecated, use eqx.filter_checkpoint instead", DeprecationWarning)
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@ft.wraps(fun)
|
|
83
|
-
def wrapper(*args, **kwargs):
|
|
84
|
-
dynamic, static = eqx.partition((args, kwargs), is_jax_array_like)
|
|
85
|
-
dynamic_out, static_out = checkpointed_fun(static, dynamic)
|
|
86
|
-
|
|
87
|
-
return eqx.combine(dynamic_out, static_out.value)
|
|
88
|
-
|
|
89
|
-
return wrapper
|
|
77
|
+
return eqx.filter_checkpoint(fun, prevent_cse=prevent_cse, policy=policy)
|
|
90
78
|
|
|
91
79
|
|
|
92
80
|
def is_jax_array_like(x):
|
|
@@ -202,7 +190,7 @@ def _jittable_dg_einsum(
|
|
|
202
190
|
contract_path = opt_einsum.contract_path
|
|
203
191
|
else:
|
|
204
192
|
ty = next(iter(non_constant_dim_types))
|
|
205
|
-
contract_path =
|
|
193
|
+
contract_path = jax_einsum._poly_einsum_handlers.get(ty, jax_einsum._default_poly_einsum_handler)
|
|
206
194
|
# using einsum_call=True here is an internal api for opt_einsum... sorry
|
|
207
195
|
operands, contractions = contract_path(*operands, einsum_call=True, use_blas=True, optimize=optimize)
|
|
208
196
|
|
|
@@ -212,3 +200,23 @@ def _jittable_dg_einsum(
|
|
|
212
200
|
if spec is not None:
|
|
213
201
|
einsum = jax.named_call(einsum, name=spec)
|
|
214
202
|
return einsum(operands, contractions, precision, preferred_element_type, _dot_general) # type: ignore[operator]
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def tree_checkpoint_name(x: T, name: str) -> T:
|
|
206
|
+
"""
|
|
207
|
+
Checkpoint a tree of arrays with a given name. This is useful for gradient checkpointing.
|
|
208
|
+
This is equivalent to calling [jax.ad_checkpoint.checkpoint_name][]
|
|
209
|
+
except that it works for any PyTree, not just arrays.
|
|
210
|
+
|
|
211
|
+
See Also:
|
|
212
|
+
* [jax.ad_checkpoint.checkpoint_name][]
|
|
213
|
+
* [haliax.nn.StackedCheckpointPolicy][]
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
def _checkpoint_leaf(x):
|
|
217
|
+
if is_jax_array_like(x):
|
|
218
|
+
return checkpoint_name(x, name)
|
|
219
|
+
else:
|
|
220
|
+
return x
|
|
221
|
+
|
|
222
|
+
return jax.tree.map(_checkpoint_leaf, x)
|
|
@@ -38,10 +38,7 @@ from .loss import binary_cross_entropy_loss, cross_entropy_loss, cross_entropy_l
|
|
|
38
38
|
from .mlp import MLP
|
|
39
39
|
from .normalization import LayerNorm, log_softmax, logsumexp, softmax, standardize
|
|
40
40
|
from .pool import max_pool, mean_pool, min_pool
|
|
41
|
-
from .scan import BlockSeq, Stacked
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# TODO: support where in softmax, etc
|
|
41
|
+
from .scan import BlockSeq, Stacked, StackedCheckpointPolicy
|
|
45
42
|
|
|
46
43
|
|
|
47
44
|
def one_hot(x: NamedArray | int, class_axis: Axis, *, dtype=None) -> NamedArray:
|