Inspiration
Golf apps fail exactly where they are used. Courses have dead zones, your hands are full between shots, and a round's data is personal. Logging "8 iron, short and right" should not need a data connection on the 14th tee. Hybrid inference fixes that: the on-course work runs on the phone, and the cloud does what the cloud is better at.
What it does
- Hands-free voice logging. Tap the mic and say the shot. Speech recognition is forced on-device, and the on-device model (Apple Foundation Models through Firebase AI Logic) turns the words into a shot record: club, yards, direction, where it finished. It works in Airplane Mode.
- An offline caddie. The app computes your round stats in code; the on-device model turns them into a two-sentence read ("your irons are missing right; favour the left side of greens").
- Scorecard photo → pars, tees and yardages, routed to the cloud by capability. The same prefer-on-device session receives the photo. Apple's on-device model takes text only, so Firebase AI Logic falls back to Gemini, and the badge visibly flips from On-device to Cloud. Pick your tees; the course is saved on the phone for next time, so setup happens once.
- "Log a shot in Rounds" with Siri. Siri asks for the shot and it goes through the same parser and prefer-on-device model; Siri reads back what was logged and where the AI ran.
- Ask your caddie, offline, streamed. The answer appears as the on-device model writes it. "What club from 150?" is answered on-device from the round's computed facts and your own club distances.
- Club for a distance. Type the yards; the app picks the club whose median logged distance is closest. Plain math.
- A "Where the AI ran" scoreboard on the summary: shots per source, average latency, and how much of the round needed no signal.
- A post-round debrief, prefer-cloud. Gemini writes three short paragraphs from the whole round; with no signal, the same session falls back to the on-device model. Diagnostics runs all four inference modes (prefer on-device, prefer cloud, only on-device, only cloud) on demand.
- GPS-measured shot distances, offline, shown with their error margin, and a satellite shot map (Apple MapKit, no API key) on the summary.
- Rounds Review (Chrome web companion). Tap Copy link for Chrome (or
Share) on the iPhone round summary to open the round at
https://statlab-rounds-companion.web.appvia the#r=URL fragment (no server upload). Review hole-by-hole shots and club yardage medians in plain code, then generate a debrief or ask questions powered by Gemini Nano in Chrome via Firebase AI Logic hybrid inference—with all four inference modes selectable and App Check (reCAPTCHA Enterprise) enforced. - Every AI result shows where it ran (On-device / Cloud), the model name and the latency, from the SDK's own report, never guessed.
How we built it
- Firebase AI Logic hybrid inference. Every call opens
generativeModelSession(model: HybridModel(primary: SystemLanguageModel.default, secondary: geminiModel(...))), a fresh session each time, because the SDK only falls back while the on-device session has no history. The badge comparesresponse.rawResponse.modelVersionwith the system model's name. The debrief uses a prefer-cloud hybrid session (HybridModel(primary: gemini, secondary: system)), and the caddie streams responses viastreamResponse(to:). App Check uses App Attest in TestFlight builds. - We read the SDK source, not just the docs. The hybrid API was removed in
firebase-ios-sdk 13.0.0, so the app is pinned to 12.19.3, the last release
with it. The image fallback we rely on is in the SDK's
Part.swiftandHybridModelSession.swift. - Guardrails so the model never invents your round. A deterministic shorthand parser reads the golfer's words. The model's rewrite must pass the same parser and a plausibility check, and it can only fill gaps; the golfer's words always win. The caddie and the debrief receive a facts sheet computed in code, and an answer containing any number that is not in the facts is discarded. The scorecard read only accepts 9 or 18 pars of 3 to 6. 70 unit tests (60 Swift in RoundsKit, 10 JS in web/test) verify parsers, stats, club math, and number-guard logic.
- Two platforms, one hybrid architecture. On iOS (
firebase-ios-sdk12.19.3) the primary model isSystemLanguageModel.default; on Chrome (firebase13.4.0) the primary model is Gemini Nano viaInferenceMode.PREFER_ON_DEVICE, falling back seamlessly togemini-3.5-flash-liteon both platforms. - Windows to iPhone, with no Mac. The app was written on Windows. GitHub Actions on an Xcode 27 runner runs the tests, compiles, signs and uploads to TestFlight on every push, so each change reached the iPhone in about 15 minutes.
Challenges we ran into
- The hybrid docs described an API that the latest SDK had removed. Reading the changelog and source found it, and pinning 12.19.3 kept the SDK's own routing report.
- Making the model trustworthy for numbers: models are fluent with figures they invent, so every number the user sees is computed in code, and model answers are checked against it.
- Signing and uploading iOS builds from CI without a Mac and without an Admin API key: manual signing with a dedicated certificate, created through the App Store Connect API.
Accomplishments that we're proud of
- On the first day, the on-device path ran on a real iPhone, in Airplane Mode,
with the SDK reporting
apple-foundation-models-system-language-model. - Routing by capability that the user can see: the same session answers text on-device and a photo in the cloud.
- A logger that still saves your shot when the model fails, because the model is an assistant, not the source of truth.
What we learned
On-device models are fast and private enough to do real work mid-round. The design win is deciding what each layer is trusted with: code owns facts, models own language, and the user can always see which model answered.
What's next for Rounds
Rounds is part of the StatLab family of apps from Luh Labs LLC and will link into StatLab Sports Network: rounds logged offline will sync via Firestore once back online alongside multi-round club dispersion trends and tee-shot heatmaps.
Pre-existing work
None. Every file in the repository was written between November 23 and November 30, 2026, for this contest; the commit history shows the order. Third-party libraries are listed in the README.
Built With
- apple-foundation-models
- apple-speech
- core-location
- firebase-ai-logic-(hybrid-inference)
- firebase-app-check-(app-attest)
- gemini-developer-api-(gemini-3.5-flash-lite)
- github-actions
- photosui
- swift
- swiftdata
- swiftui