Originally published on Medium: https://medium.com/@dqj1998/desktop-apps-keep-wiring-a-7b-model-into-every-control-path-115063626c2f
Desktop apps keep wiring a 7B model into every control path. Here is the physics β and the 10% AI / 90% deterministic code architecture that survives production.
Every new desktop app pitch this year ships the same diagram: a small language model in the center, arrows fanning out to every feature β parsing, planning, formatting, error recovery β all routed through the same few billion parameters. It demos beautifully. It ships badly.
This is the first article in a six-part series on 10% AI, 90% deterministic code: how to use on-device models hard, but held small. No product tour, no trend forecast β just the engineering constraints that force the architecture, and the architecture that survives contact with real users.
The first thing to internalize: token throughput on the edge is a memory-bandwidth problem, not a model-quality problem.
Every decoded token streams the active weights (plus the KV cache) from memory once. The back-of-envelope:
theoretical tok/s β memory bandwidth (GB/s) Γ· active weights (GB)
A 7B model at 4-bit quantization is roughly 4 GB of active weights. Back-of-envelope numbers, measured against hardware classes rather than lab queens:
| Hardware class | Bandwidth | Theoretical | Realistic sustained |
|---|---|---|---|
| Thin laptop, shared LPDDR | 68β100 GB/s | 17β25 tok/s | 8β14 tok/s while the UI composites |
| Mid-tier unified memory | 200β400 GB/s | 50β100 tok/s | 30β60 tok/s |
| 12 GB discrete GPU | 270β500 GB/s | 65β125 tok/s | 45β90 tok/s |
Three multipliers turn those numbers into a wall:
Meanwhile, direct manipulation UI has a hard budget: under ~100 ms feels instant, under ~1 s keeps flow, beyond that users reach for the window close button. A model call lives at 500 ms to 5 s. That is not a gap you close with prompt engineering. It is a gap you design around: the model cannot sit inside the interaction loop, and it certainly cannot sit inside the control loop.
The fix is not "use the model less." It is to decide, before writing code, which tasks carry a specification β and give every spec-bearing task to deterministic code.
Tasks that must be owned by code, because a spec exists and a machine can check compliance:
Tasks where the model earns its 10%, because no spec exists and variance is acceptable:
The boundary as code:
// Spec-bearing stages stay deterministic: pure, testable.
interface DeterministicStage<I, O> {
name: string;
run(input: I): Result<O, SpecError>;
}
// The model appears only as a leaf, with four mandatory fields.
interface AiOperator<I, O> {
name: string;
buildPrompt(input: I): string; // built by code
parse(raw: string): Result<O, ParseError>; // schema-checked
fallback(input: I): O; // rules, not retries
budget: { timeoutMs: number; maxTokens: number };
}
// A pipeline is a graph; AI operators are leaves, never hubs.
type Stage = DeterministicStage<any, any> | AiOperator<any, any>;
Note the two non-negotiables: parse (the model's output is untrusted input, validated like any other external payload) and fallback (failure resolves to a deterministic result, never to a retry loop).
The alternative to a deterministic pipeline with AI leaves is the end-to-end agent: one model, one context window, all control flow. Both ship. Only one is maintainable:
| Property | End-to-end agent | Deterministic pipeline + AI leaves |
|---|---|---|
| Testability | Prompt-dependent; tests flake with temperature | 90% of the graph has golden tests |
| Fault isolation | Any token can break any feature | Failure confined to one leaf with a fallback |
| Latency variance | Seconds, effectively unbounded | Bounded by per-leaf budgets |
| Reproducibility | Same input, different output | Byte-identical except at AI leaves |
| Debugging | Re-read the transcript, guess | Binary-search the graph |
Data flow through the pipeline looks like this β note that the model sits beside the main path, not on it:
ββββββββββββββββββββββββββββββββββββββββββββββββ
.pptx file βββΆ β parse container (deterministic) β
β build slide tree (deterministic) β
β extract text/tables/notes (deterministic) β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β structured summary (typed)
βββββββββββββββββΌβββββββββββββββββββββββββββββββ
β local AI operator β
β prompt built by code βββΆ model βββΆ schema β
β on timeout/error βββΆ deterministic fallback β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β polished notes (untrusted,
β schema-checked)
βββββββββββββββββΌβββββββββββββββββββββββββββββββ
β align timeline (arithmetic) β
β render / encode (deterministic) β
β package output (deterministic) β
βββββββββββββββββ¬βββββββββββββββββββββββββββββββ
βΌ
output artifact
If any box on the main path fails, you get a reproducible bug report. If the AI leaf fails, you get the fallback output and a log line. Nothing upstream stops, nothing downstream corrupts state.
Boundaries enforced only by convention decay. Make the pipeline data, and the boundary becomes reviewable in a diff:
{
"pipeline": "document-pipeline",
"stages": [
{ "type": "deterministic", "id": "parse-container" },
{ "type": "deterministic", "id": "build-structure" },
{
"type": "ai",
"id": "polish-speaker-notes",
"input": "structured-slide-summary",
"constraints": {
"timeoutMs": 3000,
"maxTokens": 420,
"temperature": 0.2
},
"onFailure": "use-extracted-text"
},
{ "type": "deterministic", "id": "align-timeline" },
{ "type": "deterministic", "id": "render-and-mux" }
]
}
Three numbers do most of the work. timeoutMs: 3000 converts a hung model into a fallback. maxTokens: 420 caps worst-case decode time at that bandwidth math from the first section. temperature: 0.2 keeps retries from wandering. The deterministic stages carry no budgets at all β they either return or they throw a reproducible error.
Teams that wire the model into every path meet the same five failures, in roughly this order:
None of these are model-quality problems. Bigger models make them rarer, not absent. They are boundary problems.
Before any task gets routed to the model, ask four questions:
The rule of thumb: the model gets ~10% of the code paths and 100% of the ambiguity. It shines exactly where a spec is missing β and nowhere else.
That was the philosophy. The next five articles get progressively more concrete: how to constrain a small model's output so the parse step never fails (grammar-constrained decoding and context minimalism); how to package an inference runtime so it degrades gracefully on a five-year-old laptop; then three articles on a concrete target β reading real documents, synthesizing speech, and assembling the whole pipeline into a video β before the final piece shows the system it all adds up to.
If you have shipped local-LLM features that regressed exactly this way, you already know why the boundary comes first.
The author is a systems engineer building local-first desktop software. This series is Part 1 of 6.