Views
No views yet
git clone https://github.com/NellyW8/VeriReason.gitcd VeriReason1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4model_name = "Nellyw888/VeriReason-codeLlama-7b-RTLCoder-Verilog-GRPO-reasoning-tb"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16)
7model.eval()
8
9prompt = """
10Please act as a professional verilog designer. Develop a module that implements a 8-bit comparator. The module should have two 8-bit inputs and one output. If the first input is greater than the second input, the output should be high. Otherwise, the output should be low. First, think through the design approach, considering the functionality, inputs, outputs, and implementation details. Then provide the complete Verilog code implementation. Respond in the following format: <think>
11...
12</think>
13<answer>
14```verilog
15...```
16</answer>
17"""
18
19input_ids = tokenizer(prompt, return_tensors="pt").input_ids
20outputs = model.generate(input_ids, max_length=1024, temperature=0.2, top_p=0.95)
21result = tokenizer.decode(outputs[0], skip_special_tokens=True)
22print(result)mv verilog_rewards_tb.py verilog_train_tb.py src/open-r1/1mkdir verilog_recipe
2mv verilog_grpo_tb.yaml verilog_recipe/NCCL_DEBUG=INFO TORCH_DISTRIBUTED_DEBUG=DETAIL CUDA_VISIBLE_DEVICES=0,1,2 ACCELERATE_USE_NCCL=1 accelerate launch --config_file recipes/accelerate_configs/zero3.yaml --num_processes=3 src/open_r1/verilog_train_rtlcoder.py --config verilog_recipe/verilog_grpo_tb.yaml --use_vllm=false1@misc{wang2025verireason,
2 title={VeriReason: Reinforcement Learning with Testbench Feedback for Reasoning-Enhanced Verilog Generation},
3 author={Yiting Wang and Guoheng Sun and Wanghao Ye and Gang Qu and Ang Li},
4 year={2025},
5 eprint={2505.11849},
6 archivePrefix={arXiv},
7 primaryClass={cs.AI},
8 url={https://arxiv.org/abs/2505.11849},
9}