Views
No views yet
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4
5base_model = AutoModelForCausalLM.from_pretrained(
6 "Qwen/Qwen3-32B",
7 torch_dtype=torch.bfloat16,
8 device_map="auto",
9 trust_remote_code=True,
10)
11model = PeftModel.from_pretrained(base_model, "shaunak1234/qwen3-32b-lora-finetome")
12tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-32B", trust_remote_code=True)
13
14messages = [
15 {"role": "system", "content": "You are a helpful, accurate, and thoughtful assistant."},
16 {"role": "user", "content": "Explain the difference between TCP and UDP, and when you'd choose each for a real-world application."}
17]
18
19text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20inputs = tokenizer(text, return_tensors="pt").to(model.device)
21outputs = model.generate(**inputs, max_new_tokens=1024, temperature=0.7, top_p=0.9)
22print(tokenizer.decode(outputs[0], skip_special_tokens=True))1from peft import PeftModel
2from transformers import AutoModelForCausalLM
3import torch
4
5base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-32B", torch_dtype=torch.bfloat16)
6model = PeftModel.from_pretrained(base, "shaunak1234/qwen3-32b-lora-finetome")
7merged = model.merge_and_unload()
8merged.save_pretrained("qwen3-32b-finetome-merged")
9# Serve with vLLM, TGI, or any inference framework| Parameter | Value |
|---|---|
| LoRA rank (r) | 64 |
| LoRA alpha | 128 |
| LoRA dropout | 0.05 |
| Target modules | all-linear |
| Batch size | 8 |
| Gradient accumulation | 4 |
| Effective batch size | 32 |
| Learning rate | 2e-4 |
| LR scheduler | Cosine |
| Warmup ratio | 0.05 |
| Weight decay | 0.01 |
| Max sequence length | 4096 |
| Epochs | 1 |
| Total steps | 765 |
| Precision | bfloat16 |
| Gradient checkpointing | Yes |
| Component | Details |
|---|---|
| GPU | AMD Instinct MI300X (192GB HBM3) |
| Platform | AMD DevCloud |
| Software | PyTorch 2.5.1 + ROCm 6.2 |
| Framework | Transformers 4.51.3, PEFT 0.15+ |
| Training speed | ~33-35 seconds/step |
| Total training time | ~7 hours |
| Cost | ~$14 (at $2/hr) |