Fine-tuning a Medical Large Model on AMD ROCm: A Hands-on Example Without Relying on CUDA

The developer hackathon between Lablab.ai and AMD produced a complete MedQA fine-tuning tutorial, running entirely on AMD Instinct GPUs, proving that the ROCm ecosystem for LLM fine-tuning has moved beyond the presentation stage.
A CUDA-Free Medical Model Fine-Tuning Example Silently Proves ROCm Is Ready
Recently, the official Hugging Face blog featured a hands-on tutorial from the Lablab.ai × AMD Developer Hackathon: fine-tuning the MedQA medical question-answering model on AMD Instinct GPUs using the full ROCm stack. The entire workflow runs without a single line of CUDA or a single call to nvidia-smi, yet still turns a general-purpose base model into a specialized one that performs well on clinical QA benchmarks.
While the event itself isn’t a flashy headline, at this point in 2026, its symbolic value outweighs its technical novelty. Over the past two years, nearly every “I can fine-tune an LLM too” tutorial has assumed you own an H100—or at least a 4090. Under the hood, PyTorch, bitsandbytes, Flash-Attention, and vLLM all rely on CUDA kernels. On the AMD side, “open ecosystem” has been the mantra for years, yet there have been few plug-and-play end-to-end tutorials that “just run.” This MedQA tutorial is one of the few public demos to fully complete the chain—and to do so in a genuinely valuable real-world scenario (clinical QA).

The Bottom Line First: ROCm Learned a Lot More This Year Than You Might Think
After reading the whole tutorial, my impression is—the developer experience on AMD has progressed from “it runs” to “it runs without modification.” A few concrete observations:
- The official PyTorch ROCm wheel can be installed via
pip—no source compilation required; - The Hugging Face Transformers + PEFT + TRL stack runs nearly seamlessly on ROCm; the LoRA and QLoRA processes match the CUDA side;
- Flash-Attention now has a ROCm-compatible version, so long-context training is no longer a performance pitfall;
- Even bitsandbytes, historically the troublemaker, has a usable ROCm branch—4-bit quantized training now works.
In other words, the awkward 2024 experience of “ROCm installs, but every library needs manual patches” is largely a thing of the past. That’s why this MedQA example can confidently advertise “copy and paste to run”—behind it is a year’s worth of glue code merged upstream through joint effort by AMD and the open-source community.
Why MedQA Is a Representative Task
Choosing MedQA as the fine-tuning target is an interesting move. It isn’t an “alignment” task like “make the model more polite,” but rather a domain knowledge injection task with clear right and wrong answers—USMLE-style multiple-choice questions that can’t be gamed by phrasing.
The tutorial follows the classic recipe:
- Base model selection: starting from a 7B open-source instruction-tuned model—a balance between VRAM footprint and adaptability;
- Data processing: converting the MedQA dataset into instruction format, prompting “You are a clinical doctor, please choose the most appropriate diagnosis/treatment from the following options”;
- LoRA fine-tuning: rank 16, training only the attention projection matrices, running smoothly on a single MI250X card;
- Evaluation: before-and-after testing on the MedQA benchmark, reporting accuracy improvement—cleaner than many blog tutorials out there.
One important detail: the tutorial specifically emphasizes using bf16 instead of fp16 for mixed-precision training on ROCm. The Instinct series natively supports bf16 well, whereas fp16 can trigger fallback paths for certain operators—a common pitfall for developers migrating from CUDA.
So, How Far Behind (or Ahead) Is ROCm Compared to CUDA?
That’s the question everyone asks. The tutorial itself doesn’t provide strict benchmarks (it’s a hackathon output, after all), but based on public data and my experience, the current situation looks roughly like this:
- Training throughput: MI300X vs. H100 shows a 10%–20% gap at the 7B–13B LoRA fine-tuning scale, sometimes even outperforming in specific cases;
- Inference: vLLM support for ROCm is now merged into the main branch, throughput is effectively on par;
- Ecosystem completeness: still trailing a bit. Some third-party frameworks (e.g., Axolotl, LLaMA-Factory) treat ROCm as “usable but not first-class,” and GitHub issue responses are slower;
- Memory-to-cost ratio: AMD’s real killer feature. With 192 GB of HBM3 on a single MI300X, multi-card communication overhead for 70B-scale models is greatly reduced—often balancing out or even surpassing raw performance differences.
For developers, this means: if you’re doing mainstream fine-tuning like LoRA/QLoRA, ROCm is now a serious option; but if you rely heavily on custom kernels available only for CUDA, migration cost still exists.
Why It’s Worth Tackling the Medical Vertical Now
Let’s talk about medical LLMs. This year, Google’s MedGemma 1.5 and other companies’ specialized medical models highlight a clear consensus: general-purpose LLMs hit a ceiling in medical contexts; specialized fine-tuning isn’t optional—it’s mandatory.
The reasons are straightforward:
- Medical knowledge updates rapidly—cutoff dates in general models are a hard limitation;
- Clinical language distributions differ drastically from web data—zero-shot quality is unstable;
- Compliance and explainability requirements demand controllable model behavior, not just a black-box API.
This makes “fine-tuning a domain model on your own hardware with your own data” a necessity. The MedQA tutorial’s value lies in offering a minimal viable reference—you don’t need an entire NVIDIA DGX setup; a single AMD Instinct machine (or cloud instance) can complete the full pipeline.

Practical Tips for Developers Ready to Try
If you want to reproduce it, here are a few hands-on recommendations:
- Use the official Docker image first. The
rocm/pytorchimage version must strictly match your driver version—lower host drivers will cause mysterious segmentation faults; - Do data preprocessing on the CPU. Tokenizing on GPU offers no benefit—small-batch scheduling overhead wastes time;
- Enable gradient checkpointing. For a 7B + LoRA setup, VRAM pressure isn’t high, but it’s a good habit for later scaling to 13B/34B;
- Separate evaluation from training code. For multiple-choice tasks like MedQA, comparing token probabilities between options is far more robust than having the model generate and then parse answers.
As for inference deployment—if you want to serve the trained model without setting up vLLM yourself—OpenAI Hub now supports hosting open-source medical models with OpenAI-compatible APIs. That eliminates most ops overhead, letting your team focus on data and evaluation.
In Conclusion
The tutorial itself is modest in scope, but the trend it signals is clear: hardware choices for LLM fine-tuning are shifting from “NVIDIA only” to “there’s a second path.” For Chinese developers, this may matter even more than for their North American peers—another hardware path means greater supply-chain resilience.
ROCm isn’t flawless yet—but it’s past the “tutorials don’t run” stage. What remains is simply: who’ll be brave enough to be the first adopter?
References
- MedQA: Fine-Tuning a Clinical AI on AMD ROCm — No CUDA Required (Hugging Face Blog) — The original tutorial on which this article is primarily based, including full code and dataset details.



