Examples#
This page is a catalog of the runnable example scripts in the
repository. Each example renders on this site and is also a Python file
in the examples/ directory of the
GitHub repository.
The examples come in three tiers:
Quickstart — the first run, with the defaults.
Core — the everyday features: detached jobs, data, checkpoints, and parallel sweeps.
Advanced — multi-host Pathways jobs and LLM fine-tuning. These need special quota or external credentials.
To run an example, clone the repository, install Kinetic, make sure that
kinetic init has saved an active profile, and run the script:
git clone https://github.com/keras-team/kinetic.git
cd kinetic
uv pip install -e .
kinetic init # skip this step if you already have an active profile
python examples/fashion_mnist.py
Each example names its accelerator in the decorator. Your cluster needs a
node pool with that accelerator, or you change the accelerator= value.
See Getting Started.
The LLM examples import packages that the default image does not have,
such as keras-hub, tunix, and wandb. Before you run one of them,
put a requirements.txt with those packages next to the script, or in
the examples/ directory. Kinetic reads that file and builds an image
with the packages. See Dependencies.
Quickstart#
The first script to run after kinetic init. A small Keras classifier
on Fashion-MNIST that shows that your cluster can schedule a TPU pod and
return a result to your shell.
The smallest possible check. Keras on JAX on a CPU node, without accelerator quota. Use it to test your install before you request hardware.
Core#
The full detached-job API: run_async(), status(), tail(),
result(), a reattach from another shell with kinetic.attach(), and
list_jobs().
Wrap a local directory in kinetic.Data(...). The function receives a
plain filesystem path, and does not know whether the bytes started on
your laptop or in Cloud Storage.
Data(..., fuse=True) for volumes, single files, several mounts in one
job, and a mix of mounted and downloaded data.
JAX training that continues where it stopped. Writes Orbax checkpoints
to KINETIC_OUTPUT_DIR, and shows the resume path when you run the same
function again.
The same pattern for Keras. Round-trips model.get_weights() through
Orbax, so a restarted job continues at the right step.
Fan out a grid of jobs with run_async_map(), limit the concurrency,
collect the results, and handle the job that fails.
One script that runs work on a CPU pool, a TPU pool, and a GPU pool in turn. Useful to check which hardware your cluster serves.
Advanced#
The reference for a slice with more than one TPU host. A short JAX program that checks that the cross-host collectives work before you trust them with a real workload.
Supervised fine-tuning of Gemma 2B with LoRA and the Keras
DataParallel distribution. Pulls the weights from Kaggle, and forces
the pathways backend on a single-host slice to exercise the multi-host
code path.
Compact Gemma 3 1B fine-tuning on one TPU. A good baseline before you scale to Pathways, and a worked example of Kaggle credentials in the pod.
Supervised fine-tuning of Gemma 3 with LoRA and QLoRA through Tunix on
a TPU v5e slice, with credentials forwarded through capture_env_vars.
Tutorials#
The pages in the Examples & Tutorials section of the sidebar are longer walkthroughs:
Training Keras Models — patterns for an existing Keras script.
Native JAX Training — JAX loops, single-host parallelism, and multi-host slices.
PyTorch Training — PyTorch on GPU nodes.
Fine-tuning Gemma 4 on TPU — a complete LoRA fine-tune with inference.
Fine-tuning LLMs — Keras Hub, Kaggle credentials, and LoRA.
Running vLLM on TPU — vLLM inference on a TPU slice.