--- license: other task_categories: - text-generation language: - en tags: - verilog - python - rtl - hardware pretty_name: RTL Verilog -> Python reference-model SFT configs: - config_name: default data_files: - split: train path: data/python.train.jsonl - split: validation path: data/python.validation.jsonl - split: test path: data/python.test.jsonl - config_name: bench data_files: - split: validation path: bench/python_bench.validation.jsonl - split: test path: bench/python_bench.test.jsonl --- # RTL Verilog → Python reference-model SFT Task: given a hardware problem description and an interface skeleton, write a **cycle-accurate Python model** `class TopModule` with `eval(inputs: dict) -> dict` (one call = one rising edge of every clock; clock inputs are not passed; reset is an ordinary input; outputs are read after the edge). This is the Python agent of ChipMATE-style Verilog/Python cross-verification. Training and evaluation code, recipe and documentation: [github.com/yil384/rtl-qwen-sft](https://github.com/yil384/rtl-qwen-sft), `docs/PYTHON_SFT.md` (configs `configs/qwen38-27b-python.example.yaml`, `configs/b200-multinode-qwen38-27b-python.example.yaml`). ## Layout | File | Rows | Use | | --- | ---: | --- | | `data/python.train.jsonl` | 96,525 | SFT train | | `data/python.validation.jsonl` | 1,078 | frozen; `eval_loss` only | | `data/python.test.jsonl` | 1,037 | frozen; never trained on | | `bench/python_bench.validation.jsonl` | 1,151 problems | benchmark `python-heldout-val` (checkpoint selection) | | `bench/python_bench.test.jsonl` | 1,095 problems | benchmark `python-heldout` (report) | | `release_manifest.json` | | rows, sha256, sources and answer origins per file | SFT rows: `{"messages": [system, user, assistant], "provenance": {...}}`. The user turn is the spec, then `Complete this skeleton:`, a Python skeleton and `Answer:`. The assistant turn is `...` followed by `` with one fenced `python` block. Benchmark rows: `{"problem_id", "messages": [system, user], "golden", "reference_python", "provenance"}`. `golden` is the reference Verilog's trace: ports, stored stimulus and expected outputs per cycle. `reference_python` is the verified pipeline answer, used only for the harness self-check, or null. ## How the answers were made and checked Every problem's reference Verilog (from `yil384/rtl-verilog-sft` v062 code view) is simulated with yosys + Icarus Verilog for 300 cycles of fixed random stimulus. The seed is 0. Each input is all-zeros 10% of the time, all-ones 10%, uniform otherwise. Reset is asserted for the first 3 cycles and then with probability 0.03. Outputs are sampled after each rising edge, and X/Z bits are don't-care. Problems with less than 50% known output bits are not used. **An answer is kept only if every output matches on every cycle.** | `provenance.answer_origin` | train rows | how | | --- | ---: | --- | | `ir_transpile_normalized+posthoc_rationale` | 65,477 | PyVerilog AST transpiler output, normalized to the skeleton convention (clock not read, settle loop unrolled), re-verified | | `llm_verilog_hint+posthoc_rationale` | 20,744 | Qwen3-Coder-30B-A3B-Instruct, shown the reference Verilog; first verified sample | | `llm_verilog_hint_repair+posthoc_rationale` | 1,313 | one repair round with the harness feedback (first mismatching cycle, expected/got bits, off-by-k-cycles diagnosis) | | `v32_reuse` / `v12_reuse` | 4,698 / 4,293 | existing V32 / v12 skeleton-format answers for the same prompt that pass our trace, kept with their original rationale | Sources (license of each row follows its upstream Verilog source; see the Verilog dataset card): CodeV-R1 40,702, VeriCoder 32,465, VeriMM 11,391, VeriThoughts 6,467, VeriReason-Luna 5,500. Combinational 56,422, sequential 40,103. ## Splits and leakage - Train, validation and test come from the Verilog v062 `code.train`, `code.validation` and `code.test` splits. 11,304 train rows are CodeV-R1 problems outside the Verilog 100k. They were compared with the held-out problems by id, spec text and reference-Verilog hash. - Removed from train: 5 rows whose spec equals a held-out spec, and 13 rows over 16,384 tokens (Qwen3.8 tokenizer, `qwen3_5` template with thinking). Long rows are dropped, never truncated. - Removed from the held-out side: rows whose answer code is identical to a train answer (validation 158, test 115). Trivial circuits translate to identical Python for different problems. The same problems are also removed from the benchmark files, as are 5 benchmark problems without an SFT row whose reference answer equals a train answer (validation 4, test 1). So no held-out problem has its verified answer verbatim in training. One test row over 16,384 tokens was also dropped. - The benchmark files keep every remaining problem with a usable trace, whether or not a verified answer exists: 1,102 of 1,151 and 1,052 of 1,095 have `reference_python`. - Built for the held-out splits with the same pipeline. Only one GPU was free for that run, so the fallback generator ran with FP8 weights there. Every answer still had to pass the trace. - The training repository's `prepare` accepts the three SFT files with 0 rejected rows. Its checks cover duplicate ids, duplicate dialogues, and cross-split id/group/prompt/response matches. ## Limitations - **Post-hoc reasoning.** Except for the two `*_reuse` origins, the `` text was written by Qwen3-Coder-30B-A3B-Instruct after the code had passed verification, as in ChipMATE sec. 2.3. It explains a known-correct answer and is not how the answer was derived. Rationales that mention Verilog, the converter or a given solution, or that criticize the code, were filtered. - **Verified ≠ correct.** A pass means agreement with one reference Verilog on one finite 300-cycle trace. That is differential testing, not formal equivalence. Behavior outside the stimulus is unchecked, and the reference itself can be wrong. - IR-derived answers are mechanical in style: two-phase current/next-state temporaries and extra width masks. - Not 100k: about 13k train-pool problems got no verified answer from the available generator. - No model trained on this set has been evaluated yet. ## History `python_sft.train.jsonl` at the repository root is the earlier 96,543-row train file in ShareGPT `conversations` format. It is superseded by `data/python.train.jsonl` (same answers, `messages` format, the removals above). `legacy/` holds the original 47,205-row v12 skeleton file, **unverified**, as is.