You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-21Lines changed: 34 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,17 +2,26 @@
2
2
3
3
### Tesseract-JAX
4
4
5
-
`tesseract-jax` executes [Tesseracts](https://github.com/pasteurlabs/tesseract-core)as part of JAX programs, with full support for function transformations like JIT, `grad`, and more.
5
+
Tesseract-JAX is a lightweight extension to [Tesseract Core](https://github.com/pasteurlabs/tesseract-core)that makes Tesseracts look and feel like regular [JAX](https://github.com/jax-ml/jax) primitives, and makes them jittable, differentiable, and composable.
6
6
7
7
[Read the docs](https://docs.pasteurlabs.ai/projects/tesseract-jax/latest/) |
8
-
[Explore the demos](https://github.com/pasteurlabs/tesseract-jax/tree/main/demo) |
8
+
[Explore the examples](https://github.com/pasteurlabs/tesseract-jax/tree/main/examples) |
9
9
[Report an issue](https://github.com/pasteurlabs/tesseract-jax/issues) |
10
10
[Talk to the community](https://si-tesseract.discourse.group/) |
11
11
[Contribute](CONTRIBUTING.md)
12
12
13
13
---
14
14
15
-
The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesseract_client, inputs)`](https://docs.pasteurlabs.ai/projects/tesseract-jax/latest/content/api.html#tesseract_jax.apply_tesseract), which is fully traceable by JAX. This enables end-to-end autodifferentiation and JIT compilation of Tesseract-based pipelines.
15
+
The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesseract_client, inputs)`](https://docs.pasteurlabs.ai/projects/tesseract-jax/latest/content/api.html#tesseract_jax.apply_tesseract), which is fully traceable by JAX. This enables end-to-end autodifferentiation and JIT compilation of Tesseract-based pipelines:
16
+
17
+
```python
18
+
@jax.jit
19
+
defvector_sum(x, y):
20
+
res = apply_tesseract(vectoradd_tesseract, {"a": {"v": x}, "b": {"v": y}})
21
+
return res["vector_add"]["result"].sum()
22
+
23
+
jax.grad(vector_sum)(x, y) # 🎉
24
+
```
16
25
17
26
## Quick start
18
27
@@ -31,7 +40,8 @@ The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesser
3. Use it as part of a JAX program via the JAX-native `apply_tesseract` function:
@@ -44,38 +54,41 @@ The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesser
44
54
45
55
# Load the Tesseract
46
56
t = Tesseract.from_image("vectoradd_jax")
57
+
t.serve()
47
58
48
59
# Run it with JAX
49
-
x = jnp.ones((1000,1000))
50
-
y = jnp.ones((1000,1000))
60
+
x = jnp.ones((1000,))
61
+
y = jnp.ones((1000,))
51
62
52
-
defvector_add(x, y):
53
-
return apply_tesseract(t, x, y)
63
+
defvector_sum(x, y):
64
+
res = apply_tesseract(t, {"a": {"v": x}, "b": {"v": y}})
65
+
return res["vector_add"]["result"].sum()
54
66
55
-
vector_add(x, y) # success!
67
+
vector_sum(x, y) # success!
56
68
57
-
# You can also use it with JAX transformations like JIT and grad
58
-
vector_add_jit = jax.jit(vector_add)
59
-
vector_add_jit(x, y)
69
+
# You can also use it with JAX transformations like JIT and grad
70
+
vector_sum_jit = jax.jit(vector_sum)
71
+
vector_sum_jit(x, y)
60
72
61
-
vector_add_grad = jax.grad(vector_add)
62
-
vector_add_grad(x, y)
63
-
```
73
+
vector_sum_grad = jax.grad(vector_sum)
74
+
vector_sum_grad(x, y)
75
+
```
64
76
65
77
> [!TIP]
66
-
> Now you're ready to jump into our [demos](https://github.com/pasteurlabs/tesseract-jax/tree/main/demo) for more examples on how to use Tesseract-JAX.
78
+
> Now you're ready to jump into our [examples](https://github.com/pasteurlabs/tesseract-jax/tree/main/examples) for more ways to use Tesseract-JAX.
67
79
68
80
## Sharp edges
69
81
70
-
-**Arrays vs. array-like objects**: Tesseract-JAXist stricter than Tesseract Core in that all array inputs to Tesseracts must be JAXor NumPy arrays, not just any array-like (such as Python floats or lists). As a result, you may need to convert your inputs to JAX arrays before passing them to Tesseract-JAX, including scalar values.
82
+
-**Arrays vs. array-like objects**: Tesseract-JAX is stricter than Tesseract Core in that all array inputs to Tesseracts must be JAX or NumPy arrays, not just any array-like (such as Python floats or lists). As a result, you may need to convert your inputs to JAX arrays before passing them to Tesseract-JAX, including scalar values.
71
83
72
84
```python
73
85
from tesseract_core import Tesseract
74
86
from tesseract_jax import apply_tesseract
75
87
76
-
tess = Tesseract.from_image("vectoradd")
77
-
apply_tesseract(tess, {"a": 1.0, "b": 2.0}) # ❌ raises an error
78
-
apply_tesseract(tess, {"a": jnp.array(1.0), "b": jnp.array(2.0)}) # ✅ works
88
+
tess = Tesseract.from_image("vectoradd_jax")
89
+
with Tesseract.from_image("vectoradd_jax") as tess:
apply_tesseract(tess, {"a": {"v": jnp.array([1.0])}, "b": {"v": jnp.array([2.0])}}) # ✅ works
79
92
```
80
93
-**Additional required endpoints**: Tesseract-JAX requires the [`abstract_eval`](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/api/endpoints.html#abstract-eval) Tesseract endpoint to be defined for all operations. This is because JAX mandates abstract evaluation of all operations before they are executed. Additionally, many gradient transformations like `jax.grad` require [`vector_jacobian_product`](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/api/endpoints.html#vector-jacobian-product) to be defined.
81
94
@@ -84,6 +97,6 @@ The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesser
84
97
85
98
## License
86
99
87
-
TesseractJAX is licensed under the [Apache License 2.0](LICENSE) and is free to use, modify, and distribute (under the terms of the license).
100
+
Tesseract-JAX is licensed under the [Apache License 2.0](LICENSE) and is free to use, modify, and distribute (under the terms of the license).
88
101
89
102
Tesseract is a registered trademark of Pasteur Labs, Inc. and may not be used without permission.
0 commit comments