Deployment
Install SGLang
Install SGLang
- Low-Latency — enables speculative decoding with the model’s built-in Multi-Token Prediction (MTP) layer to reduce time between output tokens. Start here for chat and agent loops.
- High-Throughput — speculative decoding off, for tuning workloads with many concurrent requests. Compare it with MTP on your workload before choosing a serving strategy.
- DFlash2 — speculative decoding with a separate BF16 draft and a learned path selector. Download the checkpoint’s
dflash_draft/directory before launching; DFlash2 draft path defaults todflash_draft.
Playground
The Playground lets you change parsers, parallelism, GDN state precision, and speculative decoding on top of the selected deployment recipe. Changing the recipe marks the resulting configuration Not Verified until it has been run end-to-end.1. Model introduction
GigaChat 4 is a hybrid Mixture-of-Experts model — 708B total parameters and 41B active per token. Its 64 layers interleave 16 DSA layers, every fourth layer, with 48 GDN linear-attention layers. DeepSeek Sparse Attention (DSA) combines Multi-head Latent Attention (MLA) with an indexer that selects relevant tokens. Gated DeltaNet (GDN) uses a recurrent state instead of a growing KV cache. The MoE block routes to 8 of 256 experts plus 1 shared expert. The model uses gated normalization, attention gates, SwiGLU clipping at 10, and final-logit soft-capping at 30. Its configured context window is 1,048,576 tokens, using YaRN with factor 32 over a 32K base. The context a server can admit also depends on its available cache memory. The checkpoint includes one MTP layer, reused recurrently for speculative decoding. DFlash2 uses a separately trained draft. Unlike the separate instant and reasoning releases of GigaChat 3.5, GigaChat 4 switches between direct answers and reasoning on each request. Tool calls use GigaChat’s GCML format in both modes. Resources: GigaChat4-708B-A41B on Hugging Face · SGLang integration · GigaChat 3.5 Reasoning cookbook.2. Configuration tips
Weight memory. The recipes serve an FP8 target. Its weights exceed the combined capacity of eight H100 80 GB GPUs, so the H100 recipes use two nodes and TP16. Keep the checkpoint accessible at the same path on both nodes, or download the same Hugging Face revision on each. Eight H200 141 GB GPUs provide more memory per node; the TP8 recipes remain unverified. Two cache pools. DSA layers use a paged attention KV pool; GDN layers keep per-request recurrent and convolution states in a Mamba-style pool.--mamba-full-memory-ratio balances the two pools, and --max-mamba-cache-size sets an explicit state-pool size. Speculative decoding needs additional GDN state buffers for verification. Tune the state pool together with concurrency rather than copying the GigaChat 3.5 pool size.
Context and concurrency. The recipes set --max-running-requests 64 and --cuda-graph-max-bs-decode 64. The first caps concurrent running requests; the second controls decode CUDA graph capture. They leave --context-length, --max-total-tokens, and --chunked-prefill-size to SGLang’s defaults and memory planning. A configured 1M-token window does not guarantee enough cache memory to admit a request of that size: check the startup log for context_len and max_total_num_tokens. Set a smaller --context-length if your application does not need the full window.
Parsers. The recipes enable --reasoning-parser auto and --tool-call-parser auto, which resolve to gigachat4 for this architecture. You can also select gigachat4 explicitly for both. Keep the reasoning parser enabled for instant requests too; it handles both modes and returns thinking separately from the answer.
Draft precision. MTP loads the bundled NextN layer automatically. DFlash2 needs a separate draft path and --speculative-draft-model-quantization unquant to keep the MLA draft in BF16 while the target stays FP8. The draft’s attention backend is configured independently; the DFlash2 recipe uses flashinfer.
3. Advanced usage
The examples use the OpenAI-compatible API. Install the client withpip install openai. For a two-node deployment, replace localhost with the head node’s address when running the client elsewhere.
3.1 Instant and reasoning modes
Setchat_template_kwargs.reasoning on each request: false for a direct answer, true for reasoning followed by the answer. The checkpoint’s chat template enables reasoning by default when this argument is omitted. With the gigachat4 reasoning parser enabled, thinking is returned in message.reasoning_content and the answer in message.content.
Instant and reasoning example (Python)
Instant and reasoning example (Python)
temperature and top_p in the client request; SGLang’s repetition_penalty goes in extra_body, alongside chat_template_kwargs:
max_tokens covers both reasoning and the final answer. An empty content with finish_reason: "length" can mean that generation stopped before the reasoning block closed; increase the limit for longer reasoning tasks.3.2 Multi-turn conversations and tool calling
Send the conversation history with each request. Store assistant thinking inreasoning_content on the same assistant message as its answer; do not create a separate reasoning role. The template argument drop_history_thinking can remove thinking from earlier user turns when rendering the history.
Multi-turn example without tools (Python)
Multi-turn example without tools (Python)
gigachat4 tool-call parser converts GCML blocks into OpenAI message.tool_calls and removes those blocks from content. A block can contain several calls. Execute each call, append the assistant message and a tool result for every tool_call_id, then request the next answer. The server parses calls; your application executes the functions.
Weather tools and follow-up example (Python)
Weather tools and follow-up example (Python)
tool_choice="auto" lets the model choose whether to call a tool; "required" requires a call on that turn, and "none" disables tool calls. Apply "required" only to the turns that need a call, so the model can give its final answer after receiving the results.
3.3 Streaming
Setstream=True in the same chat.completions.create request. Thinking and answer text arrive in separate delta fields. Concatenate each field in arrival order; one chunk can contain several tokens, and chunk boundaries do not correspond to MTP verification steps.
Streaming reasoning and answer (Python)
Streaming reasoning and answer (Python)
<think>, </think>, and GCML delimiters are removed by the parsers. To stream tool calls, collect delta.tool_calls by index, retain each call’s id, and concatenate the function name and arguments fragments before parsing JSON. Execute a call only after its arguments are complete.
Collect streaming tool calls (Python)
Collect streaming tool calls (Python)
--max-running-requests limit. Both streaming and non-streaming requests can run concurrently; requests above the running limit wait in the queue.
3.4 MTP speculative decoding
The Low-Latency recipe runs the checkpoint’s own NextN layer through EAGLE. GigaChat 4 reuses this single layer for three draft steps; GigaChat 3.5 uses stacked heads. No separate draft checkpoint or--speculative-draft-model-path is needed.
3.5 DFlash2 speculative decoding
The DFlash2 recipe uses a separate draft trained for the target checkpoint. The draft combines grouped convolutions with a learned path selector over token candidates. It has its own weights and layer count; it does not use the target’s bundled MTP layer. Download the draft from the model repository into./dflash_draft. Run this command on each node, or use a shared working directory:
- Use a matching draft. The bundled
dflash_draft/directory contains the draft for this target. If you download it elsewhere, update DFlash2 draft path in the deployment panel. The draft config must identifyGigaChat4DFlash2DraftModeland contain the traineddflash_config, including the target depth. A draft trained for a different target size is not interchangeable. - Keep the MLA draft in BF16. The target can remain FP8.
unquantprevents the draft from inheriting the target’s quantization setting; the current MLA draft implementation requires unquantized weights. - Configure the draft backend separately.
--speculative-draft-attention-backend flashinferapplies to the draft’s dense MLA attention. The target keeps its DSA attention backend. - Choose the block size for the trained draft. The preset uses eight positions: one anchor and seven proposed tokens. Check the draft’s configuration before changing it.
