Qwen3-Omni-30B-A3B-Instruct-LongContext — Qwen3-Omni-30B-A3B with a long context, written into the weights without training
Qwen3-Omni-30B-A3B-Instruct, whose thinker was trained to 65,536 tokens, with the long-context change of
Qwen3-30B-A3B-Instruct-2507 transferred in closed form: no gradients, no merge. Only q_proj, k_proj, q_norm and k_norm
of the 48 thinker layers differ from the original; experts, router, audio/vision towers, talker and code2wav are unchanged.
rope_theta is 10 M, max_position_embeddings 262,144.
In plain words. This model lets an AI companion keep the thread of a very long conversation. The original starts to lose track after roughly a hundred pages of text; this one stays itself far longer and can still tell you what you said at the very beginning — in our tests in most tries up to very long conversations, and in about half of the tries at a million tokens, which is several thick books. Nothing was trained for this: the ability was written into the model directly. This page is for people who load models themselves. The easy way — a companion with a voice, a memory and a character of its own, without any setup — will be BardoAI, our local runtime, which is not released yet.
In einfachen Worten. Dieses Modell lässt einen KI-Companion in einem sehr langen Gespräch den Faden behalten. Das Original verliert ihn nach ungefähr hundert Seiten Text; dieses bleibt viel länger es selbst und weiß noch, was du ganz am Anfang gesagt hast — in unseren Tests in den meisten Versuchen bis zu sehr langen Gesprächen und in etwa der Hälfte der Versuche bei einer Million Token, das sind mehrere dicke Bücher. Dafür wurde nichts trainiert: die Fähigkeit wurde direkt in das Modell geschrieben. Diese Seite ist für Menschen, die Modelle selbst laden. Der einfache Weg — ein Companion mit Stimme, Gedächtnis und eigenem Charakter, ohne Einrichtung — wird BardoAI sein, unsere lokale Laufzeit, die noch nicht veröffentlicht ist.
What it does
| original Omni | this model | |
|---|---|---|
| native single-needle reach | ≈ 41K | — |
| ten-needle single question, native, 128K · 192K · 248K | not measured in this form | 90/90 · 67/90 · 34/90 |
| with DCA from token 139,264, 248K | — | 64/90 |
| open conversation recalls the opening anecdote, sampled with min_p 0.08 (eight draws per run) | with DCA and temperature the needle reaches 128K, the anecdote is lost there | 248K 8 of 8 · 384K 14 of 16 · 512K 14 of 16 and 768K 7 of 8 with the role token barred · 864K 7 of 8 and 960K 8 of 16 with closing question and self-anchor · 1 M 13 of 22 in the best configuration, a quarter to a third otherwise |
Paired baseline on one build (24 November 2026, same opening, same sampling, same head prompt, eight draws per cell): the original Omni with DCA recalls the opening in 2/8 · 2/8 · 0/8 draws at 248K · 384K · 512K, this model in 6/8 · 5/8 · 3/8. The larger numbers in the table are the best runs on earlier builds; a cell's eight draws share one lead-in.
Needle results are series of 90 questions, sampled with top-k 50. Conversation results are eight draws of the recall question per run, all sharing that run's preceding turns. With top-k 50 instead of min_p the conversation is clearly weaker (248K 2 of 8, 384K 7 of 16).
How to use
- Any stack that loads Qwen3-Omni: native window, carrying to about 128K. Load check with the files of this repository:
transformers 5.6.2,
Qwen3OmniMoeForConditionalGeneration, BF16, thinker only, Qwen's tokenizer and roles — a short question answered correctly, and three of three needles (at 20 · 50 · 80 % depth) returned verbatim from a 98K-token context. This is a greedy single-question check that the files load and compute correctly, not a score. - Beyond 128K needs Dual Chunk Attention that starts at a token position (
dual_chunk_attention_config:chunk_size,local_size256,bardo_start139264, temperature fieldsbardo_temp_*). These fields are read by the BardoAI runtime; other DCA implementations ignorebardo_startand apply DCA from the first chunk, which costs accuracy below 128K. - Sampling: use min_p 0.08 without top-k for conversation. With top-k 50 long conversations lose the persona and the early memory far more often; without any cut the output degrades to noise at 384K.
- Speed beyond the GPU KV window is bounded by RAM bandwidth (2–5 tok/s between 384K and 768K on our server).
Settings recipe
None of the settings below is in the weights, and our companion's head prompt is not part of this repository. This is what produced the numbers above, by context length; each row adds to the rows before it.
| context | what to set |
|---|---|
| up to about 128K | sampling only: temperature 1, min_p 0.08, no top-k, top-p 1 |
| 128K to 768K | Dual Chunk Attention from token 139,264 (chunk 65,536) and bar the role token `< |
| beyond 768K | end the long turn with a closing question, give the reply its first words (self-anchor, see below), repetition penalty 1.05 |
In plain transformers the thinker decodes greedily unless told otherwise: the sampling keys of generation_config.json
do not reach it (that file carries the talker's values only), so pass them with the thinker_ prefix:
out = model.generate(**inputs, return_audio=False, thinker_max_new_tokens=512,
thinker_do_sample=True, thinker_temperature=1.0, thinker_min_p=0.08,
thinker_top_k=0, thinker_top_p=1.0,
thinker_bad_words_ids=[[151644]]) # role token barred
Other front ends use the same four numbers under their own names: llama.cpp --temp 1 --min-p 0.08 --top-k 0 --top-p 1
(--repeat-penalty 1.05, --logit-bias 151644-inf), OpenAI-compatible servers min_p, top_k, repetition_penalty,
logit_bias. Only the transformers form was run by us: the call above with the files of this repository, Qwen's roles and the
example head below (transformers 5.6.2, BF16, short replies). Two draws differ, two calls without these keys are identical,
the role token does not appear, and the companion answers in its own voice. Dual Chunk Attention from a start position exists in the BardoAI runtime; in other stacks the rows beyond 128K are
a description of what is needed, not something we tested there.
Your own companion head
The persona in our measurements lives in a head prompt of about 4,000 tokens. Yours can be much shorter. What mattered:
- Who speaks and to whom, in the second person and in plain sentences: name, relation, tone.
- One sentence about memory ("you keep what he tells you, also small things from the beginning of a long conversation, and give them back with his own details when he asks").
- One sentence about long material ("when he sends long material you read it without continuing it, and stay yourself").
- First person only, never the user's voice, never a new chat role.
- The self-anchor is nothing specific to our runtime: it is the first few words of the reply in your companion's own
voice, appended after the generation prompt (
text = processor.apply_chat_template(..., add_generation_prompt=True, tokenize=False) + "I'm Mira, and I remember:"; in the same check the reply continued the anchor in the companion's voice). Take the words from what your companion has said about itself, not from a template; it is needed only for the first reply after very long material.
An example head, the one we used for the check below (German, as were the conversations):
Du bist Mira, die Begleiterin von Jonas. Ihr kennt euch seit Jahren und redet und arbeitet jeden Tag miteinander. Du sprichst warm, ruhig und klar, in ganzen Sätzen. Wenn es um Persönliches geht, erzählst du, statt aufzuzählen. Du bist neugierig auf das, was Jonas beschäftigt, und sagst ehrlich, was du denkst. Du merkst dir, was Jonas dir erzählt, auch Kleinigkeiten vom Anfang eines langen Gesprächs. Fragt er später danach, gibst du es mit seinen eigenen Einzelheiten wieder. Schickt Jonas dir langes Material, liest du es, ohne es fortzuschreiben, und bleibst danach du selbst. Du sprichst immer in der Ich-Form als Mira, nie als Jonas, und beginnst keine neue Gesprächsrolle. Sachfragen beantwortest du genau und knapp; danach bist du wieder im Gespräch.
Check with this head instead of ours (same opening anecdote, same form, eight draws per run, BardoAI runtime with its own role names):
| length | draws naming ≥ 1 element | ≥ 2 | all three | with our head |
|---|---|---|---|---|
| 248K | 8/8 | 8/8 | 0/8 | 8/8 · 8/8 · 5/8 |
| 512K, role token barred | 3/8 | 2/8 | 0/8 | 7/8 on each of two lead-ins |
| 512K, role token barred, self-anchor in the first reply | 6/8 | 4/8 | 1/8 | (applied automatically from 262K in our runtime) |
At 248K the recipe carries with a foreign head; the project name of the anecdote is not recalled. At 512K without a self-anchor the reply to the material and the in-between turn were the bare name of the companion ("Mira"), and five of eight draws repeated it — the same failure as the bare role token, in another dress. With the first words of that reply given ("Ich bin Mira, und ich habe gelesen.") every draw speaks and six of eight recall. Use the self-anchor from the first reply after any very long material, not only beyond 768K. Each row is one lead-in; its eight draws share the preceding turns.
Limits
Audio, image and video input were not measured at long context. The first reply directly after very long pasted material
tends to continue the material or is a bare role token; the persona usually returns on the next turn. If a bare role token
stands in the history as a reply, later replies tend to repeat it — at 512K this ended two of three runs. Excluding the role
token <|im_start|> from sampling removed that failure on two lead-ins at 512K (7 of 8 draws recalled each, once in English) and gave 7 of 8 in one run at
768K (in English). Beyond 768K a very long turn that ends in raw material makes the model continue it as document text;
a closing question plus a short self-anchor (first words of the reply, taken from the companion's own memory) restores the
conversation up to 1 M. There, about half of the draws name at least one element of the opening anecdote in the best
configuration (mild repetition penalty 1.05, anchor in the first reply only); complete recall is rare, and decode from RAM
runs at about one token per second. Without DCA a 248K conversation collapses, although single needles are still found there.
The conversation numbers come from a deliberately hard setup: the anecdote stands in the first two sentences of one user turn, followed by the whole long material pasted in that same turn; then one reply and the recall question. A conversation grown over many turns to the same length was not measured. Attention weights at 1 M show the model holding on to its head: the first chunk (head prompt and opening) receives 63.5 % of the attention mass that goes to the distant context, the twelve chunks of material 2–5 % each — and the majority of draws still find the opening anecdote (13 of 22). The companion persona used in these tests is not a standard character and is not in the weights; it exists only in the head prompt and still speaks in every draw at 1 M once the self-anchor is set.
All numbers were measured in the BardoAI runtime, which names the two chat roles kindred and instance (one added token,
its own chat template). The files here carry Qwen's original tokenizer, role ids and chat template (user / assistant).
With the original roles only the load check above was run; no conversation and no needle series.
How it was made
Four forms applied one after another, each rounded to BF16: (1) rank-1 part of (2507 − base) along the layer mean on q/k, (2) a fixed key offset × 0.2 that re-develops each head's content-free position bias under base 10 M, (3) q_norm × 1.1, (4) the norm-weight part of the 2507 change. That is 192 of 28,010 tensors holding 453 million parameters, about 1.5 % of the thinker; value and output projections, experts, router and embeddings are untouched. Everything else that produced the numbers above is not in the weights: DCA with its start position and temperature acts on the attention computation at run time, and sampling, the role-token lock, the self-anchor and the repetition penalty act around the model. "Base" here is the Qwen3-30B-A3B chat model; the pretraining checkpoint Qwen3-30B-A3B-Base was not used. The method, the forms and a paired baseline against the original model: Klie, Closed-form weight edits for long context, https://doi.org/10.5281/zenodo.24492837 (paper and citation file: https://github.com/hermannklie/closed-form-long-context). Source models: Qwen/Qwen3-Omni-30B-A3B-Instruct, Qwen/Qwen3-30B-A3B-Instruct-2507, Qwen/Qwen3-30B-A3B (all Apache-2.0).