CoolFace
Modelpublic

br1-pist/NVIDA-Nemotron-3-30B-Nano-AgentCoder

sourceHugging Faceotherupdated 16d agoView on Hugging Face
0likes160downloads
Model Card

๐Ÿง  Nemotron-3-Nano-30B-A3B-AgentCoder

A GRPO/RLAIF Post-Trained Model for Multi-Turn Agent Trajectories and Tool Calling


Model Description

Nemotron-3-Nano-30B-A3B-AgentCoder is a 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.

Highlights

  • โ€”๐Ÿงฐ Trained on decision points, not whole dialogues: each training row is a real conversation state plus the next assistant turn, so the reward targets the choice the agent actually has to make
  • โ€”๐Ÿ“ˆ Mean judge reward improved +50.1 % over the run (0.412 โ†’ 0.618), with both single-sample quality and best-of-8 capability rising
  • โ€”โœ‚๏ธ Runaway generations largely eliminated: the share of over-long completions fell from 22.8 % to 4.4 %, and mean completion length dropped ~40 %
  • โ€”โš–๏ธ DAPO loss with group-relative reward scaling, which removes the length bias of vanilla GRPO
  • โ€”๐Ÿ”ฌ Reward came from a rubric-scored LLM judge covering evidence gathering, tool selection, root-cause reasoning and verification
  • โ€”๐Ÿชถ Parameter-efficient: 0.1435 % of weights trained (45.4 M of 31.6 B), so the base model's general capability is preserved

๐Ÿš€ Direct Use

  • โ€”โœ… Multi-turn agent loops where the model must decide between answering, calling a tool, and reacting to tool output
  • โ€”โœ… Tool / function calling in coding, data-management, and shell-execution contexts
  • โ€”โœ… General reasoning and Q&A inherited from the base model

โš ๏ธ Out-of-Scope Use

  • โ€”โŒ Highly sensitive or confidential data
  • โ€”โŒ Domains requiring expert-level specialisation or certification
  • โ€”โŒ Tasks where full explainability is mandatory
  • โ€”โŒ Autonomous execution of irreversible actions without human review

๐Ÿ’ป Getting Started

This architecture ships custom modelling code, so trust_remote_code=True is required. The Mamba-2 layers also need mamba-ssm and causal-conv1d compiled against your installed PyTorch โ€” without them transformers falls back to a much slower pure-PyTorch path.

python
from transformers import AutoModelForCausalLM, AutoTokenizer

model_name = "br1-pist/Nemotron-3-Nano-30B-A3B-AgentCoder"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    dtype="auto",
    device_map="auto",
    trust_remote_code=True,
)

messages = [{"role": "user", "content": "List the files in /var/log, then summarise the largest one."}]
text = tokenizer.apply_chat_template(
    messages, tokenize=False, add_generation_prompt=True
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)

generated_ids = model.generate(**model_inputs, max_new_tokens=1024)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))

Tool calling

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.

Serving notes

  • โ€”Stop tokens: 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.
  • โ€”Padding: generation_config.json sets pad_token_id: 11, matching the tokenizer's pad_token of <|im_end|>.
  • โ€”No `vocab.json`: the tokenizer uses the TokenizersBackend and loads entirely from tokenizer.json. This is expected, not a missing file.
  • โ€”Sampling: the export inherits do_sample: true, temperature: 1.0, top_p: 1.0. For evaluation or structured output, set decoding explicitly rather than relying on these defaults.
  • โ€”Reasoning traces: the model emits <think> blocks. nano_v3_reasoning_parser.py is included for servers that separate reasoning from the final answer.

๐Ÿง  Training Details

Phase 1 โ€” Post-Training: RLAIF with Group Relative Policy Optimization (GRPO)

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_proj are adapted. out_proj and conv1d are 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.04 and a peak learning rate of 1.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 to 0.01, raising the peak LR to 4.0e-6 and 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.
GRPO Data
  • โ€”3,686 training and 334 validation decision points, extracted from 800 source conversations (4,020 unique states before splitting)
  • โ€”Every context/next-assistant pair in the winning trajectory becomes one row, with reasoning_content and tool_calls preserved alongside content so tool-calling turns are not flattened away
  • โ€”Train/validation split is grouped by root request, giving 0 overlap between the two sets
  • โ€”Domains: coding, general Q&A, data management, shell execution

Objective

  • โ€”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.

๐Ÿ–ฅ๏ธ Technical Specifications

Model Architecture

Hybrid Mamba-2 / attention / MoE (NemotronHForCausalLM, model_type: nemotron_h).

PropertyValue
Total parameters31.6 B (~3 B active per token)
Blocks52 โ€” 23 Mamba-2 (linear_attention), 23 MoE, 6 full_attention
Hidden size2688
MoE128 routed experts, 6 active per token, 1 shared expert
Attention32 heads / 2 KV heads (GQA), head dim 128
Mamba-264 heads ร— 64 head dim, SSM state 128, conv kernel 4
Vocabulary131,072
Context length262,144 (~256 K) tokens
Precisionbfloat16
Tied embeddingsNo
Artifact47 safetensors shards, ~63 GB (59 GiB)

Compute Infrastructure

Hardware

  • โ€”GPU: 16 ร— NVIDIA H100 (80 GB VRAM), 2 ร— ml.p5.48xlarge
  • โ€”System RAM: 2 TiB per node

Software

  • โ€”Python: 3.12
  • โ€”PyTorch: 2.13.0 + CUDA 13.0
  • โ€”Transformers: 5.15.1
  • โ€”TRL: 1.10.0, PEFT: 0.20.0
  • โ€”Libraries: mamba-ssm, causal-conv1d, triton, accelerate, safetensors, bitsandbytes, datasets

๐Ÿงพ Citation

BibTeX

bibtex
@article{nemotron3-nano-30b-a3b-agentcoder,
  title={Nemotron-3-Nano-30B-A3B-AgentCoder: Improving Agent Trajectories with GRPO and RLAIF},
  author={Bruno Pistone},
  year={2026},
  journal={Hugging Face Model Hub}
}

APA

Bruno Pistone. (2026). Nemotron-3-Nano-30B-A3B-AgentCoder: Improving Agent Trajectories with GRPO and RLAIF. Hugging Face Model Hub.

๐Ÿงญ Recommendations

  • โ€”Serve with the stop-token list from generation_config.json; a single eos_token_id is not sufficient for this model
  • โ€”Install mamba-ssm and causal-conv1d built against your PyTorch version, or expect a substantial throughput penalty
  • โ€”Pass tool schemas through the chat template rather than the system prompt, matching the training-time rendering
  • โ€”A gap remains between single-sample and best-of-8 quality (0.618 vs 0.741), so best-of-n sampling with a verifier still adds measurable headroom where latency allows
  • โ€”Tool-use accuracy degrades as task complexity grows; keep a human in the loop for irreversible actions
  • โ€”Avoid using this model for confidential or safety-critical applications

<p align="center"> <b>๐Ÿง  Nemotron-3-Nano-30B-A3B-AgentCoder โ€” created by Bruno Pistone</b><br> <i>Multi-turn agent trajectories, refined with GRPO and rubric-based AI feedback</i> </p>