TT Lab
Blog

한국어 English 日本語 中文

Get started
Blog

Blog

Batching and Latency: Batch Size, Concurrent Sessions, and GPU Sharing

Status: Draft (2026-10-16), partially measured. Latency per batch was measured as one-off pods on a single home lab 8GB laptop GPU (no other GPU jobs, median of repeats after warm-up). Session simulation is based on laptop CPU calculations inserting that table (code/06_batching_sim.py, around 1 second). Actual concurrent session values for workers cited load test data from the TT Score performance documentation (server GPU, at a time when cards were shared with other jobs). Part 6 of the "Reading Vision Models 3" series. The distinction between latency and throughput is in Part 1.

Table of Contents

1. Intuition: Buses and Taxis

A GPU is like a bus with thousands of computational units. If it departs with just one passenger (input), most seats remain empty; if it waits to gather several passengers, it carries many at once. However, earlier passengers have to wait while others are being collected. Batching is a trade-off where you spend latency to gain throughput. Moreover, if the bus is already full (meaning a model whose single input fully utilizes all compute units), gathering more brings no benefit.

배치를 늘리면 처리량이 늘까 — 공 모델 실측 ① 512×288: 초당 처리한 창(높을수록 좋음) 0 25 50 75 100 1 4 8 12 16 배치 크기 FP16 102 72 FP32 66 44 ② 256×144: 창 하나에 드는 시간(낮을수록 좋음) FP32 배치 1 4.07ms FP32 배치 4 3.85ms FP16 배치 1 4.69ms FP16 배치 4 2.32ms 작은 입력은 GPU 가 놀아서 묶으면 이득, 큰 입력은 손해
Figure: Execution time per run and number of windows processed per second when varying batch size — for 512x288 input, throughput decreases even as batch size increases, whereas for 256x144, it increases.

2. Server-Side Research: Batching within Latency Targets

Combining these three yields a principle: A latency budget is established first, and batch size is only increased within that budget. Furthermore, how much of a gain it provides must be measured on that specific model and GPU.

3. Direct Measurement: Does Batching Make the Ball Model Faster?

We measured TT Score's ball model (BlurBall, 3-frame window, 1.49M parameters) on an experimental GPU by varying only the batch size (512x288, median of 3 batches of 30 runs after 10 warm-up runs, cuDNN auto-tuner enabled).

Batch FP16 Single Run FP16 Windows/sec FP32 Single Run FP32 Windows/sec
1 9.82ms 101.8 15.11ms 66.2
2 20.36ms 98.2 34.21ms 58.5
3 32.71ms 91.7 57.10ms 52.5
4 46.15ms 86.7 79.69ms 50.2
8 103.77ms 77.1 178.09ms 44.9
16 221.25ms 72.3 366.10ms 43.7

Throughput decreased as batching increased. Because Batch 1 was already fully utilizing this GPU, batching only enlarged intermediate tensors (since the model maintains 512x288 resolution throughout, a single FP32 feature map is tens of megabytes), which likely caused cache overflow (probable cause). It is not because the GPU heated up and slowed down from prolonged running; measuring Batch 1 again after running the heaviest workload (1024x576 batch 4) for a few minutes yielded the same initial value (9.77 vs 9.82ms).

Reducing the input to 256x144 reverses this result.

256×144 Batch 1 Batch 4 Per Window (Batch 4)
FP32 4.07ms 15.40ms 3.85ms (0.95x)
FP16 4.69ms 9.29ms 2.32ms (0.49x)

Because a single small input leaves the GPU underutilized, batching four together cut the inference time in half in FP16. Even for the same model, the pros and cons of batching reverse depending on the input size and the GPU. When measured on a server GPU (24GB class) with the same model on 2026-10-12, a batch size of 3 yielded a slight benefit, taking 0.83x the inference time (FP16 8.0ms → batch size 3 20.0ms) (TT Score Performance Document 2.9.8).

4. When Multiple Sessions Share One GPU

A real-time worker receives "sessions" instead of "requests." Frames arrive at 30fps per session, and the worker holds only the newest frame for each session (the "latest-only" policy from Part 1). When the GPU is free, the TT Score worker's approach is to batch together the latest windows of all waiting sessions. We simulated this by session count using the empirical tables above (GPU share only, 30 seconds).

Session One by one (oldest frame first) Batched (all waiting sessions)
Laptop GPU empirical table, session 3 30.0fps per session, median latency 9.8ms Same
Laptop GPU, session 4 Average 25.5fps (slowest session 18.6), median 37.0 · p99 43.0ms All 21.7fps, median 62.7 · p99 79.1ms
Laptop GPU, session 6 Average 17.0fps (slowest session 2.5), median 39.3ms All 13.5fps, median 91.4ms
Server GPU table, session 5 Average 25.0fps (slowest session 5.1), median 36.0ms All 30.0fps, median 27.4 · p99 40.0ms
Server GPU, session 6 Average 20.8fps (slowest session 3.4) All 26.3fps, median 54.7ms

(code/06_batching_sim.out.txt. (Since the server GPU table only has two data points, batch sizes of 4 and above are assumed to scale linearly.)

Here is how to read this.

An actual load test of the worker (server GPU, sharing cards with other workloads on 2026-10-11) showed the same pattern. A single session achieved 29.4fps with a round-trip p99 of 32ms; three sessions yielded 16–20fps per session with a round-trip median of 70–95ms, and 21–30% of sent frames were dropped being overwritten by newer frames (Performance Document 4.2).

5. Methods for Sharing a GPU

There are three ways for multiple workloads to share a single GPU (NVIDIA GPU Operator and Device Plugin documentation).

Method How it partitions Memory isolation Error isolation
Time-slicing Alternating usage. Only makes resources "appear" divided None None
MPS Simultaneous, with caps on memory and compute share per client Caps exist Could not verify in documentation
MIG (Supported GPUs only) Hardware-partitioned instances, each with its own memory Yes Yes

Time-slicing may seem free, but if another workload on the same card is busy, your latency increases directly. This appears to be what Clockwork meant by "concurrent execution enlarges the tail" in production. In TT Score's actual measurements, a single inference of the ball model took 10.5ms when the card was idle, but 34ms when running alongside 2–3 other tasks (Performance Document 2.9.8). Real-time latency is determined more by "who else is sharing the card" than by the model itself.

6. Limitations

7. Connection to Our Project

The next post shifts focus from servers to on-device execution on phones.

A word from TT. If a bus is already full, letting more people on just delays closing the doors. My ball model was exactly like that—the more we batched, the slower it got!

References

Sign in to like

Comments

No comments yet.

Sign in to leave a comment