15 Downloads Updated 1 week ago
ollama run brnpistone/NVIDIA-Nemotron-3-Nano-30-AgentCoder-q4-k-m
Updated 1 week ago
1 week ago
e9beb509c841 Β· 25GB
Nemotron-3-Nano-30B-A3B-AgentCoder-Q4-K-M is a quantized post-trained version of NVIDIAβs Nemotron-3-Nano-30B-A3B, optimised for agentic behaviour in multi-turn, tool-calling conversations.
Unlike a supervised fine-tune, this model was trained with Group Relative Policy Optimization (GRPO) under Reinforcement Learning from AI Feedback (RLAIF): for every conversational decision point the policy samples a group of candidate continuations, an LLM judge scores each against a rubric, and the advantage is computed relative to the group mean β so no reward model and no value network are trained.
The chat template renders tools with <tool_call> / <function=β¦> / <parameter=β¦> tags. Pass the schemas through apply_chat_template(..., tools=[...]) rather than describing them in the system prompt, so the rendering matches what the model was trained on.
generation_config.json declares eos_token_id: [2, 11] β </s> and <|im_end|>. The tokenizerβs eos_token is <|im_end|> (id 11) and the chat template ends turns with it, while config.json still carries the base repoβs scalar eos_token_id: 2 (and pad_token_id: 0). Prefer the values in generation_config.json; dropping id 11 makes the model generate past the end of its answer.<think> blocks. nano_v3_reasoning_parser.py is included for servers that separate reasoning from the final answer.Reward model (RLAIF)
- Judge: moonshotai/Kimi-K3
- Rubric-scored 0β10, normalised to 0β1; rewards evidence gathering, correct tool choice, root-cause reasoning and verification, and penalises speculation, wrong-tool calls and symptom patching
- Unscorable completions (content filter, malformed verdict) are excluded from the group baseline rather than scored zero β 0.31 % of samples over the run
- Judge critiques were logged per completion, giving a per-step audit trail of why a trajectory scored as it did
GRPO parameters
- Generations per prompt (group size): 8
- Beta (KL coefficient): 0.01
- Loss type: dapo
- Reward scaling: group (unit variance within each group)
- Sampling temperature: 1.0
- Max completion length: 640 tokens (reference answers: p50 185, p95 456), truncated completions masked out of the loss
Training parameters
- Learning rate: 4.0e-6, cosine schedule with a 40 % floor
- Warmup steps: 46
- Per-device batch size: 2 Γ 16 GPUs Γ gradient accumulation 4 = 128 completions (16 prompts) per step
- Epochs: 2 β 460 optimiser steps
- Max grad norm: 0.5, weight decay 0.01
- LoRA: rank 64, alpha 128, dropout 0.1, applied to attention (q/k/v/o_proj), the Mamba input projection (in_proj) and the MoE shared expert (up_proj, down_proj)
- Trainable parameters: 45,436,928 / 31,668,811,200 (0.1435 %)
- Precision: bf16, FSDP full-shard with NemotronHBlock wrapping and activation checkpointing
- Attention: kernels-community/flash-attn3
- Hardware: 2 Γ ml.p5.48xlarge (16 Γ H100 80 GB), 26 h 32 m of training (27 h billable end-to-end)
Note on LoRA targets. The 128 routed experts are 3-D stacked parameters and cannot be reached by LoRA, so only the shared expertβs
up_proj/down_projare adapted.out_projandconv1dare rejected by PEFT β₯ 0.20.0 for Mamba architectures and are therefore excluded.Note on the KL coefficient. An earlier run of this recipe used
beta: 0.04and a peak learning rate of1.68e-6. Its policy KL settled at ~0.006 by step 4 and never moved again, the reward gain stalled halfway through, and the final improvement was only +6.1 %. Lowering beta to0.01, raising the peak LR to4.0e-6and lifting the cosine floor from 10 % to 40 % is what produced the results below β the KL ceiling, not the data volume, was the binding constraint.
reasoning_content and tool_calls preserved alongside content so tool-calling turns are not flattened awayObjective - Improve tool-selection accuracy and multi-turn trajectory quality - Reduce speculation and symptom patching in favour of evidence gathering
Outcome (measured on all 58,880 sampled completions) - Mean judge reward rose from 0.4121 (first 10 % of steps) to 0.6184 (final 10 %), +50.1 %, Welch t = 52.7, p < 10β»Β³β°β°. A regression across every individual completion confirms the trend (slope +5.0 Γ 10β»β΄ per step, r = 0.30) - Both capability and consistency improved. Best-of-8 sampling rose 0.648 β 0.741 (+14.5 %, p = 6 Γ 10β»Β³β΅) and mean-of-8 rose 0.412 β 0.618 (+50.3 %, p = 2 Γ 10β»ΒΉΒ²β΄). The larger share of the gain is consistency β the model became far more likely to produce a good trajectory on any single sample β but unlike the earlier low-LR run, peak achievable quality moved as well - The distribution shifted, not just the mean: median reward 0.350 β 0.650; the share of completions scoring below 0.25 collapsed from 26.3 % to 3.7 %, while the share above 0.70 grew from 15.5 % to 39.3 % - Runaway generations were trained away: over-long completions fell from 22.8 % to 4.4 % and mean completion length from ~1,430 to ~850 characters, with reward rising at the same time β concision, not truncation of useful content. Length remains the single strongest negative correlate of reward (r = β0.55) - Policy KL from the reference model rose from ~0.005 to ~0.047, roughly 7Γ the level the earlier over-anchored run reached, confirming the policy genuinely moved - Group signal stayed viable to the end: only 0.27 % of groups had zero within-group variance and 1.2 % of completions carried a negligible advantage. Within-group reward sd did narrow from 0.172 to 0.111 and token entropy from 0.83 to 0.66, which is the expected signature of a sharpening policy and the practical limit on adding further epochs at this group size
Scope of these numbers. All figures above are scored by the same LLM judge that produced the training reward, on the training prompts. They demonstrate that the optimisation worked; they are not a held-out benchmark. An independent evaluation on the 334 validation decision points is not included in this release.
Hybrid Mamba-2 / attention / MoE (NemotronHForCausalLM, model_type: nemotron_h).
| Property | Value |
|---|---|
| Total parameters | 31.6 B (~3 B active per token) |
| Blocks | 52 β 23 Mamba-2 (linear_attention), 23 MoE, 6 full_attention |
| Hidden size | 2688 |
| MoE | 128 routed experts, 6 active per token, 1 shared expert |
| Attention | 32 heads / 2 KV heads (GQA), head dim 128 |
| Mamba-2 | 64 heads Γ 64 head dim, SSM state 128, conv kernel 4 |
| Vocabulary | 131,072 |
| Context length | 262,144 (~256 K) tokens |
| Precision | bfloat16 |
| Tied embeddings | No |
| Artifact | 47 safetensors shards, ~63 GB (59 GiB) |
generation_config.json; a single eos_token_id is not sufficient for this modelmamba-ssm and causal-conv1d built against your PyTorch version, or expect a substantial throughput penalty