File size: 2,073 Bytes
f9cf203
 
 
 
 
 
 
 
 
 
 
 
901b049
f9cf203
901b049
f9cf203
901b049
f9cf203
901b049
 
f9cf203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
901b049
 
f9cf203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
library_name: peft
base_model: Qwen/Qwen3-32B
tags:
- verilog
- code-generation
- lora
- qwen3
- verl
- grpo
license: apache-2.0
---

# qwen3-32b-verilog-lora

This is a LoRA (Low-Rank Adaptation) adapter for **Qwen/Qwen3-32B** fine-tuned for **Verilog code generation**.

## Training Details

- **Base Model**: Qwen/Qwen3-32B
- **Training Algorithm**: GRPO (Group Relative Policy Optimization) 
- **LoRA Rank**: 32
- **LoRA Alpha**: 32
- **Target Modules**: o_proj, k_proj, up_proj, v_proj, gate_proj, q_proj, down_proj
- **Task**: Verilog hardware description language code generation

## Usage

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel

# Load base model and tokenizer
base_model_name = "Qwen/Qwen3-32B"
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
base_model = AutoModelForCausalLM.from_pretrained(
    base_model_name,
    torch_dtype="auto",
    device_map="auto"
)

# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "sonyashijin/qwen3-32b-verilog-lora")

# Generate Verilog code
prompt = "Create a 4-bit D flip-flop with enable and asynchronous reset:"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=512, temperature=0.7)
generated_code = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(generated_code)
```

## Training Configuration

- **Data**: Custom Verilog training dataset
- **Batch Size**: 64 
- **Learning Rate**: 3e-5
- **KL Loss Coefficient**: 0.001
- **Max Prompt Length**: 1200 tokens
- **Max Response Length**: 1200 tokens

## Files

- `adapter_config.json`: LoRA adapter configuration
- `adapter_model.safetensors`: LoRA adapter weights (safe tensors format)

## Citation

If you use this model, please cite the VERL (Verification Enhanced Reinforcement Learning) framework.

```bibtex
@misc{verl2024,
  title={VERL: Verification Enhanced Reinforcement Learning for Verilog Code Generation},
  author={Your Name},
  year={2024},
  url={https://huggingface.co/sonyashijin/qwen3-32b-verilog-lora}
}
```