Hybrid Edge-Cloud Inference › Latency accounting

Michael BrenndoerferDecember 1, 20264 min read
Language AI HandbookAll chapters
Part 43 of 67Small and On-Device Language Models
Chapter 330Hybrid Edge-Cloud Inference › Latency accounting
Reading section 7 of 13 · Latency accounting · 4 minSection 7 of 13 · 4 min

Section 7 of 13 · 4 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

Latency in hybrid systems is deceiving because the slowest component is often the one you did not measure. We decompose end-to-end latency into additive terms and track each separately.

The discipline is to attribute every millisecond to exactly one term, so that when latency regresses you can identify the responsible component rather than guessing.

For routing:

Troute=Tgate+Trouter+(1−I)Tlocal+I (Tup+Tqueue+Tprefill+N⋅Tdecode+Tdown).\begin{aligned} T_{\text{route}} = {} & T_{\text{gate}} + T_{\text{router}} + (1-I)T_{\text{local}} \\ & + I\,(T_{\text{up}} + T_{\text{queue}} + T_{\text{prefill}} + N\cdot T_{\text{decode}} + T_{\text{down}}). \end{aligned}

where:

  • TgateT_{\text{gate}}: time for the on-device privacy gate to classify the request
  • TrouterT_{\text{router}}: time for the router to compute features and the difficulty score on device
  • II: indicator equal to 1 for the direct cloud path and 0 for the direct edge path
  • TupT_{\text{up}}: time to upload the prompt to the cloud
  • TqueueT_{\text{queue}}: time waiting in the cloud serving queue
  • TprefillT_{\text{prefill}}: cloud prompt-prefill compute time
  • NN: number of generated (decode) tokens
  • TdecodeT_{\text{decode}}: per-token cloud decode time, so N⋅TdecodeN\cdot T_{\text{decode}} is total cloud decode time
  • TdownT_{\text{down}}: time to download the completion to the device

Here TlocalT_{\text{local}} is on-device inference time. These are direct-path totals. If a cloud attempt times out before the device runs the edge model, include time spent on that attempt as well as local inference.

For a short cloud request, fixed network and queue time can be a large part of the total. For longer requests, prefill or decode can take a larger share. Measure their contributions separately and stratify the results by request length and service load. Record the gate and scoring costs on edge as well.

This is why the same routing policy can be latency-optimal for short requests and latency-pessimal for long ones, and why the router's cost estimates must be functions of request length rather than constants.

For a serialized two-endpoint layer split, count one exchange per decode step. The following ledger starts after prefill:

Tpart,decode=∑i=1N(Tlocal-layers,i+Texchange,i+Tremote-layers,i).T_{\text{part,decode}} = \sum_{i=1}^{N}\big(T_{\text{local-layers},i} + T_{\text{exchange},i} + T_{\text{remote-layers},i}\big).

where:

  • Tlocal-layers,iT_{\text{local-layers},i}: compute time on the device in step ii
  • NN: number of decode steps, each requiring an exchange between device and server
  • Texchange,iT_{\text{exchange},i}: serial network delay and transfer time for the activation exchange in step ii
  • Tremote-layers,iT_{\text{remote-layers},i}: compute time on the server in step ii

With comparable exchange times, the network term grows in proportion to the number of steps in this schedule. To compare with an all-edge run of the same model, measure how much faster the relocated layers run on the server. Their compute-time saving must cover the exchanges and any other costs the split adds.

For a sequential speculative protocol with one exchange per verification round, the network term appears once per round:

Tspec=B⋅Troundtrip+Tcloud-verify+Tedge-draftT_{\text{spec}} = B\cdot T_{\text{roundtrip}} + T_{\text{cloud-verify}} + T_{\text{edge-draft}}

where:

  • BB: number of verify rounds, i.e., batches of draft tokens sent for verification
  • TroundtripT_{\text{roundtrip}}: network round trip for one draft-to-verify exchange
  • Tcloud-verifyT_{\text{cloud-verify}}: total time for the cloud target model to score the drafted tokens across all rounds
  • Tedge-draftT_{\text{edge-draft}}: total time for the edge draft model to propose tokens across all rounds

For a run of NN output tokens, BB is the first round by which the cumulative number of emitted tokens reaches NN. Over a long run with a stable average of eˉ\bar e emitted tokens per round, B≈N/eˉB \approx N/\bar e. For a draft of kk proposals, a rejection at the first proposal emits one correction token. If all kk proposals are accepted, the round can emit k+1k+1 tokens with the additional target draw. A stop token or the output limit can shorten the final round. Compare the resulting exchanges, verify time and draft time on the links the service will use.

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