Configuration
LayerScale is configured entirely on the command line. There is no configuration file. In the Docker image, everything after the image name is passed to the engine; the default is serve 0.0.0.0:8080 --model /models.
layerscale [options] serve [ADDR]layerscale [options] generate <REQUEST>layerscale [options] cli-interactivelayerscale [options] video --prompt <TEXT> --out <PATH>layerscale [options] image --prompt <TEXT> --out <PATH>--help prints the same reference. Flags may come before or after the command.
Commands
| Command | What it does |
|---|---|
serve [ADDR] |
Start the HTTP API on ADDR. Default 127.0.0.1:8080. Use 0.0.0.0:8080 inside a container. |
generate <REQUEST> |
Run one chat completion and print it. REQUEST is the JSON body of /v1/chat/completions (messages, temperature, max_tokens and so on). |
cli-interactive |
Chat with the model at a prompt. /max and /temp set sampling; /help lists the commands. |
video --prompt <TEXT> --out <PATH> |
Generate one video clip with its sound from a prompt (see Video and image generation). Writes PATH, whose extension picks the format: .mp4 (H.264 and AAC, the default) or .y4m (raw frames, with a .wav beside them). --size WxH, --seconds and --steps (each the model’s own by default) and --seed (0) shape it. |
image --prompt <TEXT> --out <PATH> |
Make one still picture from a prompt with a video generation model (see A picture). Writes PATH, whose extension picks the format: .png (the default) or .jpg. --size, --steps and --seed shape it, as for video. |
Every command needs --model.
Options
The flags use the names common among inference servers (--kv-cache-dtype, --device, --gpu-memory-utilization), so an existing launcher carries over with few changes.
| Flag | Default | Meaning |
|---|---|---|
--license-key <KEY> |
LAYERSCALE_LICENSE_KEY |
A Pro license key (LSK-...), as the flag or the environment variable: needed for more than one GPU and for the Dynamo worker. |
--api-key <KEY> |
LAYERSCALE_API_KEY, else off |
Require KEY as the API bearer token (Authorization: Bearer <KEY> or x-api-key: <KEY>) on every route except /health, /healthz and OPTIONS, as the flag or the environment variable, which keeps it off the process list. A key of your own: a license key is refused. Without one the API is open to anyone who can reach the address. |
--model <DIR|ORG/NAME> |
none, required | Model directory with config.json, tokenizer.json (or tekken.json) and either model.safetensors or model.safetensors.index.json plus its shards, or a Hugging Face repo id, loaded from the local Hugging Face cache (HF_HUB_CACHE, $HF_HOME/hub, ~/.cache/huggingface/hub) and downloaded into it first when it is not there. A gated repo needs HF_TOKEN; see Models. |
--ctx <N> |
the model’s max_position_embeddings, clamped to what the KV pool holds for one sequence |
Context length in tokens per sequence. The clamp is logged as ctx_defaulted. |
--max-num-seqs <N> |
128, or fewer when the memory left after the weights cannot back each sequence with its recurrent state and 1024 tokens of KV; 4 on the CPU | Maximum sequences batched together, at most 1024: a larger value is clamped. |
--gpu-memory-utilization <F> |
0.92 on CUDA, 0.9 otherwise |
Fraction of each GPU’s total memory for weights plus KV cache. The denominator is the card’s total memory, not what is free when the engine starts. |
--max-total-tokens <N> |
derived from the memory budget | Exact KV pool size in tokens across all sequences, overriding --gpu-memory-utilization. A smaller pool saves memory and may preempt sequences. |
--chunked-prefill-size <N> |
2048, 8192 on Qwen3.8-Flash-Next |
The most of one prompt prefilled in one step. Larger prefills a long prompt faster and makes decode wait longer behind it. |
--kv-cache-dtype <T> |
auto |
auto, bf16, fp8 or nvfp4 (datacenter Blackwell). auto follows the checkpoint. An fp8 cache halves the pool, so the same card holds twice the context. See Models. |
--device <NAME> |
the GPU the build has | auto, cpu, cuda, rocm or metal (the Metal build knows auto, cpu and metal). Asking for a backend the build lacks is an error, not a fallback. |
--tp <N> |
every GPU the host shows | Split one copy of the model across GPUs 0..N-1. 1 disables tensor parallelism. Above 1 needs a Pro license. See Models. |
--nnodes <N> |
1 |
Serve one model across N machines, one server process a node. --tp counts the GPUs of every node; without --tp, every GPU the host shows times N. CUDA. See Multi-node. |
--node-rank <K> |
0 |
Which node this process is, 0..N-1. |
--dist-init-addr <HOST:PORT> |
none, required above one node | Where node 0 listens for the other nodes. Every node passes the same value and the same other flags. |
--no-prefix-cache |
off, so caching is on | Do not share KV pages between requests with a common prefix. |
--speculative-algorithm <A> |
mtp on a checkpoint with an MTP head, else ngram |
mtp, ngram or none. mtp drafts with the checkpoint’s MTP head, ngram from text already in the context, none turns speculation off. |
--num-speculative-tokens <N> |
per model | Drafts the MTP head makes a step, 1 to 16. |
--speculative-draft-model-path <DIR|ORG/NAME> |
off | A block drafter checkpoint (DFlash2) that drafts for its target, such as ricursiveAI/Ripple-65B-Preview-DFlash2 beside ricursiveAI/Ripple-65B-Preview-NVFP4, in place of the target’s own MTP head where it has one. CUDA, any --tp. |
--synthetic-acceptance-length <AL> |
off | Benchmark only. Pins speculative decoding’s acceptance so AL tokens a verify step come out on average; the output is not the model’s. |
Notes
Memory. By default the engine takes --gpu-memory-utilization of the scarcest card’s total memory, subtracts the weights, and gives the rest to the KV pool. --max-num-seqs then defaults to 128, or fewer when the pool cannot back 1024 tokens per sequence.
Context. A request whose prompt reaches the context limit is refused with a 400 that names the limit.
Tensor parallelism. Without --tp the engine uses every GPU it can see. More than one GPU needs a Pro license key; on a multi-GPU host without one, pass --tp 1.
Across nodes. --nnodes, --node-rank and --dist-init-addr spread one model over several machines, one server process a node. Node 0 serves the API. See Multi-node.
Pro license. More than one GPU (tensor parallelism, on one machine or several) and the Dynamo worker need a Pro license key; see layerscale.ai/pricing. Started with one, the engine prints a license log line.
Speculative decoding. The engine speculates unless told otherwise: with the checkpoint’s MTP head where it ships one, and by prompt lookup (ngram) elsewhere. Pass none when outputs must be reproducible bit for bit across runs, for example when comparing engines.
Block drafter. --speculative-draft-model-path loads a DFlash2 draft checkpoint beside its target; on Qwen3.8-27B it drafts in place of the checkpoint’s own MTP head. The drafter reads the target’s residual stream at a few of its layers and proposes a block (up to fifteen tokens on the Ripple-65B draft, seven on the Qwen3.8-27B one; how many of them pay is measured on the card and the traffic the server runs) in one pass; the target verifies the block as it verifies an MTP head’s drafts, and the output distribution is the target’s own (greedy requests get greedy decoding’s tokens up to rounding; sampled requests draw from the target’s distribution). The draft must be built for the target (its hidden size, vocabulary and layer count are checked at load). It runs on CUDA at any --tp (its layers shard with the target’s), with --speculative-algorithm mtp (the default) and without --num-speculative-tokens; its block length is the checkpoint’s. The draft’s layers and its own KV for every context token are held on the GPU (about 3.8 GB of weights plus 20 KB a token on the 27B pair).
--synthetic-acceptance-length is for comparing engines at one acceptance length, never for serving. Each verify step accepts as many of its drafts as keep the mean tokens a step at the length, and the KV pages, recurrent state, sessions and next drafts follow as after a real verify. The speculation startup line and /metrics report the length set and the length realized.
With an MTP head, each step verifies the tokens the head proposed in the step before, and the verify keeps the output distribution exactly what plain decoding samples (greedy requests get the tokens greedy decoding picks, up to the rounding a wider step brings). It roughly doubles single-stream decode speed and helps every decode-heavy load. The head’s weights and its cache are held on the GPU, out of the memory the KV pages and the recurrent state share (about 2 GB a GPU on Qwen3.8-Flash-Next at --tp 2); a draft takes pages only from a pool that holds everything it has admitted, so speculation never costs a running sequence its place. --speculative-algorithm ngram does not load the head and leaves such a checkpoint to prompt lookup, which runs only where no layer carries a recurrent state (a rejected draft would leave the state past the transcript); on Qwen3.8-Flash-Next it is therefore a bit-exact decode without the head, as none is.
Examples
# Serve on all interfaces on two GPUslayerscale --model mistralai/Mistral-Small-4-119B-2603 --tp 2 serve 0.0.0.0:8080
# One completionlayerscale --model nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4 generate \ '{"messages":[{"role":"user","content":"hi"}]}'
# The same server in Dockerdocker run --gpus all -p 8080:8080 -e LAYERSCALE_LICENSE_KEY=LSK-... \ -v ~/.cache/huggingface:/root/.cache/huggingface \ layerscale/layerscale:latest \ serve 0.0.0.0:8080 --model mistralai/Mistral-Small-4-119B-2603 --tp 2
# One video clip with sound, in Docker (see Video and image generation)docker run --rm --gpus all \ -v ~/.cache/huggingface:/root/.cache/huggingface -v /data/clips:/out \ layerscale/layerscale:latest \ --model MiniMaxAI/MiniMax-H3 video --out /out/fox.mp4 \ --prompt "A red fox trotting through a snowy pine forest, snow crunching underfoot"
# One server over two nodes of four GPUs; the second node passes --node-rank 1layerscale --model nvidia/GLM-5.3-Flash-NVFP4 --tp 8 --nnodes 2 --node-rank 0 --dist-init-addr node0:29500 serve 0.0.0.0:8080Logs
Every log line is one JSON object on stdout with ts, level and event fields. Startup emits engine, license (with a Pro key), loading_model, model_loaded, engine_config and ready, plus ctx_defaulted when the checkpoint’s context ceiling was larger than the pool. On datacenter Blackwell, tcgen05_images names the kernel image the card runs (sm_100a or sm_103a). Across nodes, node 0 emits cluster_up and every other node node_serving. Every API call emits a request line with the route, status, token counts, time to first token and total time.