Instructions to use moxin-org/C2Rust with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moxin-org/C2Rust with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="moxin-org/C2Rust") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("moxin-org/C2Rust") model = AutoModelForMultimodalLM.from_pretrained("moxin-org/C2Rust", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moxin-org/C2Rust with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moxin-org/C2Rust" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moxin-org/C2Rust", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/moxin-org/C2Rust
- SGLang
How to use moxin-org/C2Rust 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 "moxin-org/C2Rust" \ --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": "moxin-org/C2Rust", "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 "moxin-org/C2Rust" \ --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": "moxin-org/C2Rust", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use moxin-org/C2Rust with Docker Model Runner:
docker model run hf.co/moxin-org/C2Rust
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 "moxin-org/C2Rust" \
--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": "moxin-org/C2Rust",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'C2Rust
C2Rust is a full-parameter BF16 fine-tune of Qwen/Qwen3.5-27B for translating C programs into behaviorally equivalent Rust. The model is trained with a three-stage curriculum and evaluated with an execution-based SACTOR harness that compiles each candidate and compares its behavior with the source C program.
Paper
Pu Zhao, Changdi Yang, Yixiao Chen, Yi Gao, Yifan Cao, Haochen Zeng, and Yanzhi Wang.
Northeastern University · EmbodyX Inc · Aibao LLC
The arXiv title uses “Qwen3-27B”; Section 3 identifies the released source checkpoint as
Qwen/Qwen3.5-27B, which is the identifier used throughout this model card.
Results
87.30% execution-verified C2Rust Success Rate — a 15.00 percentage-point gain over the untuned Qwen3.5-27B base at identical model size. The 27B checkpoint also outperforms Qwen3.5-Plus (397B total), MiniMax-M2.5 (230B total), and GLM-5 (744B total) on this benchmark.
C2Rust translation success rate
Success Rate (SR) is the percentage of programs that compile and pass every end-to-end test. Scores are arithmetic means over five random seeds under the same inference configuration.
| Model | Model size | SR |
|---|---|---|
| Qwen3.5-Plus | 397B total / 17B active | 77.20% |
| MiniMax-M2.5 | 230B total / 10B active | 83.90% |
| GLM-5 | 744B total / 40B active | 84.40% |
| GLM-5.2 | 744B total / 40B active | 89.90% |
| Claude Code-4.6 | undisclosed | 90.01% |
| Qwen3.5-27B base | 27B dense | 72.30% |
| C2Rust (this model) | 27B dense | 87.30% |
The curriculum improves the direct Qwen3.5-27B baseline by 15.00 percentage points while keeping model size and serving cost fixed. C2Rust outperforms Qwen3.5-Plus, MiniMax-M2.5, and GLM-5 on this task, while remaining below GLM-5.2 and Claude Code-4.6.
General coding capability
| Model | SWE-bench Verified pass@1 |
|---|---|
| GPT-5-mini (2025-08-07) | 72.0 |
| GPT-OSS-120B | 62.0 |
| Qwen3.5-122B-A10B | 72.0 |
| Qwen3.5-27B base | 72.4 |
| C2Rust (this model) | 70.6 |
The 1.8-point difference from the untuned base suggests a modest specialization cost, while the model retains strong general software-engineering performance.
Three-stage training curriculum
| Stage | Objective | Data | Training configuration |
|---|---|---|---|
| 1. Rust continued pretraining | Strengthen Rust syntax, idioms, completion, repair, and library knowledge | 1,673,289 examples from seven Rust-focused sources | Full-parameter BF16, 1 epoch, LR 1e-6 |
| 2. Debugging-aware SFT | Learn to consume structured verifier feedback and make targeted repairs | microsoft/Verus_Training_Data |
Full-parameter BF16, 2 epochs, LR 2e-7 |
| 3. C2Rust task SFT | Learn direct C-to-Rust semantic translation | C2Rust-Moxin functions/ and programs/ pairs |
Full-parameter BF16, 2 epochs, LR 2e-7 |
Stage 1 combines Strandset-Rust, CodeFIM-Rust-Mellum, rust_instruction_dataset, humaneval-rust, the Rust subset of Magicoder-OSS-Instruct-75K, the Rust program-synthesis and repair subsets of xCodeEval, and the Rust subset of StarCoderData.
All three stages use a 16,384-token sequence length, DeepSpeed ZeRO Stage 3, and eight NVIDIA B300 GPUs. Training is text-only. The Qwen3.5 vision encoder remains in the released checkpoint but receives no task input and plays no role in C-to-Rust translation.
Model details
| Field | Value |
|---|---|
| Base model | Qwen/Qwen3.5-27B |
| Parameters | 27B language model (~28B including the retained vision encoder) |
| Weight format | Safetensors |
| Precision | BF16 |
| Context used in training | 16,384 tokens |
| Fine-tuning type | Full-parameter |
| Primary task | C-to-Rust program translation |
| License | Apache-2.0 |
The tokenizer, vocabulary, and architecture are unchanged from the base checkpoint; no task-specific special tokens were added.
Evaluation protocol
The companion benchmark contains 200 C programs: 92 receive command-line arguments and 108 read standard input. Approximately 120 are derived from IBM Project CodeNet. A translation succeeds only when the generated Rust program compiles and reproduces every reference output on the supplied tests within a six-attempt translation and repair budget.
| Setting | Value |
|---|---|
| Temperature | 0.6 |
| Top-p | 0.95 |
| Top-k | 20 |
| Maximum output length | 1,536 tokens |
| Maximum translation attempts | 6 |
| Random seeds | 5 |
The released repository's default configs evaluate SACTOR's interface-preserving, unidiomatic stage.
Generated code may therefore contain raw pointers or unsafe Rust. Passing the benchmark measures
agreement on the supplied test suite, not formal semantic equivalence.
Resources
- Paper: arXiv:2608.13681
- Project website
- Benchmark, evaluation harness, and setup instructions
- Base model: Qwen/Qwen3.5-27B
- SACTOR translation engine
- C2Rust-Moxin training datasets
Running with the benchmark
Download the checkpoint:
hf download moxin-org/C2Rust --local-dir /path/to/C2Rust-model
Clone and prepare the benchmark:
git clone https://github.com/moxin-org/C2Rust.git
cd C2Rust
bash fix_paths.sh
cd engine
uv sync
./update_rust_ast_parser.sh
cargo build --release
cd ..
Launch the checkpoint with SGLang:
export SERVE_VENV=/path/to/sglang-venv
./scripts/launch_model.sh /path/to/C2Rust-model 0,1 30878 2
Run a two-program smoke test before the complete evaluation:
python3 scripts/run_eval.py configs/native_prompt.toml results/_smoke \
--modes argv --limit 2 --workers 1
See the benchmark README and
SETUP.md for the complete environment,
five-seed evaluation, aggregation, and troubleshooting workflow.
Intended use
This release is intended for research and experimentation on C-to-Rust translation. Treat every generated program as a candidate: compile it, test it against the original implementation, and review it for correctness, safety, and maintainability before use.
Limitations
- Passing the supplied tests is not proof of semantic equivalence, memory safety, or security.
- The default evaluation permits
unsafeRust and prioritizes behavior preservation over idiomaticity. - Stage 3 uses function- and program-level pairs, but excludes project-level training examples.
- The model scores 70.6 on SWE-bench Verified versus 72.4 for the base checkpoint, suggesting mild capability narrowing after full-parameter specialization.
- The report does not yet provide an ablation isolating each curriculum stage's marginal contribution.
Citation
@article{zhao2026c2rust,
title = {Fine-Tuning Qwen3-27B for C-to-Rust Code Translation: A Three-Stage Curriculum of Pretraining, Debugging-Aware SFT, and Task-Specific SFT},
author = {Zhao, Pu and Yang, Changdi and Chen, Yixiao and Gao, Yi and Cao, Yifan and Zeng, Haochen and Wang, Yanzhi},
journal = {arXiv preprint arXiv:2608.13681},
year = {2026},
doi = {10.48550/arXiv.2608.13681}
}
License and attribution
The checkpoint is released under Apache-2.0 and is derived from Qwen/Qwen3.5-27B. The benchmark is Apache-2.0. Its dataset includes material derived from IBM Project CodeNet under CDLA-Permissive-2.0; see the dataset provenance and terms.
- Downloads last month
- 278
Model tree for moxin-org/C2Rust
Base model
Qwen/Qwen3.5-27B
Install from pip and serve model
# Install SGLang from pip: pip install sglang# Start the SGLang server: python3 -m sglang.launch_server \ --model-path "moxin-org/C2Rust" \ --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": "moxin-org/C2Rust", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'