Automation foundation model for tiny devices: 2-bit, 8-29 MB, tool calls, ASR, structured extraction and embeddings on phones, wearables, smart homes, robots, cars and microcontrollers.
TPU bug fixes
HenryNdubuakub297f001ede4
diff --git a/pyproject.toml b/pyproject.tomlindex 73a02c0..aba3ce6 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -12,6 +12,10 @@ dependencies = ["wandb",]+[project.optional-dependencies]+tpu = ["jax[tpu]"]+gpu = ["jax[cuda12]"]+[project.scripts]needle = "src.cli:main"diff --git a/setup b/setupindex 527aaa7..1c580c4 100755--- a/setup+++ b/setup@@ -53,8 +53,8 @@ echo "Installing dependencies..."pip install --upgrade pip -qpip install -e . -q-# If running on a TPU VM, load drivers and install JAX with TPU support-if lspci 2>/dev/null | grep -qi "google.*processing"; then+# Detect accelerator and install the matching JAX variant+if lspci 2>/dev/null | grep -qi "\[ff00\].*google\|google.*processing"; thenecho "TPU hardware detected..."# Load kernel modules if not already loaded@@ -79,6 +79,18 @@ if lspci 2>/dev/null | grep -qi "google.*processing"; thenecho "Enabling transparent hugepages..."sudo sh -c "echo always > /sys/kernel/mm/transparent_hugepage/enabled" 2>/dev/null || truefi++elif command -v nvidia-smi &>/dev/null && nvidia-smi &>/dev/null; then+ echo "NVIDIA GPU detected..."+ GPU_COUNT=$(nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | wc -l)+ echo "GPU devices: $GPU_COUNT"+ nvidia-smi --query-gpu=name --format=csv,noheader 2>/dev/null | head -4++ echo "Installing jax[cuda12]..."+ pip install "jax[cuda12]" -q++else+ echo "No accelerator detected, using CPU-only JAX."fiif [ -z "$WANDB_API_KEY" ]; thendiff --git a/src/train.py b/src/train.pyindex e479255..0623c44 100644--- a/src/train.py+++ b/src/train.py@@ -225,7 +225,10 @@ def train(args):os.makedirs(args.checkpoint_dir, exist_ok=True)global_step = 0- causal_mask = make_causal_mask(args.max_dec_len)+ causal_mask = jnp.broadcast_to(+ make_causal_mask(args.max_dec_len),+ (num_devices, 1, args.max_dec_len, args.max_dec_len),+ )adam_schedule = optax.warmup_cosine_decay_schedule(init_value=0.0, peak_value=args.lr,diff --git a/test.py b/test.pydeleted file mode 100644index c8640d9..0000000--- a/test.py+++ /dev/null@@ -1,11 +0,0 @@-import jax-import jax.numpy as jnp--print(f"JAX version: {jax.__version__}")-print(f"Number of devices: {jax.device_count()}")-print(f"Available devices: {jax.devices()}")--# Run a simple calculation-x = jnp.ones((2, 2))-y = jnp.dot(x, x)-print(f"Calculation result: {y}")