Views
No views yet
hipify — specifically targeting AMD wavefront-64 semantics on RDNA/CDNA architectures.| Field | Value |
|---|---|
| Model type | Qwen2.5-Coder-7B-Instruct + LoRA adapter |
| LoRA rank / alpha | r=16, alpha=32 |
| Task | Causal Language Modeling (CAUSAL_LM) |
| Finetuned from | Qwen/Qwen2.5-Coder-7B-Instruct |
| Developed by | Tazwar Ahnaf |
| License | Apache 2.0 |
| Demo | ROCmPort AI on Spaces |
rocmport-qwen-wavefront-finetuned is a parameter-efficient LoRA adapter trained to fix the class of bugs that hipify routinely introduces when porting CUDA kernels to HIP. Raw hipify output often compiles and runs but produces incorrect results on AMD hardware because it blindly substitutes CUDA warp primitives (warpSize=32) with HIP equivalents without accounting for AMD's 64-wide wavefront execution model.warpSize or the correct AMD value (64 for GFX9/CDNA).__shfl_* / __ballot / __activemask intrinsics to their correct HIP/wavefront-64 equivalents.__syncwarp() usage patterns that have no direct HIP equivalent.| Split | Examples |
|---|---|
| Train | 153 |
| Validation | 6 (one per bug category) |
| Total | ~159 |
warp_size_constant — hardcoded 32 instead of warpSizeshfl_intrinsic — __shfl_* calls with wrong lane masks or widthsballot_activemask — __ballot_sync / __activemask ported incorrectlyshared_memory_tiling — tile dimensions based on warp=32syncwarp — __syncwarp() calls without HIP equivalentcooperative_groups — warp-level CG patterns broken at wavefront-64(buggy_hip, corrected_hip) pair with a structured prompt instructing the model to output only the corrected kernel.| Parameter | Value |
|---|---|
| GPU | AMD Instinct MI300X (gfx942) |
| ROCm version | 6.2 |
| Training platform | AMD Developer Cloud |
| Framework | Hugging Face transformers + peft + trl (SFTTrainer) |
| Hyperparameter | Value |
|---|---|
| Epochs | 3 |
| Batch size (per device) | 2 |
| Gradient accumulation steps | 4 |
| Effective batch size | 8 |
| Learning rate | 2e-4 |
| LR scheduler | cosine |
| Max sequence length | 2048 |
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| LoRA target modules | q_proj, k_proj, v_proj, o_proj |
| Quantization | 4-bit (bitsandbytes NF4) |
| Optimizer | paged_adamw_32bit |
| Metric | Value |
|---|---|
| Training time | ~79 seconds |
| Final training loss | 1.189 |
| Token accuracy | ~81% |
pip install transformers peft accelerate bitsandbytes torch1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
3from peft import PeftModel
4
5BASE_MODEL = "Qwen/Qwen2.5-Coder-7B-Instruct"
6ADAPTER = "tazwarrrr/rocmport-qwen-wavefront-finetuned"
7
8# 4-bit quantization for memory efficiency
9bnb_config = BitsAndBytesConfig(
10 load_in_4bit=True,
11 bnb_4bit_quant_type="nf4",
12 bnb_4bit_compute_dtype=torch.float16,
13)
14
15tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL, trust_remote_code=True)
16
17base_model = AutoModelForCausalLM.from_pretrained(
18 BASE_MODEL,
19 quantization_config=bnb_config,
20 device_map="auto",
21 trust_remote_code=True,
22)
23
24model = PeftModel.from_pretrained(base_model, ADAPTER)
25model.eval()
26
27# ── Inference ──────────────────────────────────────────────────────────────
28BUGGY_HIP = """
29__global__ void warp_reduce(float* data, float* result) {
30 float val = data[threadIdx.x];
31 // BUG: hardcoded warp size 32, wrong for AMD wavefront-64
32 for (int offset = 16; offset > 0; offset >>= 1)
33 val += __shfl_down(val, offset, 32);
34 if (threadIdx.x % 32 == 0)
35 result[threadIdx.x / 32] = val;
36}
37"""
38
39prompt = (
40 "Fix the following buggy HIP kernel so it runs correctly on AMD hardware "
41 "with wavefront size 64 (gfx942 / MI300X). Output only the corrected kernel.\n\n"
42 f"```cpp\n{BUGGY_HIP.strip()}\n```"
43)
44
45messages = [
46 {"role": "system", "content": "You are an expert AMD GPU programmer. Fix HIP kernels for wavefront-64."},
47 {"role": "user", "content": prompt},
48]
49
50text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
51inputs = tokenizer(text, return_tensors="pt").to(model.device)
52
53with torch.no_grad():
54 outputs = model.generate(
55 **inputs,
56 max_new_tokens=512,
57 temperature=0.2,
58 do_sample=True,
59 pad_token_id=tokenizer.eos_token_id,
60 )
61
62response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
63print(response)Note: The adapter is not merged into the base weights. You must always load the base model first and then apply the adapter viaPeftModel.from_pretrainedas shown above. To merge for faster inference seemodel.merge_and_unload()in the PEFT docs.
hipify-generated HIP kernels that contain wavefront-size bugs before deployment on AMD GFX9 / CDNA hardware.peft and the original base model (~15 GB).1@misc{ahnaf2026rocmport,
2 author = {Tazwar Ahnaf},
3 title = {ROCmPort AI: LLM-Assisted CUDA-to-HIP Porting with Wavefront Bug Correction},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/tazwarrrr/rocmport-qwen-wavefront-finetuned}},
7}