How to use from the
Use from the
Transformers library
# 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]:]))
Quick Links

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.

The accompanying technical report is titled “Fine-Tuning Qwen3.5-27B for C-to-Rust Code Translation: A Three-Stage Curriculum of Pretraining, Debugging-Aware SFT, and Task-Specific SFT” (August 2026).

Results

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

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 unsafe Rust 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

The supplied manuscript has not finalized its individual author list. Until citation metadata is released, cite the software artifact:

@software{moxin2026c2rust,
  title  = {C2Rust: Fine-Tuned Qwen3.5-27B for C-to-Rust Translation},
  author = {{Moxin Organization}},
  year   = {2026},
  url    = {https://github.com/moxin-org/C2Rust}
}

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
19
Safetensors
Model size
3.05M params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for moxin-org/C2Rust

Base model

Qwen/Qwen3.5-27B
Finetuned
(296)
this model