Get started¶
Quick start¶
Note
You need Python 3.12+ and uv, which Tesseract uses to build a separate virtual environment for each Tesseract. Docker is only needed to build container images.
Install Tesseract-JAX and get the example Tesseracts:
$ pip install tesseract-jax $ git clone https://github.com/pasteurlabs/tesseract-jax
Use a Tesseract as part of a JAX program:
import jax import jax.numpy as jnp from tesseract_core import Tesseract from tesseract_jax import apply_tesseract # Serve the Tesseract in its own process (its environment is built on first use) t = Tesseract.from_source("tesseract-jax/examples/simple/vectoradd_jax/tesseract_api.py") t.serve() # Run it with JAX x = jnp.ones((1000,)) y = jnp.ones((1000,)) def vector_sum(x, y): res = apply_tesseract(t, {"a": {"v": x}, "b": {"v": y}}, vmap_method="sequential") return res["vector_add"]["result"].sum() vector_sum(x, y) # success! # You can also use it with JAX transformations like JIT and grad vector_sum_jit = jax.jit(vector_sum) vector_sum_jit(x, y) vector_sum_grad = jax.grad(vector_sum) vector_sum_grad(x, y) # vmap requires an explicit vmap_method — "sequential" is safe but slow # while "auto_experimental" or "expand_dims" is more efficient for Tesseracts that support batching. vector_sum_vmap = jax.vmap(vector_sum) vector_sum_vmap(x.reshape(10, 100), y.reshape(10, 100))
from_sourcebuilds the environment from the Tesseract’s requirements into.tesseract-venvnext totesseract_api.py, or runs on an existing interpreter passed aspython_executable=.... Unlike a container, the Tesseract is not isolated from your filesystem and user.To share or deploy the Tesseract, build the same folder into a container image (this step requires Docker) and replace
from_sourcewithfrom_image:$ tesseract build tesseract-jax/examples/simple/vectoradd_jax
t = Tesseract.from_image("vectoradd_jax")
Use
Tesseract.from_url(...)to reach a Tesseract that is already running elsewhere.apply_tesseractworks the same way with all three.
See also
See Batching strategies for jax.vmap for a guide on selecting the appropriate vmap_method, and the Tesseract Core documentation for more on installing and serving Tesseracts.
Tip
Now you’re ready to jump into our examples for ways to use Tesseract-JAX.