Qwen3-27B gets 3-stage fine-tuning to translate C to safe Rust code
Three-stage curriculum teaches Qwen3-27B idiomatic Rust, debugging, and LeetCode-based translation.
A team including Pu Zhao and Yanzhi Wang from Northeastern University has published a preprint detailing a systematic approach to fine-tuning Qwen3-27B for C-to-Rust code translation. The work, available as arXiv:2608.13681, tackles a core software-engineering pain point: converting legacy C code into safe, idiomatic Rust to eliminate memory-safety vulnerabilities. Off-the-shelf LLMs struggle at this task because general pretraining rarely emphasizes Rust-specific idioms, cross-language semantic equivalence, or reasoning about compiler feedback. The authors propose a three-stage curriculum to progressively specialize the model: first, continued pretraining on Rust-centric corpora to reinforce idiomatic syntax and standard-library usage; second, supervised fine-tuning on Microsoft's Verus_Training_Data to teach debugging and self-repair behavior; and third, task-specific fine-tuning on paired C/Rust solutions derived from LeetCode problems to learn direct semantic translation.
To evaluate the fine-tuned model, the researchers used SACTOR, an agentic, static-analysis-guided verification framework that performs structure-aware, two-phase translation (unidiomatic to idiomatic) with foreign-function-interface (FFI)-based end-to-end testing. They report success rate, idiomaticity measured via Clippy lint counts and unsafe-code fraction, and failure-mode analyses, comparing against baseline Qwen3-27B and other LLMs under the same framework. The results demonstrate that this staged approach improves both correctness and code quality, producing Rust that is more idiomatic and safer while preserving functionality. Although exact numerical gains are pending full publication, the methodology highlights how targeted fine-tuning and verification-aware evaluation can push open-weight models toward practical use in high-stakes legacy code migration.
- Uses a three-stage fine-tuning curriculum: Rust continued pretraining, Verus_Training_Data SFT for debugging, and task-specific SFT on LeetCode C/Rust pairs
- Evaluated with SACTOR framework, measuring success rate, Clippy lint counts, and unsafe-code fraction
- Improves C-to-Rust translation quality over baseline Qwen3-27B, targeting memory-safety vulnerability elimination in legacy systems
Why It Matters
Automating C-to-Rust translation can eliminate entire classes of memory-safety bugs in legacy code without costly manual rewrites.