haliax-1.4.dev452
1.4.dev452
1.4.dev450
1.4.dev447
1.4.dev446
1.4.dev445
1.4.dev444
1.4.dev443
1.4.dev441
1.4.dev439
1.4.dev438
1.4.dev420
1.4.dev419
1.4.dev413
1.4.dev412
1.4.dev411
1.4.dev410
1.4.dev409
1.4.dev408
1.4.dev407
1.4.dev406
1.4.dev405
1.4.dev404
1.4.dev403
1.4.dev402
1.4.dev400
1.4.dev399
1.4.dev398
1.4.dev397
1.4.dev396
1.4.dev395
1.4.dev394
1.4.dev393
1.4.dev392
1.4.dev391
1.4.dev390
1.4.dev389
1.4.dev388
1.4.dev386
1.4.dev382
1.4.dev381
1.4.dev380
1.4.dev379
1.4.dev378
1.4.dev375
1.4.dev374
1.4.dev373
1.4.dev372
1.4.dev371
1.4.dev369
1.4.dev368
1.4.dev367
1.4.dev366
1.4.dev365
1.4.dev364
1.4.dev363
1.4.dev362
1.4.dev360
1.4.dev359
1.4.dev356
1.4.dev355
1.4.dev354
1.4.dev353
1.4.dev352
1.4.dev351
1.4.dev348
1.4.dev347
1.4.dev346
1.4.dev345
1.4.dev344
1.4.dev343
1.4.dev342
1.4.dev341
1.4.dev340
1.4.dev339
1.4.dev337
1.4.dev336
1.4.dev335
1.4.dev334
1.4.dev333
1.4.dev332
1.4.dev331
1.4.dev330
1.4.dev327
1.4.dev326
1.4.dev325
1.4.dev324
1.4.dev322
1.4.dev321
1.4.dev319
1.4.dev318
1.4.dev317
1.4.dev316
1.4.dev315
1.4.dev314
1.4.dev313
1.4.dev310
1.4.dev308
1.4.dev307
1.4.dev306
1.4.dev305
1.4.dev303
1.4.dev302
1.4.dev301
1.4.dev300
1.4.dev299
1.4.dev298
1.4.dev297
1.4.dev296
1.4.dev295
1.4.dev294
1.4.dev293
1.4.dev292
1.4.dev291
1.4.dev290
1.4.dev289
1.4.dev288
1.3.dev287
1.3
1.2
1.1
1.0.1
1.0
1.4.dev452
1.4.dev450
1.4.dev447
1.4.dev446
1.4.dev445
1.4.dev444
1.4.dev443
1.4.dev441
1.4.dev439
1.4.dev438
1.4.dev420
1.4.dev419
1.4.dev413
1.4.dev412
1.4.dev411
1.4.dev410
1.4.dev409
1.4.dev408
1.4.dev407
1.4.dev406
1.4.dev405
1.4.dev404
1.4.dev403
1.4.dev402
1.4.dev400
1.4.dev399
1.4.dev398
1.4.dev397
1.4.dev396
1.4.dev395
1.4.dev394
1.4.dev393
1.4.dev392
1.4.dev391
1.4.dev390
1.4.dev389
1.4.dev388
1.4.dev386
1.4.dev382
1.4.dev381
1.4.dev380
1.4.dev379
1.4.dev378
1.4.dev375
1.4.dev374
1.4.dev373
1.4.dev372
1.4.dev371
1.4.dev369
1.4.dev368
1.4.dev367
1.4.dev366
1.4.dev365
1.4.dev364
1.4.dev363
1.4.dev362
1.4.dev360
1.4.dev359
1.4.dev356
1.4.dev355
1.4.dev354
1.4.dev353
1.4.dev352
1.4.dev351
1.4.dev348
1.4.dev347
1.4.dev346
1.4.dev345
1.4.dev344
1.4.dev343
1.4.dev342
1.4.dev341
1.4.dev340
1.4.dev339
1.4.dev337
1.4.dev336
1.4.dev335
1.4.dev334
1.4.dev333
1.4.dev332
1.4.dev331
1.4.dev330
1.4.dev327
1.4.dev326
1.4.dev325
1.4.dev324
1.4.dev322
1.4.dev321
1.4.dev319
1.4.dev318
1.4.dev317
1.4.dev316
1.4.dev315
1.4.dev314
1.4.dev313
1.4.dev310
1.4.dev308
1.4.dev307
1.4.dev306
1.4.dev305
1.4.dev303
1.4.dev302
1.4.dev301
1.4.dev300
1.4.dev299
1.4.dev298
1.4.dev297
1.4.dev296
1.4.dev295
1.4.dev294
1.4.dev293
1.4.dev292
1.4.dev291
1.4.dev290
1.4.dev289
1.4.dev288
1.3.dev287
1.3
1.2
1.1
1.0.1
1.0
توضیحات
Named Tensors for Legible Deep Learning in JAX
| ویژگی | مقدار |
|---|---|
| سیستم عامل | POSIX :: Linux |
| نام فایل | haliax-1.4.dev452 |
| نام | haliax |
| نسخه کتابخانه | 1.4.dev452 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | - |
| ایمیل نویسنده | David Hall <dlwh@cs.stanford.edu> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/haliax/ |
| مجوز | - |
<!--haliax-intro-start-->
# Haliax
<a href="https://github.com/stanford-crfm/haliax/actions?query=branch%3Amain++">
<img alt="Build Status" src="https://img.shields.io/github/actions/workflow/status/stanford-crfm/haliax/run_tests.yaml?branch=main">
</a>
<a href="https://haliax.readthedocs.io/en/latest/?badge=latest">
<img alt="Documentation Status" src="https://readthedocs.org/projects/haliax/badge/?version=latest">
</a>
<a href="">
<img alt="License" src="https://img.shields.io/github/license/stanford-crfm/haliax?color=blue" />
</a>
<a href="https://https://pypi.org/project/haliax/">
<img alt="PyPI" src="https://img.shields.io/pypi/v/haliax?color=blue" />
</a>
> *Though you don’t seem to be much for listening, it’s best to be careful. If you managed to catch hold of even just a piece of my name, you’d have all manner of power over me.*<br/>
> — Patrick Rothfuss, *The Name of the Wind*
Haliax is a [JAX](https:://github.com/google/jax) library for building neural networks with named tensors, in the tradition of Alexander Rush's [Tensor Considered Harmful](https://nlp.seas.harvard.edu/NamedTensor).
Named tensors improve the **legibility** and **compositionality** of tensor programs by using named axes instead of positional indices
as typically used in NumPy, PyTorch, etc.
Despite the focus on legibility, Haliax
is also **fast**, typically about as fast as "pure" JAX code.
Haliax is also built to be **scalable**: it
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),
our companion library for training large language models and other foundation models, with scale proven up to 20B parameters
and up to a TPU v3-256 pod slice.
## Example: Attention
Here's a minimal attention module implementation in Haliax. For a more detailed introduction,
please see the [Haliax tutorial](https://colab.research.google.com/drive/1TiTcQQ4V5mopbgCu1SVl-oqJtXn7rFnC).
(We use the excellent [Equinox](https://github.com/patrick-kidger/equinox) library for its module system and tree transformations.)
```python
import haliax.nn.normalization
import haliax.nn.activations
import equinox as eqx
import jax
import jax.numpy as jnp
import haliax as hax
import haliax.nn as hnn
Pos = hax.Axis("position", 1024) # sequence length
KPos = Pos.alias("key_position")
Head = hax.Axis("head", 8) # number of attention heads
Key = hax.Axis("key", 64) # key size
Embed = hax.Axis("embed", 512) # embedding size
def attention_scores(Key, KPos, query, key, mask):
# how similar is each query to each key
scores = hax.dot(query, key, axis=Key) / jnp.sqrt(Key.size)
if mask is not None:
scores -= 1E9 * (1.0 - mask)
# convert to probabilities
scores = haliax.nn.normalization.softmax(scores, KPos)
return scores
def attention(Key, KPos, query, key, value, mask):
scores = attention_scores(Key, KPos, query, key, mask)
answers = hax.dot(scores, value, axis=KPos)
return answers
# Causal Mask means that if pos >= key_pos, then pos can attend to key_pos
causal_mask = hax.arange(Pos).broadcast_axis(KPos) >= hax.arange(KPos)
class Attention(eqx.Module):
proj_q: hnn.Linear # [Embed] -> [Head, Key]
proj_k: hnn.Linear # [Embed] -> [Head, Key]
proj_v: hnn.Linear # [Embed] -> [Head, Key]
proj_answer: hnn.Linear # output projection from [Head, Key] -> [Embed]
@staticmethod
def init(Embed, Head, Key, *, key):
k_q, k_k, k_v, k_ans = jax.random.split(key, 4)
proj_q = hnn.Linear.init(In=Embed, Out=(Head, Key), key=k_q)
proj_k = hnn.Linear.init(In=Embed, Out=(Head, Key), key=k_k)
proj_v = hnn.Linear.init(In=Embed, Out=(Head, Key), key=k_v)
proj_answer = hnn.Linear.init(In=(Head, Key), Out=Embed, key=k_ans)
return Attention(proj_q, proj_k, proj_v, proj_answer)
def __call__(self, x, mask=None):
q = self.proj_q(x)
# Rename "position" to "key_position" for self attention
k = self.proj_k(x).rename({"position": "key_position"})
v = self.proj_v(x).rename({"position": "key_position"})
answers = attention(Key, KPos, q, k, v, causal_mask)
x = self.proj_answer(answers)
return x
```
Haliax was created by [Stanford's Center for Research on Foundation Models (CRFM)](https://crfm.stanford.edu/)'s research engineering team.
You can find us in the #levanter channel on the unofficial [Jax LLM Discord](https://discord.gg/FkRGNX3ND).
<!--haliax-intro-end-->
## Documentation
### Tutorials
These are some tutorials to get you started with Haliax. They are available as Colab notebooks:
<!--haliax-tutorials-start-->
* [Introduction to Haliax with Transformers](https://colab.research.google.com/drive/1TiTcQQ4V5mopbgCu1SVl-oqJtXn7rFnC)
* [Distributed Training in Haliax](https://colab.research.google.com/drive/1QX4yH3zRFF3Xiibf1aahETcSQ5nbcUMz) (including FSDP)
* [Tensor Parallelism in Haliax](https://colab.research.google.com/drive/18_BrtDpe1lu89M4T6fKzda8DdSLtFJhi)
* [Mixed Precision with `jmp`](https://colab.research.google.com/drive/1_4cikwt-UhSH7yRzNRK8ze9msM9r2mEl?usp=sharing) (This one is really a tutorial for [jmp](https://github.com/deepmind/jmp) but it's how to use it with Haliax...)
<!--haliax-tutorials-end-->
### API Reference
Haliax's API documentation is available at [haliax.readthedocs.io](https://haliax.readthedocs.io/en/latest/).
## Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
We also have a list of [good first issues](https://github.com/stanford-crfm/haliax/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
to help you get started. (If those don't appeal, don't hesitate to reach out to us on Discord!)
## License
Haliax is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.
نیازمندی
| مقدار | نام |
|---|---|
| - | equinox>=0.10.6 |
| - | jaxtyping>=0.2.20 |
| - | jmp>=0.0.4 |
| xtr | mkdocs-include-markdown-plugin; |
| xtr | mkdocs-literate-nav>=0.6.0; |
| xtr | mkdocs-macros-plugin>=0.7.0; |
| xtr | mkdocs-material>=7.3.3; |
| xtr | mkdocs>=1.4.3; |
| xtr | mkdocstrings-python>=1.1.2; |
| xtr | mkdocstrings>=0.22.0; |
| xtr | mypy>=0.910; |
| xtr | pygments; |
| xtr | pymdown-extensions; |
| xtr | pytest>=7.4.0; |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.10 | Python |
نحوه نصب
نصب پکیج whl haliax-1.4.dev452:
pip install haliax-1.4.dev452.whl
نصب پکیج tar.gz haliax-1.4.dev452:
pip install haliax-1.4.dev452.tar.gz