Nemotron-Labs-Diffusion-3B Β· ONNX q4f16 for the browser
nvidia/Nemotron-Labs-Diffusion-3B exported to one ONNX graph that runs on WebGPU with kohra, in-browser text diffusion. Try it in the kohra demo.
Size: 2.73 GB of weights in two files (onnx/model_kv_q4f16.onnx_data 2.00 GB, _data_1 0.74 GB).
4-bit RTN weights (MatMulNBits, symmetric, block 32), fp16 elsewhere, embeddings fp16.
How the graph decodes
The model writes 32-token blocks against a KV cache, as its own generate does. One graph serves both passes,
selected by an additive attention_mask input of shape [1, 1, L, past + L]:
- Denoise a block: an all-zero mask, so the block sees the whole cache and itself.
- Commit a finished block: a causal mask; keep
present_*as the new cache. The argmax of the last logit seeds the first token of the next block.
Inputs: input_ids [1, L], position_ids [1, L] (absolute), attention_mask, past_key_i / past_value_i
[1, 8, past, 128] for 26 layers. Outputs: logits [1, L, 131072] fp32, present_key_i / present_value_i.
Mask token id 100, end-of-turn id 11.
import { DiffusionLM } from 'https://cdn.jsdelivr.net/gh/NakliTechie/kohra@main/kohra.js';
const R = 'https://huggingface.co/naklitechie/Nemotron-Labs-Diffusion-3B-ONNX/resolve/main';
const lm = await DiffusionLM.from_pretrained({
model: `${R}/onnx/model_kv_q4f16.onnx`, tokenizer: 'naklitechie/Nemotron-Labs-Diffusion-3B-ONNX',
kvCache: true, maskId: 100n, eosId: 11n,
chatFormat: (t) => `<|im_start|>system\n<|im_end|>\n<|im_start|>user\n${t}<|im_end|>\n<|im_start|>assistant\n<think></think>`,
});
const { text } = await lm.generate('List three prime numbers greater than 50.', { maxNewTokens: 128, threshold: 0.9 });
Checks
- Export wrapper vs the upstream PyTorch forward: identical logits and cache in both modes (bf16, max difference 0.0).
- On a 66-token real text, the q4 graph picks the same next token as the bf16 model at 83% of positions; next-token accuracy 0.431 (bf16: 0.385).
- WebGPU in Chrome on an M4 Pro: six generations coherent; "three primes greater than 50" β 53, 59, 61 in 34
forward passes with
threshold: 0.9. - Not yet compared token for token with upstream
generate.
Export script: scripts/export_nemotron_kv.py.
Licence
Use is governed by the NVIDIA Nemotron Open Model License;
a copy is in LICENSE. Licensed by NVIDIA Corporation under the NVIDIA Nemotron Model License.
- Downloads last month
- 27
Model tree for naklitechie/Nemotron-Labs-Diffusion-3B-ONNX
Base model
nvidia/Nemotron-Labs-Diffusion-3B