Transformers serve refactor: API server split into its own process for speed

LysandreJik · x · 2026-11-28

Hugging Face's transformers team merged PR #50927, refactoring the serve API server so it no longer bottlenecks the model loop. Tested on H100 and an M2 MacBook. Key changes: the API server now runs in its own process beside the model; tokenization moved to a separate thread off the event loop; streamed events are generated from a template; one message per step instead of per token; and --api-server-count allows multiple API servers (single-model only for now). Previously the HTTP server and GPU loop shared a process and blocked each other. The team says a Rust API server is the fallback if it ever becomes the bottleneck again, and faster generation overall is next.

Original post →

More from coding & agent

coding & agent channel →