# How to Run KLM 1.6-Chat Locally on CPU or GPU

> Source: <https://www.mindstudio.ai/blog/run-klm-1-6-chat-locally-cpu/>
> Published: 2026-12-04 00:00:00+00:00

**Recommendation:** Load KLM 1.6-Chat with trust_remote_code=True in Transformers and split replies on </think> to log reasoning separately; on NVIDIA GPUs use fast_generate for batched decoding.
More in the playbook "Inference and self-hosting": <https://wpnews.pro/playbooks/inference-serving>

# How to Run KLM 1.6-Chat Locally on CPU or GPU

KLM 1.6-Chat is a 99M-parameter model that runs on CPU with plain PyTorch. Here's the setup, tool-calling code, and how to avoid doom loops.

## What is KLM 1.6-Chat?

KLM 1.6-Chat is a 99-million-parameter chat model from MinimaLabs, built on top of the KLM 1.6 base model. It’s small enough to load and run on a CPU with nothing but the Hugging Face Transformers library, no quantization tricks or GGUF conversion required. Despite its size, it scores competitively against chat models 2.3 to 17 times larger on instruction-following benchmarks like IFEval and Multi-IF, though it falls behind bigger models on tasks that reward memorized facts and arithmetic, like MMLU and GSM8K.

## TL;DR

- **KLM 1.6-Chat** is a 99M-parameter model (98,975,308 parameters, with 5.4M of those dedicated to an n-gram memory module) that runs as plain PyTorch on CPU or GPU.
- The model posts the best **IFEval and Multi-IF scores** among the compared chat models, including ones with hundreds of millions to nearly two billion parameters, but trails on GSM8K and MMLU where scale and stored knowledge matter more.
- It supports a **32,768-token context window** , extended from a 2K pretraining length through a dedicated long-context post-training stage using YaRN RoPE scaling.
- **Tool calling** is built in via a`<tool_call>` syntax, with four native tools (web_search, read_web_page, current_time, get_weather) and support for custom tool schemas.
- **Doom loops** , where small models repeat the same text until they hit the token limit, were cut from 13% to a much lower rate using reinforcement learning rather than a token-level anti-repetition fix that broke tool calling.
- On NVIDIA GPUs, the model supports **fast_generate** , a batched decoding method using fused Triton kernels and CUDA graphs for running many conversations at once.
- Reasoning (chain-of-thought via `<think>` tags) is**on by default** and can be disabled per request with`enable_thinking=False` .

### Build a credit limitreview app for800 relationshipmanagers

One prompt. Role-based access, audit trail and SSO come built in.

## How do you set up KLM 1.6-Chat locally?

The setup is minimal because the model uses standard PyTorch and the Transformers library, no custom inference server or special runtime needed. The basic loading code looks like this:

``` python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "MinimaLabs/KLM-1.6-Chat"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True).to(device)
```

From there, you build a chat message list, apply the chat template, and call `generate()`. Because the model is only 99M parameters, inference on a CPU is genuinely usable for single-turn requests, not just a technical curiosity. The chat template accepts an `enable_thinking` flag that toggles the model’s chain-of-thought reasoning inside `<think>` tags.

```
messages = [{"role": "user", "content": "Explain why the sky looks blue in two sentences."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=True,
                                       return_tensors="pt", return_dict=True).to(device)
outputs = model.generate(**inputs, max_new_tokens=1024)
reply = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
reasoning, _, answer = reply.removesuffix("<|im_end|>").rpartition("</think>")
print(answer.strip())
```

Splitting on `</think>` separates the model’s internal reasoning from its final answer, which is useful if you only want to display the answer to end users while logging the reasoning for debugging.

## What does the architecture look like under the hood?

KLM 1.6-Chat uses a hybrid design: 24 layers mixing Gated DeltaNet-2 (a linear-attention-style mechanism) with regular attention at a 3:1 ratio. The hidden size is 512, attention uses 8 query heads and 4 KV heads with YaRN RoPE scaling for long context, and the feed-forward blocks use SwiGLU activations. A notable detail is the n-gram memory: roughly 125,000 bigrams and 38,000 trigrams each get their own learned vector, accounting for about 5.4 million of the model’s 99 million total parameters. The vocabulary is small too, just 4,100 tokens with tied embeddings, which keeps the model compact but also means it has limited capacity to represent rare words or world knowledge directly.

This architecture is why the model can run on CPU: linear-attention-style layers like Gated DeltaNet-2 are cheaper to compute than full attention at longer sequence lengths, and the overall parameter count is small enough that even unoptimized PyTorch execution is fast.

## How does tool calling work, and how do you parse it?

KLM 1.6-Chat was trained to call tools using a `<tool_call>` JSON block that appears after its `</think>` reasoning section. The model was trained specifically with four tools in mind: `web_search`, `read_web_page`, `current_time`, and `get_weather`, but it accepts custom tool definitions as long as they follow the same schema (a name, a description, and flat string parameters).

To use tools, you pass tool definitions to the chat template and then parse the model’s output for `<tool_call>` blocks with a regular expression:

``` python
import json, re

TOOL_CALL_RE = re.compile(r"<tool_call>\s*(\{.*?\})\s*</tool_call>", re.S)

def parse_tool_calls(reply):
    answer = reply.split("</think>", 1)[1] if "</think>" in reply else reply
    calls = []
    for raw in TOOL_CALL_RE.findall(answer):
        try:
            call = json.loads(raw)
        except json.JSONDecodeError:
            continue
        if isinstance(call, dict) and isinstance(call.get("name"), str) and isinstance(call.get("arguments", {}), dict):
            calls.append({"name": call["name"], "arguments": call.get("arguments", {})})
    return calls
```

### Build a claims

triage app for

4,000 insurance

adjusters

One prompt. Role-based access, audit trail and SSO come built in.

After running the requested tool, you send the result back as a `tool`-role message and continue the conversation. One practical tip from the model’s documentation: if the model calls a tool that doesn’t exist, returning an error message that lists the actually available tools usually gets it to recover and call the right one on the next turn.

A separate behavioral quirk worth knowing: when tool definitions are present in the prompt, the model reasons noticeably less, sometimes just a line or two, even on questions that don’t need a tool at all. If you’re doing pure reasoning tasks like math or logic puzzles, it’s better to drop the tool definitions from the request entirely.

## Is KLM 1.6-Chat worth running instead of a larger model?

It depends on the task. For instruction-following, where the goal is strict adherence to formatting or constraints in a prompt, KLM 1.6-Chat’s IFEval and Multi-IF scores beat models several times its size, including a 1.7B model. That makes it a reasonable choice for applications built around structured output, strict formatting, or agentic tool-calling loops where following directions matters more than broad world knowledge.

For tasks requiring factual recall or multi-step arithmetic, it’s clearly outmatched. GSM8K and MMLU scores favor larger models, which makes sense: those benchmarks reward stored knowledge and computation, and a 99M-parameter model with a 4,100-token vocabulary simply doesn’t have room to store much. The model’s own documentation is blunt about this limitation, noting it often states wrong facts confidently when answering from memory. If your use case needs factual grounding, pairing it with the `web_search` and `read_web_page` tools is the better path than trusting it to recall facts directly.

## How were doom loops fixed without breaking tool calling?

Doom loops, where a small model gets stuck repeating a phrase or sentence until it exhausts its token budget, affected 13% of KLM 1.6-Chat’s replies to loop-prone prompts after initial fine-tuning. The first fix attempted was Liquid AI’s final-token preference optimization technique, which specifically trains the model against the token where a loop begins. It worked for loops, dropping the rate to 0.5%, but it had a severe side effect: it also taught the model not to copy from its context at all, which collapsed its tool-calling performance (BFCL AST score fell from 35.9 to 9.8).

The approach that stuck was reinforcement learning. Each of six RL specialists scored looped or unfinished replies as zero reward, and during the later merge step, any reply that repeated the same span eight times in a row got cut off exactly where the loop started. This fixed the repetition problem without specifically punishing the model for legitimately copying text from context, which tool use and long-document tasks both depend on.

## Frequently Asked Questions

### Can KLM 1.6-Chat run without a GPU?

Yes. It’s built as plain PyTorch with no custom CUDA kernels required for basic inference, so it runs on CPU using only the standard Transformers library. GPU acceleration is optional and mainly useful for batching many conversations at once.

### What is fast_generate and when should I use it?

### Build a claims triage app for 4,000 insurance adjusters

One prompt. Role-based access, audit trail and SSO come built in.

`fast_generate` is a batched decoding method available on NVIDIA GPUs that uses fused Triton kernels and CUDA graphs to decode multiple conversations simultaneously. Triton ships with PyTorch’s CUDA builds on Linux. It’s worth using if you’re serving many requests at once; each decoding slot reserves memory for a full 32K context (about 200 MB in bf16), so the default of 16 slots may need to be lowered on smaller GPUs.

### Does turning reasoning off make the model worse?

It depends on the task. Reasoning off gives tighter, faster replies on simple prompts, but for multi-step math or logic problems, disabling reasoning sometimes causes the model to never reach a final answer. Reasoning is enabled by default and can be turned off per-request with `enable_thinking=False`.

### What context length does KLM 1.6-Chat actually support?

The model supports up to 32,768 tokens, extended from its base model’s 2,048-token pretraining length through a dedicated long-context training stage using YaRN RoPE scaling, plus long-context examples woven into supervised fine-tuning and a dedicated RL specialist trained on document QA and key-chain tasks.

### How accurate is KLM 1.6-Chat on factual questions?

Not very, by its own documentation. At 99M parameters with a small 4,100-token vocabulary, it has limited capacity to store world knowledge and often states incorrect facts with confidence. It performs much better on instruction-following and tool-use tasks than on open factual recall.
