Examples

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#

Fashion-MNIST on a TPU

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.

examples/fashion_mnist.md
Keras + JAX on a CPU node

The smallest possible check. Keras on JAX on a CPU node, without accelerator quota. Use it to test your install before you request hardware.

examples/simple_demo.md

Core#

Submit, monitor, and reattach

The full detached-job API: run_async(), status(), tail(), result(), a reattach from another shell with kinetic.attach(), and list_jobs().

examples/example_async_jobs.md
Ship local files into the job

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.

examples/example_data_api.md
Mount data with FUSE

Data(..., fuse=True) for volumes, single files, several mounts in one job, and a mix of mounted and downloaded data.

examples/example_fuse.md
Resumable JAX training with Orbax

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.

examples/example_checkpoint.md
Resumable Keras training

The same pattern for Keras. Round-trips model.get_weights() through Orbax, so a restarted job continues at the right step.

examples/example_keras_checkpoint.md
Parallel hyperparameter sweep

Fan out a grid of jobs with run_async_map(), limit the concurrency, collect the results, and handle the job that fails.

examples/example_collections.md
Mix accelerators in one script

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.

examples/example_gke.md

Advanced#

Multi-host JAX on Pathways

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.

examples/pathways_example.md
Distributed Gemma 2B fine-tune

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.

examples/gemma_sft_pathways_distributed.md
Single-TPU Gemma 3 fine-tune

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.

examples/gemma3_sft_demo.md
Tunix SFT

Supervised fine-tuning of Gemma 3 with LoRA and QLoRA through Tunix on a TPU v5e slice, with credentials forwarded through capture_env_vars.

examples/tunix_sft.md

Tutorials#

The pages in the Examples & Tutorials section of the sidebar are longer walkthroughs: