hzeng8 commited on
Commit
6ceeeb1
·
verified ·
1 Parent(s): e969dee

Update model card from C2Rust technical report

Browse files

Add the three-stage training curriculum, verified C2Rust and SWE-bench results, evaluation protocol, limitations, and citation guidance.

Files changed (1) hide show
  1. README.md +126 -44
README.md CHANGED
@@ -3,7 +3,7 @@ license: apache-2.0
3
  base_model:
4
  - Qwen/Qwen3.5-27B
5
  library_name: transformers
6
- pipeline_tag: image-text-to-text
7
  tags:
8
  - code
9
  - c
@@ -11,42 +11,117 @@ tags:
11
  - code-translation
12
  - c-to-rust
13
  - qwen3.5
 
 
 
14
  ---
15
 
16
  # C2Rust
17
 
18
- C2Rust is a 27B-parameter BF16 Qwen3.5 checkpoint for translating C programs into behaviorally
19
- equivalent Rust. It is released alongside an execution-based benchmark that compiles each generated
20
- translation and checks its output against the reference C program.
 
 
21
 
22
- ## Resources
 
 
23
 
24
- - [Benchmark, evaluation harness, and setup instructions](https://github.com/moxin-org/C2Rust)
25
- - [Base model: Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B)
26
- - [SACTOR translation engine](https://github.com/qsdrqs/sactor)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
  ## Model details
29
 
30
  | Field | Value |
31
  |---|---|
32
  | Base model | `Qwen/Qwen3.5-27B` |
33
- | Architecture | Qwen3.5 causal language model with vision encoder |
34
- | Parameters | 27B |
35
  | Weight format | Safetensors |
36
  | Precision | BF16 |
37
- | Primary task | C→Rust program translation |
 
 
 
38
 
39
- ## Intended use
 
 
 
 
 
 
 
 
40
 
41
- The model is intended for research and experimentation on C→Rust translation. Its output should be
42
- treated as a candidate translation: compile it, test it against the original program, and review it
43
- for correctness, safety, and maintainability before use.
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- The companion benchmark evaluates a single translation stage that preserves the C interface and may
46
- produce `unsafe` Rust. It does not establish that generated code is memory-safe, idiomatic, secure,
47
- or suitable for production.
 
48
 
49
- ## Running the model with the benchmark
50
 
51
  Download the checkpoint:
52
 
@@ -68,15 +143,14 @@ cargo build --release
68
  cd ..
69
  ```
70
 
71
- Create an SGLang environment, point `SERVE_VENV` at it, and launch the checkpoint. The helper script
72
- sets the serving options expected by the benchmark:
73
 
74
  ```bash
75
  export SERVE_VENV=/path/to/sglang-venv
76
  ./scripts/launch_model.sh /path/to/C2Rust-model 0,1 30878 2
77
  ```
78
 
79
- In another shell, run a two-problem smoke test before a full evaluation:
80
 
81
  ```bash
82
  python3 scripts/run_eval.py configs/native_prompt.toml results/_smoke \
@@ -84,33 +158,41 @@ python3 scripts/run_eval.py configs/native_prompt.toml results/_smoke \
84
  ```
85
 
86
  See the [benchmark README](https://github.com/moxin-org/C2Rust#setup-once-per-machine) and
87
- [`SETUP.md`](https://github.com/moxin-org/C2Rust/blob/main/SETUP.md) for system dependencies,
88
- multi-seed evaluation, aggregation, and troubleshooting.
89
 
90
- ## Evaluation protocol
91
-
92
- The companion CodeNet benchmark contains 200 C programs: 92 use command-line arguments and 108 use
93
- standard input. A problem passes only when the generated Rust program compiles and matches the
94
- reference C program on every test case. Decoding is fixed at temperature 0.6, top-p 0.95, and top-k
95
- 20. Because individual runs are noisy, the repository reports five-seed means with standard
96
- deviation and a bootstrap confidence interval.
97
 
98
- No reference model score is claimed in the benchmark repository. Use its shipped configuration and
99
- five-seed aggregation script for comparable measurements.
 
100
 
101
  ## Limitations
102
 
103
- - Generated translations may fail to compile or may differ from the source program on untested
104
- inputs.
105
- - Passing the supplied tests is not a proof of semantic equivalence, memory safety, or security.
106
- - The benchmark's primary flow permits `unsafe` Rust and prioritizes behavioral preservation over
107
- idiomatic Rust.
108
- - Training-data and training-procedure details are not included in the current release.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
- ## Licenses and attribution
111
 
112
- The checkpoint is released under Apache-2.0 and is based on
113
- [Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B). The benchmark repository is
114
- Apache-2.0. Its dataset includes material derived from IBM Project CodeNet under
115
- CDLA-Permissive-2.0; see the benchmark's
116
  [dataset provenance and terms](https://github.com/moxin-org/C2Rust/blob/main/CodeNet/README.md).
 
3
  base_model:
4
  - Qwen/Qwen3.5-27B
5
  library_name: transformers
6
+ pipeline_tag: text-generation
7
  tags:
8
  - code
9
  - c
 
11
  - code-translation
12
  - c-to-rust
13
  - qwen3.5
14
+ - fine-tuning
15
+ - sactor
16
+ - deepspeed
17
  ---
18
 
19
  # C2Rust
20
 
21
+ **C2Rust** is a full-parameter BF16 fine-tune of
22
+ [Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B) for translating C programs into
23
+ behaviorally equivalent Rust. The model is trained with a three-stage curriculum and evaluated with
24
+ an execution-based SACTOR harness that compiles each candidate and compares its behavior with the
25
+ source C program.
26
 
27
+ The accompanying technical report is titled **“Fine-Tuning Qwen3.5-27B for C-to-Rust Code
28
+ Translation: A Three-Stage Curriculum of Pretraining, Debugging-Aware SFT, and Task-Specific SFT”**
29
+ (August 2026).
30
 
31
+ ## Results
32
+
33
+ ### C2Rust translation success rate
34
+
35
+ Success Rate (SR) is the percentage of programs that compile and pass every end-to-end test. Scores
36
+ are arithmetic means over five random seeds under the same inference configuration.
37
+
38
+ | Model | Model size | SR |
39
+ |---|---:|---:|
40
+ | Qwen3.5-Plus | 397B total / 17B active | 77.20% |
41
+ | MiniMax-M2.5 | 230B total / 10B active | 83.90% |
42
+ | GLM-5 | 744B total / 40B active | 84.40% |
43
+ | GLM-5.2 | 744B total / 40B active | 89.90% |
44
+ | Claude Code-4.6 | undisclosed | 90.01% |
45
+ | Qwen3.5-27B base | 27B dense | 72.30% |
46
+ | **C2Rust (this model)** | **27B dense** | **87.30%** |
47
+
48
+ The curriculum improves the direct Qwen3.5-27B baseline by **15.00 percentage points** while keeping
49
+ model size and serving cost fixed. C2Rust outperforms Qwen3.5-Plus, MiniMax-M2.5, and GLM-5 on this
50
+ task, while remaining below GLM-5.2 and Claude Code-4.6.
51
+
52
+ ### General coding capability
53
+
54
+ | Model | SWE-bench Verified pass@1 |
55
+ |---|---:|
56
+ | GPT-5-mini (2025-08-07) | 72.0 |
57
+ | GPT-OSS-120B | 62.0 |
58
+ | Qwen3.5-122B-A10B | 72.0 |
59
+ | Qwen3.5-27B base | 72.4 |
60
+ | **C2Rust (this model)** | **70.6** |
61
+
62
+ The 1.8-point difference from the untuned base suggests a modest specialization cost, while the model
63
+ retains strong general software-engineering performance.
64
+
65
+ ## Three-stage training curriculum
66
+
67
+ | Stage | Objective | Data | Training configuration |
68
+ |---|---|---|---|
69
+ | 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` |
70
+ | 2. Debugging-aware SFT | Learn to consume structured verifier feedback and make targeted repairs | [`microsoft/Verus_Training_Data`](https://huggingface.co/datasets/microsoft/Verus_Training_Data) | Full-parameter BF16, 2 epochs, LR `2e-7` |
71
+ | 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` |
72
+
73
+ Stage 1 combines Strandset-Rust, CodeFIM-Rust-Mellum, rust_instruction_dataset, humaneval-rust,
74
+ the Rust subset of Magicoder-OSS-Instruct-75K, the Rust program-synthesis and repair subsets of
75
+ xCodeEval, and the Rust subset of StarCoderData.
76
+
77
+ All three stages use a 16,384-token sequence length, DeepSpeed ZeRO Stage 3, and eight NVIDIA B300
78
+ GPUs. Training is text-only. The Qwen3.5 vision encoder remains in the released checkpoint but receives
79
+ no task input and plays no role in C-to-Rust translation.
80
 
81
  ## Model details
82
 
83
  | Field | Value |
84
  |---|---|
85
  | Base model | `Qwen/Qwen3.5-27B` |
86
+ | Parameters | 27B language model (~28B including the retained vision encoder) |
 
87
  | Weight format | Safetensors |
88
  | Precision | BF16 |
89
+ | Context used in training | 16,384 tokens |
90
+ | Fine-tuning type | Full-parameter |
91
+ | Primary task | C-to-Rust program translation |
92
+ | License | Apache-2.0 |
93
 
94
+ The tokenizer, vocabulary, and architecture are unchanged from the base checkpoint; no task-specific
95
+ special tokens were added.
96
+
97
+ ## Evaluation protocol
98
+
99
+ The companion benchmark contains **200 C programs**: 92 receive command-line arguments and 108
100
+ read standard input. Approximately 120 are derived from IBM Project CodeNet. A translation succeeds
101
+ only when the generated Rust program compiles and reproduces every reference output on the supplied
102
+ tests within a six-attempt translation and repair budget.
103
 
104
+ | Setting | Value |
105
+ |---|---:|
106
+ | Temperature | 0.6 |
107
+ | Top-p | 0.95 |
108
+ | Top-k | 20 |
109
+ | Maximum output length | 1,536 tokens |
110
+ | Maximum translation attempts | 6 |
111
+ | Random seeds | 5 |
112
+
113
+ The released repository's default configs evaluate SACTOR's interface-preserving, unidiomatic stage.
114
+ Generated code may therefore contain raw pointers or `unsafe` Rust. Passing the benchmark measures
115
+ agreement on the supplied test suite, not formal semantic equivalence.
116
+
117
+ ## Resources
118
 
119
+ - [Benchmark, evaluation harness, and setup instructions](https://github.com/moxin-org/C2Rust)
120
+ - [Base model: Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B)
121
+ - [SACTOR translation engine](https://github.com/qsdrqs/sactor)
122
+ - [C2Rust-Moxin training datasets](https://github.com/Bobchenyx/Moxin-C2Rust-Datasets)
123
 
124
+ ## Running with the benchmark
125
 
126
  Download the checkpoint:
127
 
 
143
  cd ..
144
  ```
145
 
146
+ Launch the checkpoint with SGLang:
 
147
 
148
  ```bash
149
  export SERVE_VENV=/path/to/sglang-venv
150
  ./scripts/launch_model.sh /path/to/C2Rust-model 0,1 30878 2
151
  ```
152
 
153
+ Run a two-program smoke test before the complete evaluation:
154
 
155
  ```bash
156
  python3 scripts/run_eval.py configs/native_prompt.toml results/_smoke \
 
158
  ```
159
 
160
  See the [benchmark README](https://github.com/moxin-org/C2Rust#setup-once-per-machine) and
161
+ [`SETUP.md`](https://github.com/moxin-org/C2Rust/blob/main/SETUP.md) for the complete environment,
162
+ five-seed evaluation, aggregation, and troubleshooting workflow.
163
 
164
+ ## Intended use
 
 
 
 
 
 
165
 
166
+ This release is intended for research and experimentation on C-to-Rust translation. Treat every
167
+ generated program as a candidate: compile it, test it against the original implementation, and review
168
+ it for correctness, safety, and maintainability before use.
169
 
170
  ## Limitations
171
 
172
+ - Passing the supplied tests is not proof of semantic equivalence, memory safety, or security.
173
+ - The default evaluation permits `unsafe` Rust and prioritizes behavior preservation over idiomaticity.
174
+ - Stage 3 uses function- and program-level pairs, but excludes project-level training examples.
175
+ - The model scores 70.6 on SWE-bench Verified versus 72.4 for the base checkpoint, suggesting mild
176
+ capability narrowing after full-parameter specialization.
177
+ - The report does not yet provide an ablation isolating each curriculum stage's marginal contribution.
178
+
179
+ ## Citation
180
+
181
+ The supplied manuscript has not finalized its individual author list. Until citation metadata is
182
+ released, cite the software artifact:
183
+
184
+ ```bibtex
185
+ @software{moxin2026c2rust,
186
+ title = {C2Rust: Fine-Tuned Qwen3.5-27B for C-to-Rust Translation},
187
+ author = {{Moxin Organization}},
188
+ year = {2026},
189
+ url = {https://github.com/moxin-org/C2Rust}
190
+ }
191
+ ```
192
 
193
+ ## License and attribution
194
 
195
+ The checkpoint is released under Apache-2.0 and is derived from
196
+ [Qwen/Qwen3.5-27B](https://huggingface.co/Qwen/Qwen3.5-27B). The benchmark is Apache-2.0. Its
197
+ dataset includes material derived from IBM Project CodeNet under CDLA-Permissive-2.0; see the
 
198
  [dataset provenance and terms](https://github.com/moxin-org/C2Rust/blob/main/CodeNet/README.md).