sglang-metis
SGLang support for Lernex's Metis models. Install it next to SGLang and they serve like any other model: OpenAI-compatible API, reasoning split out of the answer, tool calls parsed and typed, radix prefix caching, chunked prefill, CUDA graphs.
| Model | Repositories |
|---|---|
| Metis-1.7 Logos Research Preview | Lernex/Metis-1.7-Logos-Research-Preview (BF16), Lernex/Metis-1.7-Logos-Research-Preview-FP8, Lernex/Metis-1.7-Logos-Research-Preview-NVFP4 |
| Metis-1.6 | Lernex/Metis-1.6-Logos, Lernex/Metis-1.6-Praxis and their -FP8 checkpoints |
Everything registers through SGLang's sglang.srt.plugins entry point, so there is nothing to
import or patch:
Metis17ForCausalLMandMetis16ForCausalLM, the models, with their state layouts in SGLang's hybrid Mamba pool.--reasoning-parser metis, which separates the thinking from the answer.--tool-call-parser metis, which turns<|tool_call|><function=...>blocks into OpenAI tool calls, typing each argument from the request's JSON schema.- The
metis_nvfp4quantization method the Metis-1.7 NVFP4 repository is read with, and the server settings Metis-1.7 needs.
One parser name serves both chat formats: the parsers read from the tokenizer whether a model speaks metis-chat/v1 (1.6) or metis-chat/v2 (1.7).
Install
pip install "sglang-metis>=0.2.0"
It needs SGLang 0.5.22 or newer.
Metis-1.7 Logos Research Preview
Serve
python -m sglang.launch_server --model-path Lernex/Metis-1.7-Logos-Research-Preview-NVFP4 \
--reasoning-parser metis --tool-call-parser metis
No --trust-remote-code: the plugin brings its own configuration class and model, and never
runs the repository's Transformers code.
Pick the repository for the card:
| Repository | GPU memory for the weights | On a 16 GB card | Serve it with |
|---|---|---|---|
Lernex/Metis-1.7-Logos-Research-Preview-NVFP4 |
7.3 GiB | 9 requests at once at 65,536 tokens | the command above |
Lernex/Metis-1.7-Logos-Research-Preview-FP8 |
12.0 GiB | 3 requests at once at 65,536 tokens | the command above, with its name and --mem-fraction-static 0.88 |
Lernex/Metis-1.7-Logos-Research-Preview (BF16) |
23 GiB | on a 32 GB card; on 16 GB with --cpu-offload-gb 14, at about 1.6 tokens a second for one request |
the command above, with its name |
With the radix cache on, SGLang reserves three state pages for each running request, about
355 MB at 65,536 tokens; a smaller --context-length shrinks the pages and fits more. On a
16 GB card the FP8 repository needs --mem-fraction-static 0.88: SGLang's default for the card
leaves its 12 GiB of weights no room for any state. SGLang's CPU offload copies each offloaded
MoE layer to the GPU whole on every use, so BF16 on a 16 GB card is for checking outputs rather
than serving; vLLM's offload reads only the experts a step routes to and decodes BF16 on the
same card about 14 times faster.
What the plugin sets for you. Overlap scheduling is off for Metis-1.7, because each decode
step's n-gram rows are read from the token ids the previous step sampled. Prefill runs eagerly
and decode in CUDA graphs. In the FP8 and NVFP4 repositories, the FP8 dense layers run with
BF16 activations on SGLang's FP8 Marlin kernel and the NVFP4 experts with BF16 activations on
the W4A16 Marlin MoE: the precisions the repositories' recorded accuracy was measured at.
SGLang has no weight-only FP8 MoE, so the FP8 repository's experts quantize activations per
token. SGLANG_METIS_FP8_ACTIVATIONS=fp8 and SGLANG_METIS_NVFP4_ACTIVATIONS=fp4 quantize
activations in the dense layers and the NVFP4 experts too. No Metis-1.7 layer uses SGLang's
token KV cache, so the Mamba pool that holds the state pages gets the memory SGLang would
otherwise set aside for it (--mamba-full-memory-ratio 20; your own value wins). With
--cpu-offload-gb, the MoE layers move to the host, front to back, and come to the GPU around
each use.
The n-gram memory. Every repository carries an 11.6 GB ternary n-gram memory. The plugin never puts it on the GPU: it memory-maps the file, starts each step's gather on a host thread as soon as the scheduler hands the step over, and copies only the rows the step needs (2 KB a token) to the GPU, right before the first layer that reads them or right before a decode graph replays. Free system memory lets the page cache keep the rows in use; without it they are read from the SSD.
Prefix caching. SGLang's radix cache is on by default. A request's whole state is one page (every Mamba layer and every compressed-attention block), and the cache keeps that page at the end of each finished request, so the next turn of a conversation resumes from the exact state the previous turn ended in. A second turn of 639 tokens, resumed from the first turn's state with 623 tokens served from the cache, gives the same 24 greedy tokens as a cold run; its first token's distribution moves by 0.015 (NVFP4) and 0.008 (FP8) KL, the size of a change in prefill chunking.
Context. The plugin serves 65,536 tokens by default, and each request's page is sized for
the context length, so a smaller --context-length fits more requests. The Preview is trained
and measured within 4,096 tokens, and its model card explains how it degrades past that; serve
longer contexts only if you have measured them on your workload.
Sampling. SGLang reads generation_config.json: thinking-mode defaults of temperature 1.0
and top-p 0.95. For direct answers, the model card recommends temperature 0.7 and top-p 0.8.
Use it
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
model = "Lernex/Metis-1.7-Logos-Research-Preview-NVFP4"
reply = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": "How many positive divisors does 2026 have?"}],
max_tokens=16384,
)
print(reply.choices[0].message.reasoning_content) # the thinking
print(reply.choices[0].message.content) # the answer
Tools, direct mode ("chat_template_kwargs": {"enable_thinking": false}) and streaming work as
for Metis-1.6 below. In thinking mode, the turn after a tool result sometimes ends without
<|think_end|>: the Preview writes its answer inside the reasoning and stops, so the parser
returns the whole turn as reasoning_content with no content, as the reference parser in
Dromos does. Send the turn after a tool result in direct mode, or read the reasoning when the
content is empty.
How Metis-1.7 maps onto SGLang
Metis-1.7 Logos Research Preview runs its 24 layers twice per token, with separate mixers for the second pass: 18 Mamba-3 layers, three HCA and three CSA compressed-attention layers, each followed by a latent MoE (320 experts, 8 per token on the first pass and up to 16 on the second, plus a shared expert), with four mHC residual streams and the n-gram memory injected at layers 2 and 6.
Every mixer is causal with bounded state, so a request's whole decode state is one fixed page,
which SGLang's Mamba pool holds as a single Mamba layer: the page's FP32 fields in its temporal
state and its BF16 fields in its conv state. The radix cache, chunked prefill and the scheduler
then work as they do for SGLang's own hybrid models. The numerics are the same code as the vLLM
plugin's: the upstream mamba_ssm Mamba-3 Triton kernels for prefill, a step kernel adapted
from them for decode (see NOTICE), SGLang's fused MoE fed the model's own routing, and FP32
wherever the reference keeps it.
Status
Measured on an RTX 5070 Ti (16 GB) with SGLang 0.5.22, against FP32 logits from the native runtime on the release's reference prompts: a 15-token thinking chat, a 166-token chat with tools and 300 tokens of prose. Mean top-20 KL to the reference:
| Repository | Path | Thinking chat | Chat with tools | Prose |
|---|---|---|---|---|
| BF16 | whole prefill | 0.0084, 100% | 0.105, 90% | 0.0083, 96% |
| BF16 | batch | 0.0056, 93% | 0.118, 90% | 0.0073, 96% |
| FP8 | whole prefill | 0.0101, 100% | 0.123, 90% | 0.0076, 97% |
| FP8 | batch / 64-token chunks | 0.0092 / 0.0176 | 0.146 / 0.151 | 0.0077 / 0.0087 |
| NVFP4 | whole prefill | 0.0101, 93% | 0.154, 85% | 0.0157, 94% |
| NVFP4 | batch / 64-token chunks | 0.0157 / 0.0116 | 0.160 / 0.161 | 0.0157 / 0.0194 |
Each cell is the mean top-20 KL and how often the top token agrees with the reference. BF16
ran with --cpu-offload-gb 14. whole prefill: each prompt in one step. batch: the three
prompts in one step. 64-token chunks: chunked prefill, the state carried from chunk to
chunk.
- The quantizer's own measurement of each repository, with BF16 activations, is the target: FP8 0.0091 / 0.126 / 0.0067 and NVFP4 0.0125 / 0.163 / 0.0149. The native model run against itself with a batch neighbour moves by 0.0056 / 0.112 / 0.0056: the chat with tools has near-ties, which is why its floor is high. The FP8 repository's experts quantize activations per token here (see above), which the FP8 target does not.
- Decode: each prompt continued for 37 to 48 greedy tokens through the decode CUDA graph, then the whole sequence prefilled at once; the decode steps' distributions differ from the prefill's by a mean KL of 0.0053 / 0.0011 / 0.0010 (NVFP4), 0.0076 / 0.0095 / 0.0003 (FP8) and 0.0052 / 0.0036 / 0.0005 (BF16).
python -m sglang.launch_serverwith the commands above, driven through the OpenAI client byscripts/serve_smoke17.py, passes for all three repositories: NVFP4 and FP8 at the default 65,536-token context, BF16 at 8,192 with--cpu-offload-gb 14. Thinking-mode reasoning arrives asreasoning_contentand the answer ascontent, direct mode returns no reasoning, a tool call comes back typed in both modes (daysas the integer 3), the model answers from the tool's result on the next turn, and 16 requests at once keep their structure.- Reproducibility. Greedy decoding is not bit-reproducible from run to run: the fused MoE kernels can return last-bit differences between identical calls (in vLLM, where it was traced, they are the first thing to differ), and the model carries those forward about as far as a batch neighbour moves the native runtime. The same request at temperature 0 can give different text from one run to the next.
Throughput with an 8,192-token context, 128-token prompts generating 256 tokens each, radix cache off: output tokens per second over the decode, all streams together.
| Repository | 1 stream | 8 streams | 32 streams |
|---|---|---|---|
| NVFP4 | 46 | 299 | 515 |
FP8, --mem-fraction-static 0.88 |
44 | 285 | does not fit |
At this context 32 FP8 streams do not fit on a 16 GB card. BF16 with --cpu-offload-gb 14
decodes about 1.6 tokens a second for one request (see above).
Limitations
- One GPU: tensor and pipeline parallelism are not supported for Metis-1.7 in this release.
- Speculative decoding and LoRA adapters are not supported.
- Text only. The checkpoint's vision encoder is not loaded.
Metis-1.6
Serve
python -m sglang.launch_server --model-path Lernex/Metis-1.6-Praxis \
--reasoning-parser metis --tool-call-parser metis
No --trust-remote-code: the plugin brings its own configuration class and model, and never
runs the repository's Transformers code.
Memory. Praxis (3.0B) runs in BF16 on a 16 GB card. Logos (10.2B) is 20.8 GB in BF16; on a 16 or 24 GB card serve the FP8 checkpoint, which SGLang reads directly:
python -m sglang.launch_server --model-path Lernex/Metis-1.6-Logos-FP8 \
--reasoning-parser metis --tool-call-parser metis
Metis-1.6-Logos-FP8 and Metis-1.6-Praxis-FP8 are compressed-tensors FP8 checkpoints (11.2
GB and 3.5 GB): FP8 weights with one scale per output channel and activations quantized per
token, for the routed experts, the Mamba input projections and the attention projections.
Everything the architecture is sensitive to stays as trained: the Mamba output projection,
the MoE latent projections, the shared expert, the routers, the depth memory and the
embedding. scripts/make_fp8.py writes them from a BF16 checkpoint. --quantization fp8
on the BF16 weights also works (the plugin then keeps the Mamba output projection in BF16
itself), but SGLang loads the whole BF16 model before quantizing it, so Logos needs a card
that holds 21 GB to do it that way.
Concurrency. Every request holds a Mamba state for each pass of each Mamba layer (20 per request on Praxis, 32 on Logos, in FP32 as the model was trained), so the Mamba cache, not the KV cache, sets how many requests run at once. SGLang's defaults size it for models with a quarter of the state. On a 16 GB card these hold the most streams:
| Model | Flags |
|---|---|
| Praxis, BF16 or FP8 | --max-mamba-cache-size 160 --max-total-tokens 131072 --cuda-graph-max-bs-decode 32 (53 requests) |
| Logos, FP8 | --max-mamba-cache-size 24 --max-total-tokens 32768 --cuda-graph-max-bs-decode 8 --mem-fraction-static 0.92 (8 requests) |
--mamba-ssm-dtype bfloat16 halves the state and doubles the requests, at a small cost in
accuracy the reference never pays.
The sampling defaults come from the model's generation_config.json (temperature 0.6,
top-p 0.95, top-k 20). Thinking is on unless a request turns it off with
"chat_template_kwargs": {"enable_thinking": false}.
Use it
from openai import OpenAI
client = OpenAI(base_url="http://localhost:30000/v1", api_key="EMPTY")
# Thinking mode (the default): the reasoning arrives separately from the answer.
reply = client.chat.completions.create(
model="Lernex/Metis-1.6-Praxis",
messages=[{"role": "user", "content": "What is 17 x 23?"}],
)
print(reply.choices[0].message.reasoning_content)
print(reply.choices[0].message.content)
# Tools, in direct mode (no thinking).
reply = client.chat.completions.create(
model="Lernex/Metis-1.6-Praxis",
messages=[{"role": "user", "content": "Weather in Lisbon for the next 3 days?"}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}, "days": {"type": "integer"}},
"required": ["city"],
},
},
}],
extra_body={"chat_template_kwargs": {"enable_thinking": False}},
)
print(reply.choices[0].message.tool_calls) # get_weather(city="Lisbon", days=3)
Streaming works the same way: reasoning, content and tool-call arguments arrive as deltas.
How the model maps onto SGLang
Metis-1.6 runs its stack of blocks twice per token with shared weights. Each block carries four residual streams joined by pass-conditioned Sinkhorn mixes, runs a Mamba-2 or position-free GQA mixer and then a latent mixture of experts, and keeps a per-token depth memory written after every attention layer and at the end of every pass.
Only the mixers look across positions, so the plugin gives each (pass, layer) pair its own
SGLang layer id, pass * layers + layer, while the weights exist once. SGLang's hybrid
backend then allocates a Mamba state or a KV cache per pass, and radix caching, chunked
prefill and CUDA graphs work as they do for any hybrid model. A Mamba block calls SGLang's
Mamba-2 backend with the pass's layer id; inside a CUDA graph that call is a graph break, as
SGLang's own hybrid models do it, because it reads each step's batch layout. An attention
block keeps one weightless RadixAttention per pass.
The parts the model is sensitive to stay in FP32 where the reference keeps them: the routers
and their balance bias, A, D and dt_bias, the SSM state, the Sinkhorn mixes, the depth
memory's attention and gates, the depth head and every RMSNorm. The 4x4 mixes and their read
and write weights depend only on the pass, so they are computed once when the weights load.
Status
Measured on an RTX 5070 Ti (16 GB) with SGLang 0.5.22, CUDA graphs on, against FP32 logits from the native training runtime on the release's reference prompts (a 16-token thinking chat, a 176-token chat with tools, 300 tokens of prose). Mean top-20 KL to the reference, and how often the top token agrees:
| Model | Weights | Thinking chat | Chat with tools | Prose | tok/s, 1 / 32 streams |
|---|---|---|---|---|---|
| Praxis | BF16 | 0.0013, 100% | 0.014, 94.9% | 0.0018, 98.7% | 153 / 1969 |
| Praxis | FP8 checkpoint | 0.0055, 100% | 0.036, 93.7% | 0.0077, 96.0% | 153 / 2096 |
| Praxis | BF16, --quantization fp8 |
0.011, 93.3% | 0.042, 89.1% | 0.0075, 98.0% | 152 / 2098 |
| Logos | FP8 checkpoint | 0.0055, 93.3% | 0.033, 91.4% | 0.0079, 95.3% | 82 / 430 (8 streams) |
Praxis in BF16 is inside the noise floor of the native model run in BF16 (0.0073, 0.014, 0.0022). In every configuration the thinking and direct answers are correct.
scripts/smoke.pyproduced the table: prompt logprobs on fixed token sequences, greedy generation in thinking and direct mode, one stream and a batch.scripts/serve_smoke.pyagainstsglang.launch_serverwith both parsers: thinking-mode reasoning arrives asreasoning_content, a tool call comes back typed (daysas the integer 3) in direct and thinking mode, the streamed answers equal the whole ones, and the model answers from the tool's result on the next turn.tests/checks both parsers on outputs rendered by the real tokenizer and chat template, whole and streamed in deltas of 1, 2, 3, 7 and all characters, and that every checkpoint tensor (BF16 and FP8) maps onto the model.
Limitations
- Tensor parallelism must divide the Mamba groups and KV heads: 10 on Logos (TP 1, 2, 5 or 10), 8 on Praxis (TP 1, 2, 4 or 8). Only TP 1 has been run. Pipeline parallelism is not supported: every layer runs twice per token.
- Speculative decoding and LoRA adapters are untested.
- The adaptive-depth and adaptive-width heads in the checkpoint are not used: the release runs the fixed policy (2 passes, top 4), which is what this plugin implements.
- SGLang ships no tuned fused-MoE kernel configuration for these expert shapes on most cards
and falls back to its default; tuning one with SGLang's
tuning_fused_moe_triton.pymay add speed.
Tests
pip install -e ".[test]"
METIS_MODEL_DIR=/path/to/Metis-1.6-Praxis METIS17_MODEL_DIR=/path/to/Metis-1.7-Logos-Research-Preview pytest
Without the two directories the parser tests fetch the tokenizers from the Hub and the
weight-map tests skip. tests/test_parser17.py checks both parsers on metis-chat/v2 turns
rendered by the real Metis-1.7 tokenizer and chat template, whole and streamed in deltas of
several sizes. The Metis-1.7 numerics are the vLLM plugin's, tested there.
Scripts:
scripts/kl17.py: Metis-1.7 against reference logits (--refs): whole, batch, chunked, decode against prefill, and a radix-cached second turn.scripts/bench17.py: Metis-1.7 throughput at several stream counts.scripts/serve_smoke17.pyandscripts/serve_smoke.py: the OpenAI-client checks against a running server, for 1.7 and 1.6.scripts/smoke.pyandscripts/make_fp8.py: the Metis-1.6 checks and FP8 writer.
License
Apache 2.0.
Metadata
Release files for sglang-metis 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sglang_metis-0.2.0.tar.gz | 78.9 kB | With provenance | Details for sglang_metis-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sglang_metis-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for sglang_metis-0.2.0-py3-none-any.whl |
Total release size: 157.2 kB
Release files / sglang_metis-0.2.0.tar.gz
| Download URL | sglang_metis-0.2.0.tar.gz |
|---|---|
| Size | 78.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ace146818dcfe00939fd7bcbceaf346c111a86ac8490a293cc1b874201511e5a
|
|
BLAKE2b-256 checksum How to use checksums |
a8dc3f6c0baab2d1a4b875675f5c133aff5058a0539670153e8fe34ecdd488da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logRelease files / sglang_metis-0.2.0-py3-none-any.whl
| Download URL | sglang_metis-0.2.0-py3-none-any.whl |
|---|---|
| Size | 78.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
54e8e938fc415affde3fc91efd7a7f04c61e23ebc6b3d6a9dd349f58c6b8b1db
|
|
BLAKE2b-256 checksum How to use checksums |
3093a4d85c2e53877d58e1af1db8a8d75999784bc93df82c1beeaf2a544d7710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logSecurity for sglang-metis 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sglang_metis-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.