Hybrid Edge-Cloud Inference › Latency accounting
Language AI HandbookAll chapters 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:
where:
- : time for the on-device privacy gate to classify the request
- : time for the router to compute features and the difficulty score on device
- : indicator equal to 1 for the direct cloud path and 0 for the direct edge path
- : time to upload the prompt to the cloud
- : time waiting in the cloud serving queue
- : cloud prompt-prefill compute time
- : number of generated (decode) tokens
- : per-token cloud decode time, so is total cloud decode time
- : time to download the completion to the device
Here 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:
where:
- : compute time on the device in step
- : number of decode steps, each requiring an exchange between device and server
- : serial network delay and transfer time for the activation exchange in step
- : compute time on the server in step
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:
where:
- : number of verify rounds, i.e., batches of draft tokens sent for verification
- : network round trip for one draft-to-verify exchange
- : total time for the cloud target model to score the drafted tokens across all rounds
- : total time for the edge draft model to propose tokens across all rounds
For a run of output tokens, is the first round by which the cumulative number of emitted tokens reaches . Over a long run with a stable average of emitted tokens per round, . For a draft of proposals, a rejection at the first proposal emits one correction token. If all proposals are accepted, the round can emit 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!