Skip to content

Commit e301a1f

Browse files
authored
doc: add rendered demos to docs (#9)
#### Relevant issue or PR n/a #### Description of changes - Add rendered demos to docs. - Add extra navigation item for index page. #### Testing done manual #### License - [x] By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license](https://pasteurlabs.github.io/tesseract-jax/LICENSE). - [x] I sign the Developer Certificate of Origin below by adding my name and email address to the `Signed-off-by` line. <details> <summary><b>Developer Certificate of Origin</b></summary> ```text Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` </details> Signed-off-by: Dion Häfner <[email protected]>
1 parent 67d918f commit e301a1f

26 files changed

+1030
-136
lines changed

.github/workflows/test_examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
# test with oldest supported Python version only (for slow tests)
1717
python-version: ["3.10"]
1818

19-
demo:
19+
example:
2020
- simple
2121
- cfd
2222

@@ -46,7 +46,7 @@ jobs:
4646
uv sync --extra dev --frozen
4747
4848
- name: Run example
49-
working-directory: demo/${{matrix.demo}}
49+
working-directory: examples/${{matrix.example}}
5050
run: |
5151
uv pip install jupyter
5252
uv run --no-sync jupyter nbconvert --to notebook --execute demo.ipynb

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
`tesseract-jax` executes [Tesseracts](https://github.com/pasteurlabs/tesseract-core) as part of [JAX](https://github.com/jax-ml/jax) programs, with full support for function transformations like JIT, `grad`, and more.
66

77
[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) |
99
[Report an issue](https://github.com/pasteurlabs/tesseract-jax/issues) |
1010
[Talk to the community](https://si-tesseract.discourse.group/) |
1111
[Contribute](CONTRIBUTING.md)
@@ -31,7 +31,7 @@ The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesser
3131
2. Build an example Tesseract:
3232

3333
```bash
34-
$ tesseract build demo/simple/vectoradd_jax
34+
$ tesseract build examples/simple/vectoradd_jax
3535
```
3636

3737
3. Use it as part of a JAX program via the JAX-native `apply_tesseract` function:
@@ -44,26 +44,28 @@ The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesser
4444

4545
# Load the Tesseract
4646
t = Tesseract.from_image("vectoradd_jax")
47+
t.serve()
4748

4849
# Run it with JAX
49-
x = jnp.ones((1000, 1000))
50-
y = jnp.ones((1000, 1000))
50+
x = jnp.ones((1000,))
51+
y = jnp.ones((1000,))
5152

52-
def vector_add(x, y):
53-
return apply_tesseract(t, x, y)
53+
def vector_sum(x, y):
54+
res = apply_tesseract(t, {"a": {"v": x}, "b": {"v": y}})
55+
return res["vector_add"]["result"].sum()
5456

55-
vector_add(x, y) # success!
57+
vector_sum(x, y) # success!
5658

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)
59+
# You can also use it with JAX transformations like JIT and grad
60+
vector_sum_jit = jax.jit(vector_sum)
61+
vector_sum_jit(x, y)
6062

61-
vector_add_grad = jax.grad(vector_add)
62-
vector_add_grad(x, y)
63+
vector_sum_grad = jax.grad(vector_sum)
64+
vector_sum_grad(x, y)
6365
```
6466

6567
> [!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.
68+
> 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.
6769

6870
## Sharp edges
6971

demo/cfd/Readme.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

demo/simple/README.md

Whitespace-only changes.

docs/conf.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

99
import re
10+
import shutil
11+
from pathlib import Path
1012

1113
from tesseract_jax import __version__
1214

13-
project = "tesseract-jax"
14-
copyright = "2025, The tesseract-jax Team @ Pasteur Labs"
15-
author = "The tesseract-jax Team @ Pasteur Labs"
15+
project = "Tesseract-JAX"
16+
copyright = "2025, Pasteur Labs"
17+
author = "The Tesseract-JAX Team @ Pasteur Labs + OSS contributors"
1618

1719
# The short X.Y version
1820
parsed_version = re.match(r"(\d+\.\d+\.\d+)", __version__)
@@ -28,12 +30,16 @@
2830
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
2931

3032
extensions = [
31-
"myst_parser",
33+
"myst_nb", # This is myst-parser + jupyter notebook support
3234
"sphinx.ext.intersphinx",
3335
"sphinx.ext.autodoc",
3436
"sphinx.ext.napoleon",
3537
"sphinx.ext.viewcode",
3638
"sphinx_autodoc_typehints",
39+
# Copy button for code blocks
40+
"sphinx_copybutton",
41+
# OpenGraph metadata for social media sharing
42+
"sphinxext.opengraph",
3743
]
3844

3945
myst_enable_extensions = [
@@ -62,6 +68,18 @@
6268
html_theme_options = {
6369
"light_logo": "logo-light.png",
6470
"dark_logo": "logo-dark.png",
65-
"sidebar_hide_name": False,
71+
"sidebar_hide_name": True,
6672
}
6773
html_css_files = ["custom.css"]
74+
75+
76+
# -- Handle Jupyter notebooks ------------------------------------------------
77+
78+
# Do not execute notebooks during build (just take existing output)
79+
nb_execution_mode = "off"
80+
81+
# Copy example notebooks to demo_notebooks folder on every build
82+
for example_notebook in Path("../examples").glob("*/demo.ipynb"):
83+
# Copy the example notebook to the docs folder
84+
dest = (Path("demo_notebooks") / example_notebook.parent.name).with_suffix(".ipynb")
85+
shutil.copyfile(example_notebook, dest)

docs/content/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# API documentation
1+
# API reference
22

33
```{eval-rst}
44
.. automodule:: tesseract_jax

docs/content/get-started.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Get started
2+
3+
`tesseract-jax` executes [Tesseracts](https://github.com/pasteurlabs/tesseract-core) as part of JAX programs, with full support for function transformations like JIT, `grad`, `jvp`, and more.
4+
5+
The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesseract_client, inputs)`](tesseract_jax.apply_tesseract), which is fully traceable by JAX. This enables end-to-end autodifferentiation and JIT compilation of Tesseract-based pipelines.
6+
7+
## Quick start
8+
9+
```{note}
10+
Before proceeding, make sure you have a [working installation of Docker](https://docs.docker.com/engine/install/) and a modern Python installation (Python 3.10+).
11+
```
12+
13+
```{seealso}
14+
For more detailed installation instructions, please refer to the [Tesseract Core documentation](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/introduction/installation.html).
15+
```
16+
17+
1. Install Tesseract-JAX:
18+
19+
```bash
20+
$ pip install tesseract-jax
21+
```
22+
23+
2. Build an example Tesseract:
24+
25+
```bash
26+
$ tesseract build examples/simple/vectoradd_jax
27+
```
28+
29+
3. Use it as part of a JAX program:
30+
31+
```python
32+
import jax
33+
import jax.numpy as jnp
34+
from tesseract_core import Tesseract
35+
from tesseract_jax import apply_tesseract
36+
37+
# Load the Tesseract
38+
t = Tesseract.from_image("vectoradd_jax")
39+
t.serve()
40+
41+
# Run it with JAX
42+
x = jnp.ones((1000,))
43+
y = jnp.ones((1000,))
44+
45+
def vector_sum(x, y):
46+
res = apply_tesseract(t, {"a": {"v": x}, "b": {"v": y}})
47+
return res["vector_add"]["result"].sum()
48+
49+
vector_sum(x, y) # success!
50+
51+
# You can also use it with JAX transformations like JIT and grad
52+
vector_sum_jit = jax.jit(vector_sum)
53+
vector_sum_jit(x, y)
54+
55+
vector_sum_grad = jax.grad(vector_sum)
56+
vector_sum_grad(x, y)
57+
```
58+
59+
```{tip}
60+
Now you're ready to jump into our [examples](https://github.com/pasteurlabs/tesseract-jax/tree/main/examples) for ways to use Tesseract-JAX.
61+
```
62+
63+
## Sharp edges
64+
65+
- **Arrays vs. array-like objects**: Tesseract-JAX ist 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.
66+
67+
```python
68+
from tesseract_core import Tesseract
69+
from tesseract_jax import apply_tesseract
70+
71+
tess = Tesseract.from_image("vectoradd")
72+
apply_tesseract(tess, {"a": 1.0, "b": 2.0}) # ❌ raises an error
73+
apply_tesseract(tess, {"a": jnp.array(1.0), "b": jnp.array(2.0)}) # ✅ works
74+
```
75+
- **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.
76+
77+
```{tip}
78+
When creating a new Tesseract based on a JAX function, use `tesseract init --recipe jax` to define all required endpoints automatically, including `abstract_eval` and `vector_jacobian_product`.
79+
```

docs/demo_notebooks/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.ipynb

docs/index.md

Lines changed: 20 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,39 @@
1-
# tesseract-jax
1+
# Tesseract-JAX
22

3-
`tesseract-jax` executes [Tesseracts](https://github.com/pasteurlabs/tesseract-core) as part of JAX programs, with full support for function transformations like JIT, `grad`, `jvp`, and more.
4-
5-
The API of Tesseract-JAX consists of a single function, [`apply_tesseract(tesseract_client, inputs)`](tesseract_jax.apply_tesseract), which is fully traceable by JAX. This enables end-to-end autodifferentiation and JIT compilation of Tesseract-based pipelines.
6-
7-
## Quick start
8-
9-
```{note}
10-
Before proceeding, make sure you have a [working installation of Docker](https://docs.docker.com/engine/install/) and a modern Python installation (Python 3.10+).
11-
```
12-
13-
```{seealso}
14-
For more detailed installation instructions, please refer to the [Tesseract Core documentation](https://docs.pasteurlabs.ai/projects/tesseract-core/latest/content/introduction/installation.html).
3+
```{include} content/get-started.md
4+
:start-line: 2
155
```
166

17-
1. Install Tesseract-JAX:
18-
19-
```bash
20-
$ pip install tesseract-jax
21-
```
22-
23-
2. Build an example Tesseract:
24-
25-
```bash
26-
$ tesseract build demo/simple/vectoradd_jax
27-
```
28-
29-
3. Use it as part of a JAX program:
30-
31-
```python
32-
import jax
33-
import jax.numpy as jnp
34-
from tesseract_core import Tesseract
35-
from tesseract_jax import apply_tesseract
36-
37-
# Load the Tesseract
38-
t = Tesseract.from_image("vectoradd_jax")
39-
40-
# Run it with JAX
41-
x = jnp.ones((1000, 1000))
42-
y = jnp.ones((1000, 1000))
7+
## License
438

44-
def vector_add(x, y):
45-
return apply_tesseract(t, x, y)
9+
Tesseract JAX is licensed under the [Apache License 2.0](https://github.com/pasteurlabs/tesseract-jax/LICENSE) and is free to use, modify, and distribute (under the terms of the license).
4610

47-
vector_add(x, y) # success!
11+
Tesseract is a registered trademark of Pasteur Labs, Inc. and may not be used without permission.
4812

49-
# You can also use it with JAX transformations like JIT and grad
50-
vector_add_jit = jax.jit(vector_add)
51-
vector_add_jit(x, y)
5213

53-
vector_add_grad = jax.grad(vector_add)
54-
vector_add_grad(x, y)
55-
```
14+
```{toctree}
15+
:caption: Usage
16+
:maxdepth: 2
17+
:hidden:
5618
57-
```{tip}
58-
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.
19+
content/get-started
20+
content/api
5921
```
6022

61-
## Sharp edges
62-
63-
- **Arrays vs. array-like objects**: Tesseract-JAX ist 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.
64-
65-
```python
66-
from tesseract_core import Tesseract
67-
from tesseract_jax import apply_tesseract
68-
69-
tess = Tesseract.from_image("vectoradd")
70-
apply_tesseract(tess, {"a": 1.0, "b": 2.0}) # ❌ raises an error
71-
apply_tesseract(tess, {"a": jnp.array(1.0), "b": jnp.array(2.0)}) # ✅ works
72-
```
73-
- **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.
23+
```{toctree}
24+
:caption: Examples
25+
:maxdepth: 2
26+
:hidden:
7427
75-
```{tip}
76-
When creating a new Tesseract based on a JAX function, use `tesseract init --recipe jax` to define all required endpoints automatically, including `abstract_eval` and `vector_jacobian_product`.
28+
demo_notebooks/simple.ipynb
29+
demo_notebooks/cfd.ipynb
7730
```
7831

7932
```{toctree}
80-
:caption: Contents
33+
:caption: See also
8134
:maxdepth: 2
8235
:hidden:
8336
84-
content/api
85-
Tesseract Core documentation <https://docs.pasteurlabs.ai/projects/tesseract-core/latest/>
37+
Tesseract Core docs <https://docs.pasteurlabs.ai/projects/tesseract-core/latest/>
8638
Tesseract User Forums <https://si-tesseract.discourse.group/>
8739
```
88-
89-
## License
90-
91-
Tesseract JAX is licensed under the [Apache License 2.0](https://github.com/pasteurlabs/tesseract-jax/LICENSE) and is free to use, modify, and distribute (under the terms of the license).
92-
93-
Tesseract is a registered trademark of Pasteur Labs, Inc. and may not be used without permission.

docs/static/logo-dark.png

-1.05 KB
Loading

0 commit comments

Comments
 (0)