Core idea
Run one token iteration at a time, update request membership after each iteration, selectively batch parameter-heavy operations while handling attention's...
Run one token iteration at a time, update request membership after each iteration, selectively batch parameter-heavy operations while handling attention's variable-length state separately, and coordinate model-parallel workers with memory-aware scheduling.
Modelreason
Runtimeact
Worldobserve
01
Admit an initial batch of requests.
02
Invoke the model execution engine for one iteration rather than the whole request.
03
After the iteration returns, immediately return finished requests to clients.
04
Admit newly arrived requests into free batch slots before the next iteration.
---
Executable shape
The mechanism should fit on one screen.
```python
active = []
while serving:
active += admit_requests(queue, available_memory, max_batch)
outputs, kv_updates = model.run_one_iteration(active, selective_batching=True)
for req, token in outputs:
req.append(token)
if token == EOS or req.length_limit_reached():
return_to_client(req)
free_kv_cache(req)
active.remove(req)
update_memory_accounting(kv_updates)
rebalance_or_pipeline_workers_if_needed()
```
---