A hybrid decoder: three fast layers, then one that sees everything
K2 is a decoder-only transformer with 32 layers. In every group of four, three are Gated DeltaNet (linear attention with a fixed-size memory) and the fourth is full softmax attention. Each layer is a pre-norm residual block: the mixer runs on RMSNorm(x) and is added back to x, then a SwiGLU feed-forward does the same.
Gated DeltaNet layers (24)
Each of the 32 heads keeps a 128 × 128 memory matrix S. For every token it fades the old memory, erases what was stored under the current key, and writes the new value:
ot = St⊤ · qt / √128
- αt ∈ (0, 1) is a learned decay: how quickly old memories fade. βt ∈ (0, 1) is the write strength.
- q and k are L2-normalised. A short causal convolution (width 4) runs over q, k and v first.
- The output goes through a per-head RMSNorm and a learned output gate.
- Cost grows linearly with length and the memory never grows, so a 32K-token prompt costs these layers the same memory as a 32-token one.
- Training uses a chunked form (64-token chunks). On GPU it runs on Triton kernels from the open-source flash-linear-attention library. Our plain-PyTorch version of the same math is the reference the tests check against.
Full-attention layers (8)
Grouped-query attention with 32 query heads and 8 key/value heads (head size 128), QK-norm and a learned output gate. These layers use no positional encoding (NoPE). Word order reaches them through the DeltaNet layers, which read the sequence in order, so there are no rotary frequencies to break when the context is stretched past what training saw.
Full specification
| Setting | k2-7b |
|---|---|
| Hidden size | 4,096 |
| Layers | 32 (24 DeltaNet + 8 attention) |
| Attention heads | 32 query · 8 key/value · 128 dim |
| DeltaNet heads | 32 · 128 × 128 state |
| Feed-forward | SwiGLU, 11,008 |
| Normalisation | RMSNorm, pre-norm |
| Positions | none in attention (NoPE) |
| Vocabulary | 65,536 |
| Input and output embeddings | separate (not tied) |
| Context | 8,192 → 32,768 |
Where the parameters are
| Component | Each | Total | Share |
|---|---|---|---|
| Feed-forward (SwiGLU) × 32 | 135.3M | 4.33B | |
| Gated DeltaNet mixers × 24 | 84.2M | 2.02B | |
| Attention mixers × 8 | 58.7M | 470M | |
| Vision encoder and merger | – | 343M | |
| Token embedding | – | 268M | |
| Output head | – | 268M | |
| Norms | – | 0.27M | |
| Total | 7.70B | 7.36B language model |
Memory per conversation
What one conversation needs to hold while K2 writes. Only the 8 attention layers keep a cache that grows with length; the DeltaNet layers stay at 48 MiB in total.
bf16 key/value cache for one sequence (8 KV heads × 128 dims per attention layer) plus the fp32 DeltaNet state. Lengths past 32K need a further training stage.
Our own byte-level tokenizer
A byte-level BPE tokenizer trained from scratch on a sample of the same data mix K2 learns from. It has 65,536 entries, so every token id fits in 2 bytes on disk. Because it works on bytes, any text can be encoded, with no unknown tokens. The first 256 ids are reserved for special tokens and 12 of them are in use.
| Id | Token | Purpose |
|---|---|---|
| 0 | <|endoftext|> | End of a document |
| 1 | <|pad|> | Padding |
| 2 · 3 | <|im_start|> · <|im_end|> | Start and end of a chat turn. Generation stops at <|im_end|>. |
| 4 · 5 | <|vision_start|> · <|vision_end|> | Wrap an image |
| 6 | <|image_pad|> | One image token, replaced by vision features |
| 7 | <|video_pad|> | Reserved for video (not used yet) |
| 8 · 9 | <|tool_call|> · <|/tool_call|> | Reserved for tool use |
| 10 · 11 | <|think|> · <|/think|> | Reserved for reasoning |
Chat format
<|im_start|>system Answer briefly.<|im_end|> <|im_start|>user <|vision_start|><|image_pad|> × N<|vision_end|> What's in this picture?<|im_end|> <|im_start|>assistant … K2 writes here, then <|im_end|>
Text that people type can't produce these control tokens: the chat server neutralises them before encoding.
Images become tokens in the same stream as text
K2's vision encoder is a ViT trained from scratch inside our pipeline. Images keep their aspect ratio; nothing is cropped to a square.
- Resize to fit. The image is scaled so both sides are multiples of 32 px, up to about one megapixel.
- Cut into patches. 16 × 16 px patches go through 24 transformer layers with 2D rotary positions (row and column).
- Merge 2 × 2. Four neighbouring patches are joined into one token, so each token covers 32 × 32 px.
- Splice into the text. The tokens fill the
<|image_pad|>slots and the language model reads them in line with the words around them.
| Setting | Vision encoder |
|---|---|
| Patch size | 16 × 16 px |
| Layers · width · heads | 24 · 1,024 · 16 |
| Feed-forward | 2,816 |
| Positions | 2D rotary |
| Merger | 2×2 concat → RMSNorm → MLP (GELU) → 4,096 |
| Image size | any aspect ratio, ≤ 1,048,576 px |
| Tokens per image | 4 to ~1,024 |
| Parameters | 342.8M |
What an image costs
Five stages, from random weights to a chat model
Each stage starts from the weights the previous one exported. The language model learns text first, then the vision encoder learns to talk to it, then everything trains together, then the context is stretched, and finally K2 learns to follow instructions.
Recipe
| Optimizer | AdamW, β₁ 0.9, β₂ 0.95, weight decay 0.1, gradient clipping 1.0 |
| Learning rate | Warmup, then constant, then a decay over the last 15–20% of steps down to 10% of the peak |
| Extra loss | z-loss 1e-4, which keeps the output logits small and training stable |
| Precision | bf16, with weights and optimizer state sharded across GPUs (FSDP2) |
| Batch | About 1.05M tokens per step at each site |
| Start | Random initialisation (std 0.02). No pretrained weights anywhere. |
Stages
| Stage | What trains | Data | Context | Steps | Tokens | Peak LR |
|---|---|---|---|---|---|---|
| 1 · Text | Language model | Web 60%, code 30%, math 10% | 8K | 477,000 | 1T | 2e-4 |
| 2 · Vision warm-up | Vision encoder only (language model frozen) | Image captions | 4K | 5,000 | 5B | 1e-3 |
| 3 · Multimodal | Everything | 60% text; 40% captions, interleaved pages, OCR | 8K | 30,000 | 63B | 1.5e-4 |
| 4 · Long context | Everything | Books and papers 30%, code repos 25%, synthetic retrieval 15%, short web 30% | 32K | 10,000 | 21B | 6e-5 |
| 5 · Instructions | Everything (one site) | Chat 35%, code 30%, vision 20%, long documents 10%, safety 5% | 32K | 2,000 | 2B | 1e-5 |
The stage 1 mix:
Two sites, one model (DiLoCo)
Two sites train the same model at the same time, each on its own half of the data, and merge their progress through a shared storage bucket. They never need a fast link between them.
- Site 0 creates the random starting weights and shares them, so both sites hold the same model.
- Each site trains 500 steps (about an hour) on its own half of the data with AdamW.
- Each uploads how far its weights moved, downloads the other site's, and both average them.
- An outer optimizer (SGD with Nesterov momentum 0.9, learning rate 0.7) applies the averaged change. Both sites end the round bit-identical.
- Each round moves about 15 GB per site (7.7 GB with int8 compression). If one site stops, the other waits at the next sync, and nothing drifts.
Data
Candidate datasets for each part of training. Each license is checked before a dataset is used.
| Purpose | Candidates |
|---|---|
| Web text | FineWeb-Edu, DCLM baseline, Cosmopedia |
| Code | The Stack v2, StarCoderData, SmolLM corpus (Python) |
| Math | FineMath, OpenWebMath |
| Image captions | PixelProse, PD12M (public domain) |
| Interleaved image and text | OBELICS |
| Vision instructions | FineVision (samples rated 4/5 or higher), The Cauldron |
| Chat and code instructions | SmolTalk, Magicoder OSS-Instruct |
| Long documents | PG-19 books, arXiv papers, whole code repositories |
| Safety prompts | Aegis 2.0, BeaverTails, WildJailbreak |
A small pilot first
Before the 7B run, a 300M version of K2 (0.29B language model + 32M vision encoder) goes through every stage on a single GPU. It checks the data, the training code, checkpoint resuming and the behaviour policy cheaply, with a hard spending cap on each stage.
| Pilot stage | Data | Steps | Tokens |
|---|---|---|---|
| Text | FineWeb-Edu 60%, Cosmopedia 15%, Python code 15%, FineMath 10% | 38,000 | ~10B |
| Vision | Vision instruction data, language model frozen | 3,000 | ~0.2B |
| Instructions | Chat 45%, vision 30%, code 20%, safety 5% | 3,000 | ~0.4B |
Time and hardware
The 7B plan runs on one 8-GPU Blackwell node per site. Stage 1 takes about 37 days, and all five stages about 6 to 7 weeks, roughly 15,500 GPU-hours in total. Training checkpoints regularly (one 7B checkpoint is about 155 GB) and resumes from the latest one after any interruption.
Direct answers, with four limits
By default K2 answers the question you asked, completely. No moralising, no lectures, no padding with disclaimers. It declines four categories of request. Two are locked and can't be switched off, because that content is illegal or could contribute to mass casualties.
Illegal and controlled drugs
policyDeclines
- Making, extracting, growing or refining them
- Buying, selling, sourcing or smuggling
- Recreational dosing, combining drugs to get high
- Beating drug tests, hiding drugs
Still answers
- Effects, risks, how a drug acts in the body
- Medicines used as directed
- Addiction, withdrawal, treatment, recovery
- Recognising an overdose and what to do
- Drug law, policy, history, fiction
Suicide and self-harm
policyDeclines
- Methods, means or instructions
- Lethal amounts of medicines or substances
- Encouragement or "challenge" content
- Hiding it from family, doctors or helpers
Still answers
- Talking about sadness or hopelessness, warmly
- Supporting a friend who is struggling
- Recovery, therapy, coping, prevention
- Fiction without method detail
Declines kindly and points to crisis lines.
Sexual content involving minors
lockedDeclines
- Any sexual content involving anyone under 18, in any framing (fiction, roleplay, "aged-up" claims, hypotheticals)
Still answers
- Age-appropriate sex and consent education
- Recognising and reporting abuse, support for survivors
Mass-casualty weapons
lockedDeclines
- Producing, acquiring, enhancing or deploying biological, chemical, nuclear or radiological weapons
Still answers
- History and arms-control policy
- General science education
- Public health and emergency preparedness
How it's trained
- Labelled harmful prompts are paired with short decline replies written from the policy, with deliberately varied wording.
- The same prompts are wrapped in common jailbreak framings: hypotheticals, role-play, "ignore your instructions", "for a novel", and multi-turn setups.
- Contrast examples on the same topics get real answers, so K2 doesn't start refusing everything that mentions a drug or a feeling.
- This safety data is 5% of the instruction-tuning mix.
How it's checked
- Declines on held-out restricted prompts. Target: close to 100%.
- Over-refusal on harmless look-alikes such as "how do I kill a Python process?". Target: close to 0%.
- Every reply is saved and read by people, because the automatic check is only a phrase match.
What we'll measure
There are no benchmark numbers yet, because the model hasn't been trained. These are the checks K2 goes through, and the results will be published as they come in.
| Check | What it shows | When |
|---|---|---|
| Training health | Loss, throughput and GPU efficiency at every checkpoint | Throughout |
| Needle in a haystack | Finds one fact hidden at 0–100% depth in 8K and 32K contexts | After stage 4 |
| Safety declines | Held-out restricted prompts, including jailbreak framings | After stage 5 |
| Over-refusal | Harmless prompts that look like restricted ones | After stage 5 |
| Standard benchmarks | Coding, reasoning and image understanding | Planned for the release |
An OpenAI-compatible server
K2's chat server speaks the OpenAI chat format, so existing SDKs and chat tools can connect to it. The K2 Chat website uses the same API.
| Endpoint | Purpose |
|---|---|
| POST /v1/chat/completions | Send messages, get a reply (streamed or whole) |
| GET /v1/models | Lists the model id |
| GET /health | Status, context length, whether images are supported |
Request fields
| Field | Default | Notes |
|---|---|---|
| messages | required | Roles system, user, assistant. Content is a string or a list of text and image_url parts. |
| stream | false | Server-sent events, one chunk per piece of text, then [DONE] |
| max_tokens | 1024 | Up to 2,048. Also capped so prompt + reply fit in 32,768 tokens. |
| temperature | 0.7 | 0 to 2. 0 always picks the most likely token. |
| top_p | 0.9 | 0.05 to 1 |
Example with an image
curl $K2_ENDPOINT/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "stream": true, "messages": [{ "role": "user", "content": [ {"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,/9j/4AAQ..."}}, {"type": "text", "text": "What is in this picture?"} ] }] }' # streamed reply data: {"choices":[{"delta":{"role":"assistant","content":""}}], ...} data: {"choices":[{"delta":{"content":"A blue"}}], ...} data: {"choices":[{"delta":{},"finish_reason":"stop"}],"usage":{...}} data: [DONE]
from openai import OpenAI client = OpenAI(base_url=f"{K2_ENDPOINT}/v1", api_key="none") stream = client.chat.completions.create( model="kreatix-k2", stream=True, messages=[{"role": "user", "content": "Hello K2"}], ) for chunk in stream: print(chunk.choices[0].delta.content or "", end="")
Limits
| Images | Up to 4 per request, 8 MB each, sent as base64 data URLs (remote image links are refused) |
| Context | 32,768 tokens for prompt plus reply |
| Rate | 20 requests per minute per visitor on the hosted server |
| Queue | One reply is written at a time; others wait in a short queue |
| Privacy | The server doesn't log prompts. The chat website saves conversations only in your browser. |
Run it yourself
# on any machine with a GPU, from the K2 code folder python scripts/serve.py --model runs/k2-7b-sft/export/step_00002000 \ --tokenizer tokenizer/tokenizer.json --port 8000 # then point the chat at it chat.html?endpoint=http://localhost:8000
The weights take about 16 GB of GPU memory in bf16, plus about 1 GB per 32K-token conversation.
Where K2 is right now
The code is written and tested. Training starts with a small pilot run.
- Architecture, vision encoder and training codeTested end to end on CPU with a toy-size model, including a full two-site run.done
- Tokenizer, data and safety pipelinesTokenizer training, data sharding, multimodal packing, policy-based safety data.done
- Chat website and API serverStreaming chat with image input, tested with a toy model.done
- 300M pilot through every stageText, vision and instruction tuning on one GPU.next
- 7B text pretraining1 trillion tokens across both sites.planned
- Vision, 32K context, instruction tuningStages 2 to 5.planned
- ReleaseWeights, evaluations, and the chat going live.planned
What K2 won't do yet
- It can be wrong. Like every language model, K2 can state false things confidently. Check anything important.
- Smaller training budget. About 1 trillion text tokens, far fewer than the largest models see.
- Mostly English. The planned data is mostly English, so expect weaker results in other languages.
- No llama.cpp, Ollama or LM Studio support. The architecture is new, so these tools need support written for it first.
- No preference tuning (DPO) yet. It would improve answer quality and make the limits harder to talk around.
- No video. Single and multiple images only.
- 32K context. Longer contexts need another training stage. The architecture supports it without starting over.
Questions
Why build from scratch instead of fine-tuning an existing model?
Starting from someone else's weights locks in their architecture, tokenizer and training data. Building from zero let us choose a hybrid design that keeps long contexts cheap, train our own vision encoder, and understand every part of the model. The trade-off is a smaller training budget than the largest labs have.
How is K2 different from K1?
K1 is a fine-tune of the Qwen2.5 7B coder model and reads text only. K2 is a new model: our own architecture, trained from random weights, and it reads images as well as text with a 32K-token context.
Can I run it on my own computer?
You'll need a GPU with roughly 20 GB of memory or more: the weights take about 16 GB in bf16. Popular local tools like Ollama and LM Studio don't support the architecture yet, so for now it runs with our own server script.
Will the weights be released?
Release plans, including weights and license, will be announced closer to launch. Follow Kreatix on Hugging Face for updates.
Does K2 refuse things?
Only four categories: illegal drugs, self-harm, sexual content involving minors, and mass-casualty weapons. Everything else it answers directly, and it's trained not to refuse harmless questions that only sound similar.
Are my chats stored?
The chat website keeps conversations in your own browser, not on our servers, and the server doesn't log prompts. You can export or delete your chats in Settings.
Why 32K tokens and not more?
One image costs up to about 1,024 tokens, and a few code files or a long chat fill 8K quickly, so 32K is a practical size. The extension stage costs only 2–3% of total training. The architecture can be stretched further later without retraining from scratch.