Before you start: words you need#
| Word | Plain meaning |
|---|---|
| Hybrid inference | One product feature served sometimes by a model on the device and sometimes by a model in the cloud, behind one interface. |
| Router | The code that decides, per request, where it runs. |
| Cascade | Try a small, cheap model first and escalate to a bigger one only when needed (21.k). |
| Fallback | The path taken when the preferred one is unavailable: no network, no on-device model, not enough memory. |
| Private Cloud Compute (PCC) | Apple’s server system for Apple Intelligence requests too large for the device, built so that user data is not stored and cannot be seen even by Apple. |
| Inference source | A label on each response saying whether it came from the device or the cloud, for logging and debugging. |
| Redaction | Removing personal data from a request on the device before it is sent anywhere. |
1. What is it?#
Hybrid inference is the design where a feature runs on the device when it can and in the cloud when it must, with the user seeing one product. It is how all three OS vendors now ship AI:
- Apple: on-device AFM 3 Core and Core Advanced models, and AFM 3 Cloud and Cloud Pro on Private Cloud Compute. In June 2026 Apple said AFM 3 Cloud Pro was extended to NVIDIA GPUs in Google Cloud with the same privacy guarantees. From WWDC26 the Foundation Models framework also lets apps reach server models through the same Swift API.
- Google: Gemini Nano in AICore, with Firebase AI Logic hybrid inference (experimental since
April 2026) choosing between Nano on the device and Gemini in the cloud. Its modes are
PREFER_ON_DEVICE,ONLY_ON_DEVICE,PREFER_IN_CLOUDandONLY_IN_CLOUD, and each response reports itsinferenceSource. - Microsoft: Phi Silica and Foundry Local on the PC, Microsoft Foundry models in the cloud.
Facts checked on 13 November 2026. This lesson is about the device side of the split; cascades and fallbacks between server models are in 21.k.
2. Why does it matter?#
Neither side alone is enough:
| On device | Cloud | |
|---|---|---|
| Quality | 1–4B-class models (20B sparse at best) | frontier models |
| Latency | no network; fast first token on short prompts | network round trip, queueing; fast on long prompts |
| Availability | works offline; only on capable devices | needs a network; works on any device |
| Privacy | data never leaves | needs trust, contracts or PCC-style guarantees |
| Cost to the provider | zero per token | every token billed (23.c) |
| Cost to the user | battery, heat, storage, memory | data plan |
| Control | the model ships with the app or the OS; slow to update | update any time |
A product that is only on-device fails on old phones and hard tasks. A product that is only in the cloud pays for every token, fails offline and sends everything to a server. The interesting design work is the boundary.
3. Simple analogy#
A hospital with a local clinic. Most visits (sore throat, a prescription refill) are handled at the clinic on the spot: quick, nearby, private. Hard cases go to the hospital, with a referral letter that carries only what the specialist needs. The skill is in the triage nurse (the router): send too much to the hospital and it is slow and expensive; send too little and patients get the wrong care.
4. Tiny example: a smart reply feature#
"Suggest three short replies to this message"
device has an on-device model, 400-token prompt → on device: first token in ~0.1 s, free
device is a 4-year-old phone with no model → cloud
user asks "summarise this 40-page PDF" → cloud: on-device prefill of 30k tokens takes
seconds and may not fit the context
device is offline → on device, or "not available offline"
message contains a health record and the user → on device only; never send
opted out of cloud processingFive requests, three different answers to “where”, all from one feature.
5. Technical explanation#
Five hybrid patterns#
- Route by capability. Decide once per device (or per launch): if the on-device model exists and the device is in a supported tier, use it; otherwise the cloud. Simple and predictable. This is what most apps should start with.
- Route per request. Decide each time from the request and the device state: prompt length, task type, privacy class, network quality, battery and thermal state. Firebase’s hybrid API is rule-based routing of this kind; Google says more sophisticated routing is planned.
- Cascade from device to cloud. Answer on the device; escalate when the device model signals low confidence, fails a validator (malformed JSON, a tool call it cannot make) or the user asks again. This saves cloud cost but adds latency for the escalated requests (21.k).
- Split the pipeline. Run the privacy-sensitive or latency-critical stages on the device and the heavy reasoning in the cloud: on-device speech recognition and wake word, on-device embedding and retrieval over personal data, on-device redaction, then a cloud model sees only what it needs.
- Cloud with device-grade privacy. When the request must leave the device, make the server behave like an extension of it. Apple’s Private Cloud Compute is the reference design: stateless processing (no data retained after the response), enforceable guarantees in the software stack, no privileged runtime access for staff, requests not targetable at specific users, and published software images that security researchers can inspect (verifiable transparency).
What the router should look at#
| Signal | Why |
|---|---|
| On-device model availability and version | the model may be missing, downloading or a different version (Nano 2 vs 4) |
| Device tier (RAM, chip) | sets which model and context fit (29.a) |
| Prompt length and expected output length | long prompts favour the cloud’s prefill speed; long outputs cost the battery |
| Task type and required quality | world knowledge, complex reasoning and long documents go to the cloud |
| Privacy class of the data and user consent | some data must never leave; some users opt out of the cloud |
| Network: offline, metered, round-trip time | offline forces the device; a slow network shifts the crossover |
| Battery, power saving mode, thermal state | a hot or low phone should not run a long generation |
| OS quotas | AICore blocks background use and enforces per-app quotas (29.d) |
| Cost budget | cloud tokens per user per day |
Keep the router simple, deterministic and logged. A router that depends on a learned model is hard to debug; start with rules, record every decision with its inputs and the inference source, and only then learn better rules from the logs.
Making two models look like one product#
The device and cloud models are different models. Users notice:
- Shared prompt contract. Keep one task definition and output schema; use structured output
(Apple’s
@Generable, JSON schema in the cloud) so both sides return the same shape. - Evaluate both paths on the same set, and set a quality floor for the device path per task. If the device model is below the floor for a task, route that task to the cloud.
- Conversation hand-off. A KV cache cannot move between different models. When a conversation moves from device to cloud, the history is re-sent and re-read (a cloud prefill you pay for); keep histories short or summarised on the device.
- Version skew. The OS model updates with the OS; the cloud model updates when you deploy. Pin cloud model versions and regression-test against new OS betas (28.d).
Economics#
Every request served on the device is a request you do not pay for. For a feature with 10 million daily users and 20 requests per user per day, that is 200 million requests a day. At a few hundred dollars per million requests (section 6), moving most of them to the device saves tens of thousands of dollars a day. The costs move elsewhere: engineering for many device types, model downloads, the users’ batteries, and a quality gap you must manage.
6. Under the hood: where should one request run?#
This program compares one request on a phone and in the cloud. The phone’s speeds are Google’s published Gemma 4 E2B GPU figures on a Samsung S26 Ultra (29.d); network times, cloud speeds, phone power and prices are assumptions for illustration.
// route.go — on the phone or in the cloud? Time, energy and money for one request.
// Device speeds are Google's published Gemma 4 E2B GPU figures for a Samsung S26 Ultra;
// network, cloud speed, power and prices are assumptions to replace with your own.
package main
import "fmt"
type net struct {
name string
rttMs float64
up bool
}
func main() {
const (
devPrefill = 3808.0 // tok/s on the phone GPU
devDecode = 52.0 // tok/s
devWatts = 6.0 // assumed SoC power while generating
cloudTTFT = 0.35 // s, server queue + prefill for a short prompt (assumed)
cloudPre = 20000. // tok/s server prefill for long prompts (assumed)
cloudDec = 120.0 // tok/s streamed to the user (assumed)
inPrice = 0.10 // $ per million input tokens (assumed)
outPrice = 0.40 // $ per million output tokens (assumed)
answer = 200.0 // output tokens
)
nets := []net{{"wifi", 30, true}, {"mobile", 150, true}, {"offline", 0, false}}
fmt.Println(" ---------- phone ---------- ------------- cloud: first token / total -------------")
fmt.Println("prompt first total energy wifi mobile offline $ per 1M req")
for _, prompt := range []float64{300, 3000, 30000} {
devFirst := prompt / devPrefill
devTotal := devFirst + answer/devDecode
energy := devWatts * devTotal
line := fmt.Sprintf("%6.0f %5.2f s %5.1f s %5.0f J ", prompt, devFirst, devTotal, energy)
for _, n := range nets {
if !n.up {
line += " unavailable "
continue
}
first := n.rttMs/1000 + cloudTTFT + prompt/cloudPre
line += fmt.Sprintf(" %4.2f / %3.1f s", first, first+answer/cloudDec)
}
cost := prompt*inPrice + answer*outPrice // per million requests, since prices are per million tokens
line += fmt.Sprintf(" $%6.0f", cost)
fmt.Println(line)
}
}Output:
---------- phone ---------- ------------- cloud: first token / total -------------
prompt first total energy wifi mobile offline $ per 1M req
300 0.08 s 3.9 s 24 J 0.40 / 2.1 s 0.52 / 2.2 s unavailable $ 110
3000 0.79 s 4.6 s 28 J 0.53 / 2.2 s 0.65 / 2.3 s unavailable $ 380
30000 7.88 s 11.7 s 70 J 1.88 / 3.5 s 2.00 / 3.7 s unavailable $ 3080How to read it:
- Short prompts: the phone wins on first token (0.08 s against 0.4–0.5 s) and costs nothing. For smart replies, autocomplete and classification, where the first token or a short answer is the product, the device is the right place.
- Long answers: the cloud finishes first, because a server decodes faster than a phone’s memory bus allows. If the user reads as it streams, 52 tokens per second is already faster than reading; if a program waits for the whole answer, the cloud’s speed matters.
- Long prompts move the balance to the cloud: at 30,000 tokens the phone takes almost 8 s before the first token and spends three times the energy, while the cloud bill grows tenfold. This is where a split pipeline (retrieve on the device, send only the relevant passages) pays off.
- Offline removes the choice entirely, which is why “works offline” is a product decision to make explicitly, per feature.
7. Performance implications#
- Make the routing decision cheap. It runs before every request; checking model availability should be cached, not a system call each time.
- Warm the on-device model ahead of use (load it when the feature’s screen opens) or the first request pays seconds of loading, and the router’s latency estimate is wrong.
- Stream from both sides with the same client code, so the UI behaves the same wherever the tokens come from.
- Speculative hybrids (a device model drafting tokens for a cloud model to verify) are an active research direction, but every verification round costs a network round trip, which usually exceeds the time saved. Treat them as experiments, not a default.
- Escalation adds latency to exactly the hardest requests: a cascade that first tries the device for two seconds and then goes to the cloud is slower than going to the cloud directly. Escalate early on predictable signals (prompt length, task type) rather than late on failure.
8. Production implications#
- Classify data before you route. Define which data classes may go to the cloud, under which consent, and enforce it in the router, not in each feature (23.i).
- Log the inference source with every response, and the router’s inputs. Without it, quality complaints cannot be traced to a path.
- Monitor both paths separately: device latency by device class and OS model version, cloud latency and cost, escalation rate, and the share of requests on each side.
- Plan capacity for failover. If the on-device model is withdrawn by an OS update or a bug, all traffic moves to the cloud at once. Know what that costs and whether your cloud quota can take it (23.b).
- Kill switches per path. Be able to force a feature to cloud-only or device-only remotely.
- Be honest in the UI. Users should know when content leaves their device; Apple and Google both make the distinction visible for their own features.
9. Common mistakes#
- Routing on device capability only, ignoring prompt length; long-document features then feel slow on the device.
- Assuming the two paths give the same answers. They are different models; test both.
- Cascading late. Waiting for the device model to fail before escalating doubles the latency of hard requests.
- Sending raw personal data to the cloud when on-device retrieval or redaction could send far less.
- Not budgeting for full failover to the cloud.
- No inference-source logging, so incidents cannot be attributed.
10. Hands-on exercise#
- Run
route.go. Find the prompt length at which the cloud’s first token beats the phone’s on wifi. How does it move on the mobile network? - Change
answerto 20 tokens (a classification) and to 1,000 tokens (an essay). Which side wins each, on time, energy and money? - Add a “split pipeline” option: the phone reads 30,000 tokens of personal documents with an on-device embedding model at 2,000 tokens per second, then sends only 2,000 tokens to the cloud. Compare time, energy and cost with full cloud and full device.
- Write the routing rules for a mail app’s “summarise thread” feature as a table: inputs, decision, and what is logged. Include offline, low battery, a 200-message thread and a thread marked confidential.
- With Firebase AI Logic’s hybrid API (or your own wrapper), build a toy Android feature in
PREFER_ON_DEVICEmode and loginferenceSourcefor 100 requests on a supported and an unsupported device.
11. Interview questions#
- Give three reasons to run a request on the device and three to run it in the cloud.
- What signals should a hybrid router use, and why should it start rule-based?
- Why does a long prompt favour the cloud even though the device model is free?
- What are the design principles of Apple’s Private Cloud Compute, and what problem do they solve?
- Your on-device model is withdrawn overnight by an OS update. What happens to your system, and how should it have been designed?
12. Further reading#
Checked on 13 November 2026.
- Private Cloud Compute: a new frontier for AI privacy in the cloud (Apple Security Research)
- Introducing the third generation of Apple Foundation Models (8 June 2026)
- Hybrid inference and new AI models are coming to Android (Android Developers Blog, 17 April 2026)
- Firebase AI Logic: configuration options for hybrid experiences on Android
- ML Kit GenAI APIs: quotas and background limits
- What is Foundry Local? (Microsoft Learn)
- LiteRT-LM overview and benchmarks