Text Generation
Transformers
Safetensors
English
Chinese
qwen3_5_text
veriloop
veriloop-coder
code
coding-agent
software-engineering
mathematical-reasoning
nvfp4
modelopt
tensorrt-llm
vllm
sglang
code-optimized
quantization
open-source
apache-2.0
qwen3_5
self-harness
harness-engineering
surface-host-adapter
evidence-binding
rollback
uncertainty-calibration
long-context
vertical-code-model
recursive-improvement
conversational
Instructions to use rodrigoramosrs/veriloop-coder-e2-nvfp4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rodrigoramosrs/veriloop-coder-e2-nvfp4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rodrigoramosrs/veriloop-coder-e2-nvfp4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("rodrigoramosrs/veriloop-coder-e2-nvfp4") model = AutoModelForCausalLM.from_pretrained("rodrigoramosrs/veriloop-coder-e2-nvfp4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use rodrigoramosrs/veriloop-coder-e2-nvfp4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rodrigoramosrs/veriloop-coder-e2-nvfp4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rodrigoramosrs/veriloop-coder-e2-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rodrigoramosrs/veriloop-coder-e2-nvfp4
- SGLang
How to use rodrigoramosrs/veriloop-coder-e2-nvfp4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "rodrigoramosrs/veriloop-coder-e2-nvfp4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rodrigoramosrs/veriloop-coder-e2-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "rodrigoramosrs/veriloop-coder-e2-nvfp4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "rodrigoramosrs/veriloop-coder-e2-nvfp4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rodrigoramosrs/veriloop-coder-e2-nvfp4 with Docker Model Runner:
docker model run hf.co/rodrigoramosrs/veriloop-coder-e2-nvfp4
File size: 6,862 Bytes
d53a0fe 137dbc8 907eff1 d53a0fe 137dbc8 d53a0fe 907eff1 d53a0fe 907eff1 e7145da d53a0fe cfceeaa f56be0b cfceeaa d53a0fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | ---
library_name: transformers
pipeline_tag: text-generation
license: apache-2.0
base_model:
- tsinghua-sigs-robot-lab/VeriLoop-E2
base_model_relation: quantized
language:
- en
- zh
tags:
- veriloop
- veriloop-coder
- code
- coding-agent
- software-engineering
- mathematical-reasoning
- nvfp4
- modelopt
- tensorrt-llm
- vllm
- sglang
- code-optimized
- quantization
- open-source
- apache-2.0
- qwen3_5
- self-harness
- harness-engineering
- surface-host-adapter
- evidence-binding
- rollback
- uncertainty-calibration
- long-context
- vertical-code-model
- recursive-improvement
---
<div align="center">
<h1>VeriLoop Coder E2 · NVFP4</h1>
<p><strong>Coding-Optimized Quantized Model (NVIDIA NVFP4)</strong></p>
<p>
<a href="https://huggingface.co/tsinghua-sigs-robot-lab/VeriLoop-E2">Original Model ↗</a>
·
<a href="https://github.com/rodrigoramosrs">GitHub</a>
·
Apache-2.0
</p>
</div>
---
## Overview
This repository contains an **NVFP4 quantization** of [VeriLoop E2](https://huggingface.co/tsinghua-sigs-robot-lab/VeriLoop-E2), an open 27B post-trained model built on **Qwen3.8-27B** for code, mathematics, and physics. Its core reasoning discipline is **VeriLoop-Governed Recurrence (VGR)**: candidate states are recursively proposed, externally checked, and retained only when the protected evidence state improves without regression.
Quantized by [Rodrigo Ramos](https://github.com/rodrigoramosrs).
## Quantization Approach
Produced with [NVIDIA Model Optimizer](https://github.com/NVIDIA/Model-Optimizer) using the canonical **`NVFP4_W4A4_WEIGHT_LOCAL_HESSIAN_CFG`** recipe: static per-block 4-bit weights (group size 16) + dynamic 4-bit activations, FP8 attention, local-Hessian calibration with MSE and fp8 scale sweep.
The `linear_attn` (Gated Delta Net) blocks and the self-attention projections ship in BF16 on purpose — matching validated official NVFP4 releases for this architecture family (which exclude `linear_attn*` per layer) and the widely-deployed MLP-only NVFP4 pattern. Only the MLP blocks (gate/up/down) are NVFP4. Embeddings, `lm_head` and small projections stay BF16 per the recipe.
Calibration ran on **512 samples × 512 tokens** (262144 tokens) of competitive-programming code from `nvidia/Nemotron-Competitive-Programming-v1`, keeping quantization faithful on the distributions that matter most for coding tasks.
The result retains the original model's strong software-engineering capabilities at roughly half of the BF16 footprint, ready for NVFP4-capable inference stacks on Blackwell GPUs.
## Files
| File | Size | Notes |
|---|---|---|
| `model-00001-of-00008.safetensors` … `model-00008-of-00008.safetensors` | ~29.2 GB total | NVFP4 MLP weights (packed U8 + FP8 block scales) + BF16 attention/GDN/embeddings/head |
| `model.safetensors.index.json` | — | Shard index (1427 tensors) |
| `hf_quant_config.json` | — | `quant_algo: NVFP4`, group size 16 |
| `config.json`, `tokenizer.*`, `merges.txt`, `vocab.json` | — | Config + tokenizer from the base model |
| `scripts/quantize_veriloop.py` | — | Full reproduction script (multi-GPU PTQ) |
| `scripts/validate_nvfp4.py` | — | Structural shard/index validator |
## Usage
This checkpoint targets **NVFP4-capable runtimes** (Blackwell GPUs). Plain `transformers` cannot load modelopt NVFP4 checkpoints directly.
> **Compatibility note:** per the NVIDIA recipe, the `linear_attn` blocks, the self-attention projections, a small set of projections (`linear_attn.in_proj_a/b`, `conv1d`), plus the embeddings and `lm_head`, intentionally ship in BF16. The `exclude_modules` list in `hf_quant_config.json` (mirrored in `config.json`, including fused names such as `in_proj_ba`/`in_proj_qkvz` that some loaders synthesize) declares exactly which modules those are — inference loaders must honor it and serve those modules unquantized. If a loader errors with *"weight is torch.bfloat16 but the quant config declares NVFP4"*, it is ignoring the exclusion list, not a checkpoint defect.
### vLLM
```bash
pip install 'vllm>=0.17.0'
vllm serve rodrigoramosrs/veriloop-coder-e2-nvfp4 \
--tensor-parallel-size 1 \
--max-model-len 131072 \
--kv-cache-dtype fp8_e4m3 \
--gpu-memory-utilization 0.92
```
### SGLang
```bash
pip install 'sglang[all]'
python -m sglang.launch_server \
--model-path rodrigoramosrs/veriloop-coder-e2-nvfp4 \
--trust-remote-code \
--mem-fraction-static 0.88
```
### TensorRT-LLM
Build the engine from this checkpoint with `trtllm-build` using an NVFP4 + FP8-KV configuration, then serve with `trtllm-serve`. See the [TensorRT-LLM documentation](https://github.com/NVIDIA/TensorRT-LLM) for the exact flags for your GPU.
### Reproducing
```bash
pip install "nvidia-modelopt[all]" torch transformers accelerate datasets safetensors
# needs ~55 GB VRAM across CUDA GPUs for the 27B BF16 source model
python scripts/quantize_veriloop.py \
--model ./model-bf16 \
--output ./model-nvfp4 \
--calib-size 512 \
--calib-seq-len 512
python scripts/validate_nvfp4.py ./model-nvfp4
```
On Windows the Triton JIT needs a C compiler: run from a Visual Studio Native Tools prompt (`vcvars64`) with `CC` pointing at `cl.exe`. See the header of `scripts/quantize_veriloop.py` for multi-GPU layout tuning (`--layers-split`, `--gpu-order`).
## Runtime notes
- **Verified working:** FreeToken (NVFP4, Blackwell) and SGLang ≥ 0.5.20 with the loader patch below — end-to-end generation confirmed on both.
- **SGLang ≤ 0.5.20, stock:** serving this checkpoint yields degenerate output (constant-token repetition). Root cause, bisected: `qwen3_5_text.Qwen3_5ForCausalLM.load_weights` strips the leading `model.` before delegating to a body whose params are prefix-less, so essentially every weight misses (`... not found in params_dict` warnings) and the model runs uninitialized. Fix (`scripts/sglang-qwen35-loader.patch.py`, applied in `scripts/Dockerfile.sglang-qwen35fix`): strip `model.` plus an optional `language_model.` segment, yielding exactly the body-relative names for both `model.layers.*` and `model.language_model.*` checkpoints. Affects any text-only Qwen3.5 checkpoint on stock 0.5.20, quantized or not.
## Acknowledgements
- **Libo Wang** and the **Intelligent Robotics Laboratory, Tsinghua SIGS** for developing the original VeriLoop E2 model.
- **NVIDIA** for Model Optimizer and the NVFP4 quantization tooling.
- The original model repository: [tsinghua-sigs-robot-lab/VeriLoop-E2](https://huggingface.co/tsinghua-sigs-robot-lab/VeriLoop-E2)
## License
Apache-2.0. The weights are quantized from the original Apache-2.0 licensed model. See the [original repository](https://huggingface.co/tsinghua-sigs-robot-lab/VeriLoop-E2) for full licensing details and third-party notices.
|