Instructions to use litert-community/Nemotron-3-Nano-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/Nemotron-3-Nano-4B with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli litert-lm run \ --from-huggingface-repo=litert-community/Nemotron-3-Nano-4B \ --prompt="Write me a poem"
- LiteRT
How to use litert-community/Nemotron-3-Nano-4B with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Nemotron-3-Nano-4B β LiteRT-LM
nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16 converted to the LiteRT-LM (.litertlm) format for on-device inference with Google's LiteRT-LM runtime. Requires litert-lm β₯ 0.15. To our knowledge this is the first Nemotron-3-Nano in LiteRT form.
A reasoning model (<think>, ChatML turns) on a three-kind hybrid stack: 21 Mamba2 selective-scan layers + 17 plain MLP layers + 4 grouped-query attention layers (42 total). Only the 4 attention layers keep KV (4096-token budget here), the mamba layers carry constant-size conv + SSM state, and the MLP layers carry no state at all β 50 state buffers in total (42 mamba, 8 KV), so memory stays nearly flat with context length.
| File | Recipe | Size |
|---|---|---|
Nemotron-3-Nano-4B_int8.litertlm |
int8 dynamic on linears + embedding (convs and the scan stay float); fp32 activations declared | 4.13 GB |
Geometry: hidden 3136, 40 query / 8 KV heads, mamba 96 heads Γ 80 dim (state 128, conv 4, 8 groups), vocab 131,072, untied embeddings.
Correctness
All numbers below were measured on this exact file (litert-lm 0.16.0, Apple M4 Max).
- 8-question sanity gate: 7/8 on CPU, 8/8 on GPU, non-degenerate on both. The single CPU miss is the rhyme-completion item β it answers "violets are purple" where the gate wants "blue"; the GPU run answers "blue". Every arithmetic, factual, and translation item is correct on both backends.
- Chat template is byte-equal to the source: the embedded Jinja matches the repo's
chat_template.jinjaexactly (10,504 / 10,504 bytes). Note the source repo'stokenizer_config.jsoncarries a different 10,497-byte copy; the bundle embeds the oneAutoTokenizeractually resolves. - Turn-end stop tokens are
<|im_end|>(id 11) alongside the exported id 2. - No spurious start token. The source tokenizer sets
add_bos_token: Falseand the template never renders a leading BOS, so the<s>the bundler would otherwise prepend is dropped β the on-device token stream matches the training stream. Honest note: at this scale the model is robust either way (the gate scores 7/8 with the token and 7/8 without, and greedy decoding in PyTorch is byte-identical on 2 of 3 probes), so this is a correctness-of-convention fix rather than a rescue.
Usage
# CPU
litert-lm run ./Nemotron-3-Nano-4B_int8.litertlm --prompt "What is the capital of France? Answer in one word."
# GPU β pass --cache no (see the honest note below)
litert-lm run ./Nemotron-3-Nano-4B_int8.litertlm --backend gpu --cache no --prompt "..."
The bundle carries the tokenizer and the stock Nemotron-3-Nano chat template. Seven prefill signatures (1024/256/64/16/4/1 + decode) are exported so the runtime picks tight chunks.
Performance
litert-lm benchmark <file> -p 256 -d 256 --runs 3 --cache no, litert-lm 0.16.0, Apple M4 Max. Two independent runs:
| Backend | Prefill (256) | Decode | TTFT |
|---|---|---|---|
GPU (--cache no) |
803 / 792 tok/s | 83.3 / 82.4 tok/s | 0.33 s |
| CPU | 99.6 / 113.3 tok/s | 22.7 / 22.5 tok/s | 2.64 / 2.30 s |
Both figures per cell are the two runs, not a range estimate. GPU repeats within ~1.4%; CPU prefill spreads ~13%, partly because the host was not idle during these runs (another export was using the machine) β read the CPU column as an order of magnitude, not a precise figure. --cache no matters for more than tidiness here: with the compiled-graph cache the benchmark reports a much faster CPU prefill because it is not doing the same work.
Honest notes
- GPU requires
--cache noon this bundle. With the compiled-graph cache enabled,litert-lm run --backend gpufails with WebGPUInvalid BindGroupvalidation errors, and an 8-question sweep through the Mac verify harness returns token soup (0/8). The same file with--cache noanswers 8/8. Measured as a one-variable comparison β same runner, same file, cache flag flipped β so the cache path is where it goes wrong; the root cause is not isolated further here. - Not measured on a phone yet. The desktop numbers above are Mac-only. A 4B of this shape did not fit an 8 GB Android phone when the sibling Nemotron-H-4B was measured, so expect to need a higher-RAM device; that is an expectation carried over from a different bundle, not a measurement of this one.
- It is a reasoning model. Answers arrive after a
<think>block, so give it a token budget that fits the thought (the gate above used 3200). - int8 is applied to linears and the embedding only; the convolutions and the selective scan stay float, which is what keeps the hybrid state numerically sane.
Conversion notes
Converted with litert-torch plus a hybrid-cache patch. One command, no per-model work β the reproduction script, the patch, and the full measurement record are in hf-to-litertlm:
python scripts/convert.py nvidia/NVIDIA-Nemotron-3-Nano-4B-BF16
Two things that route this model correctly and are worth knowing if you convert your own:
auto_mapin a config is not proof of remote code. This repo declaresauto_map, but transformers registersnemotron_hnatively, so withouttrust_remote_codethe library implementation loads and the repo's Python is never imported. A converter that refuses onauto_mapalone will refuse this model for no reason.- β₯3B exports use a reduced 7-signature prefill ladder. Every exported signature costs engine RAM whether or not it is called, and a 4B hybrid with the full 11-signature ladder is exactly the shape that trips memory limits at GPU program init.
Conversion took 1645 s on an M4 Max. See REPRODUCE.md for the Nemotron-H family recipe and the measurements behind every claim on this card.
- Downloads last month
- 11
Model tree for litert-community/Nemotron-3-Nano-4B
Base model
nvidia/NVIDIA-Nemotron-Nano-12B-v2-Base