28 1 week ago

A Quantized, Fine-Tuned Model for Enhanced Tool Calling, Code Generation, and Reasoning

tools thinking
ollama run brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m

Details

1 week ago

55b27af4e342 · 24GB

nemotron_h_moe
·
31.6B
·
Q4_K_M
{{- define "value" -}} {{- if eq (printf "%T" .) "string" -}} {{ . }} {{- else if eq (printf "%T" .)
{ "stop": [ "<|im_end|>", "</s>" ], "temperature": 1, "top_p": 0.95

Readme

Nemotron-3.5-Lightning-30B-AgentCoder-Q4-K-M

Q4_K_M GGUF edition of a GRPO/RLAIF post-trained Nemotron 3.5 Lightning model, packaged for Ollama.

Model description

This model adapts NVIDIA’s Nemotron 3.5 Lightning for agentic coding, multi-turn conversations, and tool calling. The source model was post-trained with Group Relative Policy Optimization (GRPO) using an LLM judge for Reinforcement Learning from AI Feedback (RLAIF).

Each training example is a decision point in a recorded conversation. The policy generates candidate next assistant turns, and the judge scores them against a rubric and reference answer. The objective rewards evidence gathering, appropriate tool selection, root-cause reasoning, and verification.

The training process uses recorded tool responses. It does not execute tools or optimize complete interactive task rollouts. LoRA updates attention projections, Mamba input projections, and shared-expert projections; fused routed-expert parameters remain frozen.

This Ollama edition is text-only and uses Q4_K_M weight quantization. All training metrics below refer to the source fine-tune before quantization. No Q4-versus-BF16 accuracy or throughput benchmark is reported.

Run with Ollama

Use a current Ollama release. The published package records REQUIRES 0.32.9.

ollama pull brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m
ollama run brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m

HTTP API

curl http://localhost:11434/api/chat \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m",
    "messages": [
      {"role": "user", "content": "Explain how to investigate a failing Python unit test."}
    ],
    "think": false,
    "stream": false
  }'

The answer is returned in message.content. Set think to true to request reasoning, which Ollama exposes in message.thinking.

Tool calling

Pass function schemas through Ollama’s tools field:

pip install -U ollama
from ollama import chat

response = chat(
    model="brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m",
    messages=[{"role": "user", "content": "List the files in /tmp."}],
    tools=[
        {
            "type": "function",
            "function": {
                "name": "list_files",
                "description": "List the files in a directory.",
                "parameters": {
                    "type": "object",
                    "properties": {"path": {"type": "string"}},
                    "required": ["path"],
                },
            },
        }
    ],
    think=True,
)

for call in response.message.tool_calls or []:
    print(call.function.name, call.function.arguments)

The application executes the requested function, appends the assistant message and corresponding tool results, and calls the model again. Ollama handles the prompt formatting and parses the model’s <tool_call> / <function=...> / <parameter=...> format into structured calls.

Serving configuration

The published package specifies:

Setting Value
Temperature 1.0
Top-p 0.95
Stop strings <\|im_end\|> and </s>
Output parser nemotron-3.5-nano
Configured context limit 262,144 tokens
GGUF quantization Q4_K_M

Other sampling options use the Ollama runtime’s defaults unless overridden in a request. The configured context limit is not the context automatically allocated by Ollama; use options.num_ctx to request a particular context length and allow memory for its runtime buffers.

The source generation configuration has EOS IDs 2 (</s>) and 11 (<|im_end|>). Both stop strings are included in the Ollama package.

Current template selection

The published manifest currently selects renderer: nemotron-3-nano, paired with parser: nemotron-3.5-nano. It also stores a full Lightning Go TEMPLATE.

The built-in renderer takes precedence over that stored template. Consequently, the published package currently uses the Nano 3 input renderer, even though its parser and stored template are Lightning-specific. The presence of an explicit TEMPLATE in ollama show --modelfile does not establish that it is active.

To align a future package with Lightning-specific input formatting, select the nemotron-3.5-nano renderer, or configure the model to use its explicit template without a built-in renderer override. The settings above describe the currently published package; this documentation review did not change it.

Inspect the installed model with:

ollama show brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m
ollama show brnpistone/Nemotron-3.5-Lightning-30B-AgentCoder-q4-k-m --modelfile

Quantized package and architecture

The published Ollama manifest contains one model GGUF, plus its template, parameters, and configuration metadata.

Package property Value
Model filename nvidia-nemotron-3.5-lightning-30b-agentcoder-q4-k-m.gguf
Model-file size 24,271,919,552 bytes: 24.272 GB / 22.605 GiB
Quantization Q4_K_M
GGUF family nemotron_h_moe
Parameter size reported by the package 31.6B
Inputs / outputs Text / generated text and tool calls
Vision projector None

Allow additional RAM/VRAM for context and inference buffers beyond the weight-file size.

The following architecture values come from the published source fine-tune:

Property Value
Transformers architecture NemotronHForCausalLM, model_type: nemotron_h
Parameters reported by the source weight index 31,577,937,344, approximately 31.58B
Active parameters Approximately 3B per token, following the base A3B architecture
Core backbone 52 blocks: 23 Mamba-2, 23 MoE, 6 attention
Hidden size 2,688
MoE 128 routed experts, 6 selected per token, 1 shared expert
Attention 32 query heads / 2 KV heads, head dimension 128
Mamba-2 64 heads × 64 head dimension, SSM state 128, convolution kernel 4
Vocabulary 131,072
Configured context limit 262,144 tokens
Tied embeddings No

The source configuration retains MTP-related fields, but its published weight index contains no mtp.* tensors. This card makes no claim of MTP or speculative-decoding acceleration for the quantized package.

Source fine-tuning: before quantization

The values below were checked against the completed Lightning job’s submitted args.yaml, saved adapter configuration and tensor headers, trainer_state.json, and train_results.json. The job’s exported configuration, generation settings, and weight index match the published Hugging Face fine-tune.

Run property Verified value
Training job nemotron35-lightning-30b-grpo-20261121083220
Dates November 21–23, 2026
Region / status us-east-1 / Completed
Hardware 2 × ml.p5.48xlarge, totaling 16 × H100 80 GB
Method GRPO with RLAIF, DAPO loss, and group reward scaling
Judge Kimi K3.1 through Amazon Bedrock
Judge score Rubric score from 0 to 10, normalized to 0–1
Epochs / optimizer steps 2 / 460
Trainer runtime 139,046.17 seconds, approximately 38 h 37 min 26 s
SageMaker-reported training / billable duration 140,532 seconds, approximately 39 h 2 min 12 s

The judge rewards gathering relevant evidence, choosing tools with workable arguments, identifying root causes, and verifying results. It penalizes unsupported claims, wrong-tool calls, describing an action without taking it, symptom-only fixes, and padding. It scores the next assistant turn in context.

GRPO and optimization

Parameter Value
Generations per prompt 8
Per-device training batch size 2
Gradient accumulation 4
Effective optimizer-step batch 128 completions / 16 prompts across 16 GPUs
Maximum completion length 768 tokens
Truncated completions Masked out of the policy loss
Sampling temperature 1.0
KL coefficient (beta) 0.02
Loss / reward scaling dapo / group
Learning rate 1.2e-6
Scheduler / warmup Cosine / 23 steps
Optimizer adamw_torch_fused
Weight decay / maximum gradient norm 0.01 / 0.5
Seed 42
Precision / attention BF16 / PyTorch SDPA
Parallelism FSDP2 hybrid sharding: 8-way sharding within each node, replication across 2 nodes
Wrapped block class NemotronHBlock
Activation checkpointing Enabled through FSDP
Evaluation strategy no

LoRA

  • Rank / alpha / dropout: 32 / 64 / 0.0.
  • Targets: mixer.q_proj, mixer.k_proj, mixer.v_proj, mixer.o_proj, mixer.in_proj, shared_experts.up_proj, and shared_experts.down_proj.
  • Trainable adapter parameters: 22,718,464, verified from 186 tensors in the saved LoRA adapter.
  • Frozen routed experts: The recipe targets module-based projections; it does not adapt the fused routed-expert parameter tensors.
  • Export: Adapter weights were merged into the BF16 source model before GGUF conversion and quantization.

A small trainable fraction does not, by itself, demonstrate that general capability was preserved.

Training data

Split Decision points Distinct initial user requests
Training 3,686 468
Validation 334 51
Total 4,020 519

These counts were verified from the S3 datasets supplied to the Lightning job. There is no overlap in initial user-request content between the two splits.

Each row contains a serialized conversation in prompt, a reference next-turn answer, rejection_type, and turn_index. The histories include recorded assistant turns and tool responses.

The validation split was supplied, but automatic evaluation was disabled. No held-out score is reported for this run.

Recorded results

These are arithmetic means of the per-step values in the final trainer_state.json. “Early” means optimizer steps 1–46, and “late” means steps 415–460: the first and last 10% of the run.

Metric Early mean Late mean
Judge reward, 0–1 0.6145 0.6297
Completion length, tokens 260.49 253.86
Clipped completion fraction 9.630% 8.781%
Token entropy 0.5740 0.5674
Policy KL 0.005034 0.006284

The late-window reward was 0.0152 higher, a 2.47% relative increase. Mean logged reward across all 460 steps was 0.6326. These summaries compare different training batches and do not constitute a controlled before/after evaluation.

Mean completion length decreased by 2.55%. The clipped fraction fell by 0.849 percentage points, from approximately 9.63% to 8.78%.

The largest logged KL was 2.3808 at step 402. Median KL across the run was 0.005330, and final-step KL was 0.007341. Final reported training loss was −0.003197. The per-step judge failure and timeout metrics were zero throughout the run.

These are source-model training diagnostics, scored by the same judge used to provide rewards. They do not establish independent coding or tool-use improvements, and they do not measure the effect of Q4_K_M quantization.

Training software

The submitted training requirements pinned PyTorch 2.13.0, Transformers 5.23.0, TRL 1.10.0, PEFT 0.21.3, and Accelerate 1.16.0. The SageMaker container tag was 2.13.0-cu133-amzn2023-sagemaker.

The CUDA training environment built mamba-ssm and causal-conv1d from pinned commits. Those are training-environment dependencies; Ollama serves the packaged GGUF through its own runtime.

Evaluation scope

No independent validation-set result, BF16-versus-Q4 accuracy comparison, or quantized throughput benchmark is included. The training metrics should not be presented as benchmark scores for this Ollama package.

Tool execution, checking results, and handling side effects belong to the calling application.