| --- |
| license: apache-2.0 |
| pipeline_tag: text-generation |
| tags: |
| - chat |
| - llm |
| - safetensors |
| base_model: Qwen/Qwen3-8B |
| language: |
| - en |
| --- |
| |
| # ParetoPilot |
|
|
| ## Model Details |
|
|
| - **Finetuned from model:** `Qwen/Qwen3-8B` |
| - **Model source paper:** ParetoPilot: Global Optimization Reasoning on HLS Design Space Exploration with LLMs |
| - **Project repository:** [GEAR-SEU/ParetoPilot-DAC-26](https://github.com/GEAR-SEU/ParetoPilot-DAC-26) |
|
|
| ## Description |
|
|
| **ParetoPilot** is designed for High-Level Synthesis (HLS) Design Space Exploration (DSE). It analyzes HLS-C code and given pragma parameters to automatically generate optimized configurations (array partitioning, loop pipelining, and unrolling). The model focuses on global optimization reasoning, providing diverse combinations to balance performance, hardware resource utilization, and PPA (Power, Performance, Area) trade-offs. |
|
|
| ## Quickstart |
|
|
| ### Prerequisites |
| ```bash |
| pip install transformers torch accelerate |
| ``` |
|
|
| ### Example |
|
|
| Here is a simple example of how to format your prompt and generate debugging instructions for buggy HLS code: |
|
|
| ````python |
| from transformers import AutoModelForCausalLM, AutoTokenizer |
| import torch |
| |
| model_name = "XXXiong/ParetoPilot" |
| tokenizer = AutoTokenizer.from_pretrained(model_name) |
| model = AutoModelForCausalLM.from_pretrained( |
| model_name, |
| torch_dtype=torch.bfloat16, |
| device_map="auto" |
| ) |
| |
| hls_code = """ |
| #include <stdio.h> |
| #include <stdlib.h> |
| |
| #define TYPE double |
| |
| #define row_size 64 |
| #define col_size 64 |
| #define N row_size*col_size |
| |
| #define MIN 0. |
| #define MAX 1.0 |
| |
| #define MAX_ITERATION 1 |
| |
| void gemm( TYPE m1[N], TYPE m2[N], TYPE prod[N] ){ |
| int i, j, k; |
| int k_col, i_col; |
| TYPE mult; |
| |
| outer:for(i=0;i<row_size;i++) { |
| middle:for(j=0;j<col_size;j++) { |
| i_col = i * col_size; |
| TYPE sum = 0; |
| inner:for(k=0;k<row_size;k++) { |
| k_col = k * col_size; |
| mult = m1[i_col + k] * m2[k_col + j]; |
| sum += mult; |
| } |
| prod[i_col + j] = sum; |
| } |
| } |
| } |
| """ |
| |
| design_space = """ |
| { |
| "arrays": { |
| "m1": { |
| "type": [1, 2], |
| "dim": [1], |
| "factor_n": { |
| "1": [0, 2, 4, 8, 16, 32] |
| } |
| }, |
| "m2": { |
| "type": [1, 2], |
| "dim": [1], |
| "factor_n": { |
| "1": [0, 2, 4, 8, 16, 32] |
| } |
| }, |
| "prod": { |
| "type": [1, 2], |
| "dim": [1], |
| "factor_n": { |
| "1": [0, 2, 4, 8, 16, 32] |
| } |
| } |
| }, |
| "loops": { |
| "outer": { |
| "pipeline": [0], |
| "unroll": [0] |
| }, |
| "middle": { |
| "pipeline": [0], |
| "unroll": [0, 2, 4, 8, 16, 32], |
| "outer_loop": "outer" |
| }, |
| "inner": { |
| "pipeline": [0, 1], |
| "unroll": [0, 2, 4, 8, 16, 32], |
| "outer_loop": "middle" |
| } |
| } |
| } |
| """ |
| |
| prompt = f"""You are tasked with generating 12 unique and effective pragma configuration combinations for optimizing the provided High-Level Synthesis (HLS) design. |
| These configurations must target the following optimization goals while strictly adhering to the condition that only parameters available in the provided configuration file can be used. |
| If a parameter is not available, set the corresponding value to 0. |
| |
| - **Performance Optimization**: Achieve the best performance, which will result in higher hardware consumption. |
| - **Resource Utilization Optimization**: Minimize hardware resource usage, which may result in reduced performance. |
| - **PPA Tradeoff Optimization**: Find a balanced unroll factor combination that offers a good tradeoff between performance and hardware utilization. |
| |
| The configuration file provides parameters for pragmas: |
| 1. **`array_partition`**: |
| - `type`: Specifies the partitioning method. `0` represents complete partitioning, `1` indicates block partitioning, and `2` indicates cyclic partitioning. |
| - `dim`: Specifies the dimension to partition. `n` specifies the n-th dimension. |
| - `factor`: Indicates the partitioning factor (applied to block or cyclic partition types). |
| |
| 2. **`pipeline`**: Specifies whether to pipeline the current loop. |
| |
| 3. **`unroll`**: Specifies the unrolling factor for the current loop. |
| |
| **Make Sure every loop and array (every dim) has its configuration. IF you think it's unneccesary, set corresponding `unroll` and `factor` to 0.** |
| |
| ### Provided Code and Context: |
| The given HLS design. |
| ```cpp |
| {hls_code} |
| ``` |
| |
| The pragma parameter you can pick: |
| ``` |
| {design_space} |
| ``` |
| |
| ### Expected output format: |
| |
| ```python |
| [ |
| ( |
| ( |
| {{'name': '[loop_name]', 'pipeline': [value], 'unroll': [value]}}, |
| |
| {{...}} |
| ), |
| ( |
| {{'name': '[array_name]', 'type': [value], 'dim': [value], 'factor': [value]}}, |
| |
| {{...}} |
| ) |
| ), |
| ... |
| ] |
| ``` |
| |
| ### Additional Considerations: |
| - Generate exactly 12 such tuples. |
| - Output configurations in specific format. |
| - **No additional explanations and annotation**. |
| """ |
| |
| messages = [{"role": "user", "content": prompt}] |
| |
| text = tokenizer.apply_chat_template( |
| messages, |
| tokenize=False, |
| add_generation_prompt=True |
| ) |
| |
| model_inputs = tokenizer([text], return_tensors="pt").to(model.device) |
| |
| generated_ids = model.generate( |
| **model_inputs, |
| max_new_tokens=8192, |
| temperature=0.7, |
| do_sample=False, |
| top_k=50, |
| top_p=0.95 |
| ) |
| generated_ids = [ |
| output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) |
| ] |
| |
| response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] |
| print(response) |
| ```` |
|
|