Hybrid Edge-Cloud Inference › Partitioning: splitting one inference pass

Michael BrenndoerferDecember 1, 20264 min read
Language AI HandbookAll chapters
Part 43 of 67Small and On-Device Language Models
Chapter 330Hybrid Edge-Cloud Inference › Partitioning: splitting one inference pass
Reading section 5 of 13 · Partitioning: splitting one inference pass · 4 minSection 5 of 13 · 4 min

Section 5 of 13 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Routing keeps inference for a request on one side. Partitioning divides the work across endpoints. Some systems move a stage such as prefill. Others exchange intermediate results during generation. The latency ledger depends on the payload size, how often the exchange occurs, and whether compute can overlap it.

Layer-level partitioning (pipeline split)

In a two-endpoint layer split, layers 1…k1 \ldots k run on the device and layers k+1…Lk+1 \ldots L run on the server. The edge sends the boundary activation. When each endpoint retains state for its assigned layers, it keeps those layers’ key-value cache on that endpoint across steps. If the device starts the next decoding step, it also needs the selected token from the server. EdgeShard is a concrete system for choosing layer placement under device and network constraints.

  • Serial exchanges. If each new token waits for one preceding round trip, a 100 ms round trip limits the schedule to at most 10 tokens/s even before compute. Link bandwidth and transfer size can reduce throughput further.
  • Activation size. A hidden state of 4,096 bf16 values uses 8,192 bytes (8 KiB). Sending that payload at 10 Mbit/s takes about 6.55 ms of serialization before protocol overhead.
  • Recovery. A transient error can delay or interrupt a step. A retry must resume from a common prefix and associated cache state or restart. Test the resume policy and its failure behavior.

Choose a placement by measuring per-layer compute, memory and transfer on the target devices and links. Evaluate prefill and single-request decode separately when the interaction needs a fast first token.

Speculative edge-cloud decoding

Speculative decoding can be partitioned so the device drafts tokens and the cloud scores them. The draft model proposes kk tokens, and the target model evaluates the draft prefixes in one parallel verification pass. The sampler accepts a prefix under the target-preserving rule and, on rejection, draws a correction token from the residual distribution. If every proposal is accepted, it can draw an additional token from the target.

One verification round can produce several output tokens. A sequential edge-cloud protocol pays a network round trip each round. When the very first proposal is rejected, the round emits the correction token without accepting any draft token.

The Python example below simulates request routing and offline fallback. For speculative decoding, the location of the sampler is a protocol decision. The same target distribution can be preserved on either side when the sampler uses the matching proposal and target distributions, the correct residual distribution on rejection, and a consistent prefix.

Bind each verifier response to the request, the committed prefix and the proposal it scored. Comparing an echoed accepted prefix with the device’s draft checks that they refer to the same proposed tokens. The serving path still needs an authenticated peer and a way to check or trust that it applied the correct target model and acceptance rule.

Retrieval and prefill partitioning

Local retrieval can select which approved snippets to send with a cloud request. If the application needs the full private collection for search, the index can stay on the device. The excerpts and any identifying metadata that leave the device still need transfer approval.

In another split, a prefill worker computes key-value (KV) state and a compatible decoder consumes it. DistServe studies this stage split in a serving cluster. A device-cloud variant needs compatible weights, tokenization, positions, cache layout and precision. Compare the bytes it would send with the original prompt representation. For example, an uncompressed bf16 cache for 1,024 tokens, 32 layers, eight KV heads per layer and head width 128 uses 2×32×1024×8×128×22\times 32\times 1024\times 8\times 128\times 2 bytes (128 MiB). The two factors of 2 count key/value and bytes per scalar. The same 1,024 token IDs at four bytes each use 4 KiB. Savings from avoiding remote prefill must cover any KV transfer and compatibility costs. Cache reuse can change that tradeoff.

The choice of cut determines how often the two sides exchange data: an autoregressive layer split can require an exchange per output token, whereas a speculative protocol can amortize that exchange across output tokens when enough proposals are accepted.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy