How flashml-org/freetoken works
FreeToken is an edge-native MoE inference and serving runtime. Its principal workflow accepts chat or completion requests, tokenizes and schedules them, executes model inference using KV/expert caching and specialized kernels, then streams generated text and tool-call data through compatible APIs. The repository also exposes an offline generation interface, multimodal input processing, cache and memory controls, and a separate daemon for managing serve-process lifecycle. The README documents runtime capabilities not visible in the sampled excerpts; those are represented at subsystem level, with uncertain internal wiring omitted.
Main entry points: engine.py Inference engine · models Model architectures · serve_manager.py Serve lifecycle · scheduler.py Request scheduler
Components 20
Serving and control
- HTTP API
python/freetoken/server/api_server.py - Generation
python/freetoken/server/generation.py
Request generation
- Tokenizer service
python/freetoken/tokenizer/server.py - Request scheduler
python/freetoken/scheduler/scheduler.py - Offline LLM
python/freetoken/llm/llm.py - Multimodal processing
python/freetoken/mm/processor.py
Model inference
- Model loading
python/freetoken/models/loader.py - Model architectures
python/freetoken/models - Model layers
python/freetoken/layers - Attention backends
python/freetoken/attention - MoE execution
python/freetoken/moe - Inference engine
python/freetoken/engine/engine.py
Memory and kernels
- KV cache
python/freetoken/kvcache - Accelerator kernels
python/freetoken/kernel - Cache reporting
python/freetoken/cache_report.py
Daemon management
- Daemon control API
python/freetoken/daemon/app.py - Serve lifecycle
python/freetoken/daemon/serve_manager.py - Daemon state
python/freetoken/daemon/pidfile.py
Other components
- API client
- Serve process
Connections 21
- API client → HTTP API: sends requests
- HTTP API → Generation: dispatches generation
- Generation → Tokenizer service: forwards messages
- Tokenizer service → Request scheduler: sends backend messages
- Request scheduler → Inference engine: schedules inference
- Inference engine → Model loading: loads model
- Inference engine → Model architectures: runs forward pass
- Model architectures → Model layers: uses layers
- Model architectures → Attention backends: uses attention
- Model architectures → MoE execution: executes experts
- Inference engine → KV cache: manages cache
- Attention backends → KV cache: stores and reads KV
- MoE execution → Accelerator kernels: uses kernels
- Inference engine → Accelerator kernels: executes kernels
- Inference engine → Multimodal processing: encodes media
- Offline LLM → Request scheduler: runs generation
- API client → Daemon control API: controls engine
- Daemon control API → Serve lifecycle: manages lifecycle
- Serve lifecycle → Daemon state: persists state
- Serve lifecycle → Serve process: launches and monitors
- API client → Cache reporting: requests cache status