An OpenAI-compatible API server that integrates flashtensors with vLLM for ultra-fast LLM model loading and switching. Models are converted once into flashtensors' optimized binary format, then loaded from local storage in seconds instead of minutes.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Docker Container (vllm/vllm-openai:v0.10.2) β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββ β
β β FastAPI Server (entrypoint.py, port 8000) β β
β β β β
β β OpenAI-Compatible Endpoints β β
β β /v1/chat/completions β β
β β /v1/completions β β
β β /v1/models β β
β β β β
β β FlashTensors Management Endpoints β β
β β /v1/flashtensors/register/{model_id} β β
β β /v1/flashtensors/load/{model_id} β β
β β /v1/flashtensors/unload β β
β β /v1/flashtensors/models β β
β β /v1/flashtensors/status β β
β βββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β flashtensors β β
β β - Converts HF models to optimized format β β
β β - Patches vLLM model loader β β
β β - 20GB memory pool, 32MB chunk I/O β β
β βββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β vLLM (v0.10.2, V0 engine) β β
β β - Inference engine β β
β β - SamplingParams, LLM interface β β
β βββββββββββββ¬ββββββββββββββββββββββββββββββββββββ β
β β β
β βββββββββββββΌββββββββββββββββββββββββββββββββββββ β
β β GPU (NVIDIA, e.g. L4 24GB) β β
β β - 80% VRAM utilization β β
β β - Single GPU (tensor_parallel_size=1) β β
β βββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Volumes:
./models:/models β Persistent flashtensors model storage
/dev/shm:/dev/shm β Shared memory for fast I/O
~/.cache/huggingface:/root/β¦ β HuggingFace download cache
- Docker with NVIDIA Container Toolkit
- NVIDIA GPU with CUDA support (tested on L4 24GB)
- Sufficient disk space for model storage
docker compose up -d --buildcurl -X POST http://localhost:8000/v1/flashtensors/register/Qwen/Qwen3-4Bcurl -X POST http://localhost:8000/v1/flashtensors/load/Qwen/Qwen3-4Bcurl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-4B",
"messages": [{"role": "user", "content": "Hello!"}],
"max_tokens": 256
}'The model is auto-loaded on first request if not already loaded.
Chat completion. Supports streaming via "stream": true. Supports multimodal (vision) inputs for VL models.
| Parameter | Type | Default | Description |
|---|---|---|---|
| model | string | required | Model ID (must be registered) |
| messages | array | required | Chat messages (role + content) |
| temperature | float | 0.7 | Sampling temperature |
| top_p | float | 1.0 | Nucleus sampling |
| max_tokens | int | 512 | Max tokens to generate |
| stream | bool | false | Stream response via SSE |
| stop | string/array | null | Stop sequences |
| n | int | 1 | Number of completions |
| presence_penalty | float | 0.0 | Presence penalty |
| frequency_penalty | float | 0.0 | Frequency penalty |
Vision model example (Qwen3-VL):
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen/Qwen3-VL-7B",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}'Images can also be passed as base64 data URIs: data:image/jpeg;base64,...
OpenAI-compatible chat completions endpoint
List all registered models.
Get info about a specific model.
Register a model: download from HuggingFace and convert to flashtensors format. Query parameter ?force=true to re-register.
Pre-load a model into GPU memory.
Unload the current model and free GPU memory.
List registered models and current loaded model.
Get detailed info about a registered model.
Server status including current model and registered models.
GET /health or GET /v1/health -- returns {"status": "healthy"}.
Set in docker-compose.yml:
| Variable | Default | Description |
|---|---|---|
CUDA_VISIBLE_DEVICES |
0 |
GPU device index |
VLLM_USE_V1 |
0 |
Must be 0 for flashtensors compatibility |
VLLM_MAX_MODEL_LEN |
4096 |
Max context window (reduce for larger models) |
VLLM_WORKER_MULTIPROC_METHOD |
spawn |
Process spawning method |
HF_TOKEN |
(unset) | HuggingFace token for gated/private models |
| Parameter | Value | Description |
|---|---|---|
storage_path |
/models |
Where optimized models are stored |
mem_pool_size |
20 GB | Memory pool size (L4 has 24GB) |
chunk_size |
32 MB | I/O chunk size |
gpu_memory_utilization |
0.80 | Fraction of GPU VRAM to use |
Register (one-time) Load (seconds) Inference
βββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
β HuggingFace β βββββββΊ β flashtensors β βββββββΊ β vLLM Engine β
β Download β convert β /models/ (disk) β load β (GPU VRAM) β
β (minutes) β β β β β
βββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
Persistent storage Ready for API
Model switching: To switch to a different (already registered) model, simply send a request with a different model parameter. The server unloads the current model and loads the new one automatically.
The Dockerfile applies several patches to flashtensors for compatibility:
- Python 3.12 support -- flashtensors' CMake config only lists 3.8--3.11; patched to include 3.12.
- Process group destruction --
dist.destroy_process_group()inflashtensors/api.pyis replaced withpass. Without this patch, vLLM cannot reload models after the first unload. - Supervisord config --
%(ENV_USER)schanged toroot,pythonchanged topython3.
- Streaming is batch-mode: The streaming endpoints (
stream: true) use vLLM's synchronousgenerate(), which returns all tokens at once. Responses are sent as SSE but not truly token-by-token. True streaming requires vLLM'sAsyncLLMEngine. - Single model at a time: Only one model can be loaded in GPU memory. Switching models requires unloading the current one.
- Single GPU: Configured for
tensor_parallel_size=1. Multi-GPU requires adjusting this value and related configuration. - No authentication: The API has no auth. Secure it via network controls or a reverse proxy if exposed beyond localhost.
- vLLM V0 engine required: Uses
VLLM_USE_V1=0to force the legacy engine, which flashtensors requires.
flashtensors/
βββ entrypoint.py # FastAPI server with flashtensors + vLLM integration
βββ Dockerfile # Container build with patches for compatibility
βββ docker-compose.yml # Orchestration with GPU, volumes, health checks
βββ models/ # Persistent storage for converted models (created at runtime)
This project is built on top of flashtensors -- a high-performance tensor serialization library that makes near-instant model loading possible. Great work on making LLM deployment significantly faster.