---
title: "On-device versus Private Cloud Compute"
lesson_id: "04"
---

# On-device versus Private Cloud Compute

- **Lesson ID:** 04
- **Goal:** Stream and measure both SystemLanguageModel and PrivateCloudComputeLanguageModel. State availability and cache cost.
- **Human lesson:** [04-on-device-vs-pcc.html](04-on-device-vs-pcc.html)

## Prerequisites

- Lesson 03, or a working metrics struct.

## Inputs, outputs, and artifacts

- **Inputs:** Two session configurations.
- **Outputs:** Side-by-side TTFT and gap logs.
- **Artifacts:** Progressive `.flow` diagrams and a two-session sketch.

## Agent build steps

1. Show LanguageModelSession() and LanguageModelSession(model: PrivateCloudComputeLanguageModel()).
2. Require an availability check and a network fallback.
3. Mention the larger PCC context window and the cost of a profile switch on TTFT.
4. Link the prompt registry course.

## Constraints

Keep the language simple, friendly, and literal. iOS 27 and macOS 27 only. No quizzes, Mermaid, or em dashes. Do not invent API names. Mark sketches as sketches and tell the reader to confirm them in the Xcode 27 SDK.

## Key concepts

- The default session is on-device. Pass `PrivateCloudComputeLanguageModel()` for PCC.
- Check availability before you show the feature. Retry on-device if the network fails.
- PCC first token includes a round trip. The server model has a larger context.
- A profile switch can invalidate the KV cache and raise TTFT.

## Takeaways

- Never compare PCC total time to on-device TTFT.
- Use one log schema for both models with a model-used field.
- PCC buys quality or context at a first-token cost.

## Acceptance checks

- Both models are named.
- Availability and fallback are stated.
- KV cache / profile-switch cost is stated.
- Sibling links, progressive `.flow` diagrams, and an Agent brief link are present.
- [ ] Proceed to [lesson 05 brief](05-instruments-and-budget.llms.md).
