Skip to main content

Splitting the Brain to Beat the Clock

Racecraft · Part 3 of 5 · ← Prologue

Splitting the Brain to Beat the Clock

How a "brake!" lands in 5 milliseconds while a cloud model thinks for five seconds — in the same app, on the same frame, without ever colliding.

Two posts in, we have a coach that knows who's driving and what to say. This post is about the only thing that lets it say anything useful: structure. Specifically, the decision to give the system not one brain but three, each on its own clock, with an ironclad rule about which one is allowed to make the driver wait.

I call it the Split-Brain engine, and the whole design collapses out of one observation. The three jobs a coach does — react, strategize, prepare — have wildly different deadlines. Trying to serve all three from one code path means the fastest job inherits the latency of the slowest. That's the original sin of every cloud-first coaching app. So I refused to let them share a path.

The Split-Brain engine Every telemetry frame fans out to three lanes against a 300–500 ms budget. The loop never waits on the slow ones. TelemetryRaceBox BLEGPS · IMU · camera~50–100 Hz fused HOT < 50 ms · deterministicDECISION_MATRIX heuristics · P0 safety + P1 tacticalno network · no LLM · measured 5 ms p95 on Pixel 10 COLD 2–5 s · cloudGemini 2.5 Flash Lite · "why, not what" strategyasync · the loop does not block on it FEEDFORWARD · geofencedGPS-triggered, velocity-scaled, ~150 m before a corner"T7 right: late apex, brake at the 100 m board" CoachingQueuepriority queueP0 preempts allTimingGate gates by phase audiospoken Design principle"Feedback 800 ms late is worse than silence." — so the safety lane is deterministic and never shares a thread with a model.
Three lanes, three clocks. The only hard rule: nothing slow is allowed to block the HOT lane.

The HOT lane: dumb on purpose

The HOT lane is the one that fires "brake!" and "oversteer — ease off!". The temptation, in 2026, is to make it smart. I made it deliberately, aggressively dumb: a hand-written DECISION_MATRIX of heuristics that's evaluated on every fused telemetry frame. No network. No model. No allocation surprises. Just arithmetic and comparisons.

Why throw away the AI exactly where the stakes are highest? Two reasons, and they're both about trust. First, speed: a heuristic check is trivially fast and has no tail latency — no GC pause, no token stream, no cold start. Second, auditability: I can read the rule that fired a safety alert and tell you precisely why. You cannot do that with a sampled language model, and "the model felt like it" is not an acceptable answer when the message is "brake."

How fast is "fast"? On a recorded Pixel 10 session, the HOT path's 95th-percentile latency was 5.00 ms against a self-imposed ceiling of 50 ms, and the P0 audio dispatch maxed at 5 ms against a 100 ms budget. That's not a simulation; it's pulled from the on-device validation artifact I'll dig into in Part 5.

The latency budget, to scale Where each lane lands against the 300–500 ms perception window. Numbers are real where measured. 5 ms50 ms500 ms5 s 300–500 ms perception window — feedback must land here HOT · ~5 ms p95 (measured, Pixel 10) HOT budget ceiling = 50 ms COLD · Gemini 2.5 Flash Lite · 2–5 s — runs off the critical path The HOT lane finishes ~10× inside its own ceiling and ~60–100× faster than the cloud lane. That gap is the whole reason safety never shares a code path with a model. The COLD lane is slow because nobody waits for it.
Drawn to scale: the reflex lane and the thinking lane live two orders of magnitude apart.

The traffic controllers: CoachingQueue and TimingGate

Three lanes producing messages would be chaos without two referees. The CoachingQueue is a priority queue where a P0 safety message doesn't politely wait its turn — it preempt()s, jumping everything else. This is the structural guarantee behind the trust thesis: a "brake!" can be generated while a chatty COLD-path sentence is mid-flight, and the brake still wins.

// P0 never queues behind tactical or strategic chatter.
if (decision.priority === 0) {
  coachingQueue.preempt(decision);   // jumps the line, flushes lower-priority TTS
} else {
  coachingQueue.enqueue(decision);   // normal cooldown + cadence rules apply
}

The TimingGate solves the opposite problem: advice that's correct but ill-timed. It's a small state machine tracking the car's CornerPhase — braking, turn-in, apex, exit — and it can enforce silence during peak cognitive load. Telling a beginner to "watch your line" at the apex is technically true and actively harmful. The gate knows to shut up.

The two traps I walked into

Trap one: the humanizer. The function that turns a raw decision into a spoken phrase, humanizeAction, lives on the HOT path. The moment it does anything heavy — a lookup that touches I/O, a stray async hop — the 50 ms budget is gone. I kept it ruthlessly synchronous: string formatting and switch statements, nothing else. Predictable execution time is the feature.

Trap two: the on-device model sneaking onto the hot thread. The edge model (more on Gemma in Part 4) runs in a single-flight async queue — one request in flight, ever, and never on the path that produces a safety cue. Even at the OS level the app asks Android for CONNECTION_PRIORITY_HIGH on the RaceBox Bluetooth link, telling the system to minimize jitter on the one sensor stream the whole thing depends on.

The architecture isn't clever. It's disciplined. Every fast thing is forbidden from depending on a slow thing.

That discipline is what makes the next part possible. Because the slow, smart lane is fully decoupled, I can drop a real language model into it — on the phone, no cloud — and if it's slow, or missing, or actively on fire, the car still gets coached. Next: putting Gemma 4 in the cockpit, and the week I lost to a single rejected tensor.

Racecraft · on-device real-time driving coach built around Gemma 4. Code: github.com/rabimba/speedracer-AI.

Comments

Popular posts from this blog

Racecraft (Project Koru) · Prologue — The Origin Story

Racecraft · Prologue , The Origin Story It Started With a Wine List and a Question About Racing How a happy-hour conversation in the Bay Area turned into a trustable AI race coach , and then into a second version that runs entirely on a phone, on the NPU. This is the prologue to a five-part series. Two years ago(1st November, 2024) I was in the Bay Area for a GDE Summit. If you've never been: it's a couple of days of talks among Google Developer Experts, the kind of people who get unreasonably excited about a new on-device runtime, and then , mercifully , a happy hour where everyone stops performing and just eats. We ended up at a restaurant(Puesto Santa Clara), a long table of GDEs, and I was doing the most important engineering of the evening: trying to decide which wine to order. Across the table was Ajeet Mirwani . I don't even remember how the wine talk turned into racing talk , these things drift , but the moment the word "racing" ...

A Split‑Brain Neuro‑Symbolic Training Method for High‑Velocity Autonomous Coaching from Telemetry

 Author: Rabimba Karanjai Scope: Problem statement + data methodology + model training (no deployment discussion) Abstract Real‑time coaching in motorsport is a safety‑critical learning problem : a system must map noisy, high‑frequency telemetry to short, actionable guidance that remains physically consistent and avoids hazardous recommendations . This paper proposes a “Split‑Brain” training formulation that separates (i) a semantic coaching target (what action/critique should be expressed) from (ii) a reflexive interface (how actions are represented as compact, verifiable tokens). The approach trains a Small Language Model (SLM) in the Gemma family [1] using QLoRA fine‑tuning [2] , and introduces a telemetry tokenizer plus teacher‑student synthesis pipeline to generate instruction‑action pairs at scale. Core contribution: a reproducible method to convert “ golden lap ” differential tel...

The Throughput Trap: Benchmarking vLLM on OpenXLA and the Reality of Production LLM Serving

vLLM Systems · DevLab 2026, Deep Dive I was recently invited by the Google TPU team to speak at the OpenXLA Summer DevLab 2026 . This post breaks down our deep-dive evaluation of the matured vLLM + OpenXLA stack, the fundamental engineering mismatches between CUDA and XLA serving paths, and why traditional capacity metrics are lying to you. If you are operating large language models at enterprise scale right now, your platform architecture team is likely staring at a massive infrastructure crossroads: Should we migrate our core serving workloads from GPUs to TPUs? Historically, NVIDIA's CUDA ecosystem was the only serious option for user-facing, low-latency LLM generation. But here in 2026, the economics and infrastructure options have transformed. Google TPUs are highly available, cheaper per chip, and the open-source serving stack built around vLLM and OpenXLA has officially achieved absolute production readiness. Yet, when our infrast...