Skip to content

Commit 26857c1

Browse files
committed
overhaul demos (now examples) and docs
1 parent 77d4f7f commit 26857c1

24 files changed

+121
-58
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 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: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
from tesseract_jax import __version__
1414

15-
project = "tesseract-jax"
16-
copyright = "2025, The tesseract-jax Team @ Pasteur Labs"
17-
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"
1818

1919
# The short X.Y version
2020
parsed_version = re.match(r"(\d+\.\d+\.\d+)", __version__)
@@ -36,6 +36,10 @@
3636
"sphinx.ext.napoleon",
3737
"sphinx.ext.viewcode",
3838
"sphinx_autodoc_typehints",
39+
# Copy button for code blocks
40+
"sphinx_copybutton",
41+
# OpenGraph metadata for social media sharing
42+
"sphinxext.opengraph",
3943
]
4044

4145
myst_enable_extensions = [
@@ -64,7 +68,7 @@
6468
html_theme_options = {
6569
"light_logo": "logo-light.png",
6670
"dark_logo": "logo-dark.png",
67-
"sidebar_hide_name": False,
71+
"sidebar_hide_name": True,
6872
}
6973
html_css_files = ["custom.css"]
7074

@@ -75,7 +79,7 @@
7579
nb_execution_mode = "off"
7680

7781
# Copy example notebooks to demo_notebooks folder on every build
78-
for example_notebook in Path("../demo").glob("*/demo.ipynb"):
82+
for example_notebook in Path("../examples").glob("*/demo.ipynb"):
7983
# Copy the example notebook to the docs folder
8084
dest = (Path("demo_notebooks") / example_notebook.parent.name).with_suffix(".ipynb")
8185
shutil.copyfile(example_notebook, dest)

docs/content/index.md renamed to docs/content/get-started.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tesseract-JAX
1+
# Get started
22

33
`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.
44

@@ -23,7 +23,7 @@ For more detailed installation instructions, please refer to the [Tesseract Core
2323
2. Build an example Tesseract:
2424

2525
```bash
26-
$ tesseract build demo/simple/vectoradd_jax
26+
$ tesseract build examples/simple/vectoradd_jax
2727
```
2828

2929
3. Use it as part of a JAX program:
@@ -36,26 +36,28 @@ For more detailed installation instructions, please refer to the [Tesseract Core
3636

3737
# Load the Tesseract
3838
t = Tesseract.from_image("vectoradd_jax")
39+
t.serve()
3940

4041
# Run it with JAX
41-
x = jnp.ones((1000, 1000))
42-
y = jnp.ones((1000, 1000))
42+
x = jnp.ones((1000,))
43+
y = jnp.ones((1000,))
4344

44-
def vector_add(x, y):
45-
return apply_tesseract(t, x, y)
45+
def vector_sum(x, y):
46+
res = apply_tesseract(t, {"a": {"v": x}, "b": {"v": y}})
47+
return res["vector_add"]["result"].sum()
4648

47-
vector_add(x, y) # success!
49+
vector_sum(x, y) # success!
4850

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)
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)
5254

53-
vector_add_grad = jax.grad(vector_add)
54-
vector_add_grad(x, y)
55-
```
55+
vector_sum_grad = jax.grad(vector_sum)
56+
vector_sum_grad(x, y)
57+
```
5658

5759
```{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.
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.
5961
```
6062

6163
## Sharp edges
@@ -75,9 +77,3 @@ Now you're ready to jump into our [demos](https://github.com/pasteurlabs/tessera
7577
```{tip}
7678
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`.
7779
```
78-
79-
## License
80-
81-
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).
82-
83-
Tesseract is a registered trademark of Pasteur Labs, Inc. and may not be used without permission.

docs/index.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1-
```{include} content/index.md
1+
# Tesseract-JAX
2+
3+
```{include} content/get-started.md
4+
:start-line: 2
25
```
36

7+
## License
8+
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).
10+
11+
Tesseract is a registered trademark of Pasteur Labs, Inc. and may not be used without permission.
12+
413

514
```{toctree}
6-
:caption: Contents
15+
:caption: Usage
716
:maxdepth: 2
817
:hidden:
918
10-
content/index
19+
content/get-started
1120
content/api
12-
Tesseract Core docs <https://docs.pasteurlabs.ai/projects/tesseract-core/latest/>
13-
Tesseract User Forums <https://si-tesseract.discourse.group/>
1421
```
1522

1623
```{toctree}
17-
:caption: Demos
24+
:caption: Examples
1825
:maxdepth: 2
1926
:hidden:
2027
2128
demo_notebooks/simple.ipynb
2229
demo_notebooks/cfd.ipynb
2330
```
31+
32+
```{toctree}
33+
:caption: See also
34+
:maxdepth: 2
35+
:hidden:
36+
37+
Tesseract Core docs <https://docs.pasteurlabs.ai/projects/tesseract-core/latest/>
38+
Tesseract User Forums <https://si-tesseract.discourse.group/>
39+
```

docs/static/logo-dark.png

-1.05 KB
Loading

docs/static/logo-light.png

-783 Bytes
Loading

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Tesseract-JAX examples
2+
3+
This directory contains example Tesseract configurations, notebooks. and scripts demonstrating how to use Tesseract-JAX in various contexts. Each example is self-contained and can be run independently.
4+
5+
## Examples
6+
7+
- [Simple](simple/demo.ipynb): A basic example of using Tesseract-JAX with a simple vector addition task. It demonstrates how to build a Tesseract and execute it within JAX.
8+
- [CFD](cfd/demo.ipynb): A more complex example demonstrating how to use Tesseract-JAX to differentiate through a computational fluid dynamics (CFD) simulation Tesseract.

0 commit comments

Comments
 (0)