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.
Improve baseline
HenryNdubuakuc4b40edb1b77
diff --git a/setup b/setupindex 1c580c4..26b3307 100755--- a/setup+++ b/setup@@ -53,44 +53,24 @@ echo "Installing dependencies..."pip install --upgrade pip -qpip install -e . -q-# Detect accelerator and install the matching JAX variant-if lspci 2>/dev/null | grep -qi "\[ff00\].*google\|google.*processing"; then- echo "TPU hardware detected..."-- # Load kernel modules if not already loaded- if ! ls /dev/accel* &>/dev/null 2>&1; then- echo "Loading TPU kernel modules..."- for mod in gasket tpu_common tpu_v2 tpu_v3 tpu_v4 tpu_v4_lite; do- sudo modprobe "$mod" 2>/dev/null || true- done- fi-- if ls /dev/accel* &>/dev/null 2>&1; then- echo "TPU devices: $(ls /dev/accel* 2>/dev/null | wc -w) chip(s)"- else- echo "WARNING: TPU PCI devices found but no /dev/accel* — kernel drivers may not match hardware."- echo " Recreate the VM with the correct --version for your accelerator type."- fi-- echo "Installing jax[tpu]..."- pip install "jax[tpu]" -q -f https://storage.googleapis.com/jax-releases/libtpu_releases.html-- if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then- echo "Enabling transparent hugepages..."- sudo sh -c "echo always > /sys/kernel/mm/transparent_hugepage/enabled" 2>/dev/null || true- fi--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[tpu]..."+pip install "jax[tpu]" -f https://storage.googleapis.com/jax-releases/libtpu_releases.html++# Load TPU kernel modules if not already loaded+if ! ls /dev/accel* &>/dev/null 2>&1; then+ echo "Loading TPU kernel modules..."+ for mod in gasket tpu_common tpu_v2 tpu_v3 tpu_v4 tpu_v4_lite; do+ sudo modprobe "$mod" 2>/dev/null || true+ done+fi- echo "Installing jax[cuda12]..."- pip install "jax[cuda12]" -q+if ls /dev/accel* &>/dev/null 2>&1; then+ echo "TPU devices: $(ls /dev/accel* 2>/dev/null | wc -w) chip(s)"+fi-else- echo "No accelerator detected, using CPU-only JAX."+if [ -f /sys/kernel/mm/transparent_hugepage/enabled ]; then+ echo "Enabling transparent hugepages..."+ sudo sh -c "echo always > /sys/kernel/mm/transparent_hugepage/enabled" 2>/dev/null || truefiif [ -z "$WANDB_API_KEY" ]; thendiff --git a/src/cli.py b/src/cli.pyindex 1d8d1fb..789c9c2 100644--- a/src/cli.py+++ b/src/cli.py@@ -85,7 +85,7 @@ TOY_CONFIG = {}BASE_CONFIG = {- "epochs": 3,+ "epochs": 1,"batch_size": 32,"lr": 3e-4,"muon_lr": 0.02,@@ -95,7 +95,7 @@ BASE_CONFIG = {"dropout": 0.0,"max_enc_len": 256,"max_dec_len": 256,- "max_samples": None,+ "max_samples": 500000,"warmup_ratio": 0.05,"dtype": "float32","seed": 42,diff --git a/src/model.py b/src/model.pyindex e7b0d45..860cedf 100644--- a/src/model.py+++ b/src/model.py@@ -77,6 +77,9 @@ class MultiHeadAttention(nn.Module):k = k.reshape(B, -1, self.num_heads, head_dim).transpose(0, 2, 1, 3)v = v.reshape(B, -1, self.num_heads, head_dim).transpose(0, 2, 1, 3)+ q = nn.RMSNorm(dtype=self.dtype, name="q_norm")(q)+ k = nn.RMSNorm(dtype=self.dtype, name="k_norm")(k)+if rope is not None:cos, sin = ropeq = apply_rope(q, cos, sin)