Okay, let's break down why you might be seeing lower-than-expected performance (15 t/s) with Qwen3 on your AMD RX "8700xt" (I'll assume this is likely an RX 7800 XT or similar RDNA 3 card, as 8700 XT isn't a standard model name – the principles apply to most modern AMD GPUs) using both llama.cpp and Ollama. Seeing the same relatively low speed on both platforms suggests a common issue, likely related to how the GPU is being utilized.
The 100+ t/s figures reported on places like /r/LocalLLaMA often require specific conditions (very small models, aggressive quantization, sometimes focusing on prompt processing speed, or specific hardware/settings), but 15 t/s is definitely lower than expected for your hardware with a reasonably sized model like Qwen3 7B at a common quantization (e.g., Q4_K_M).
Here are the most critical parameters and factors to investigate:
-
GPU Offloading (-ngl / n-gpu-layers): THIS IS THE MOST LIKELY CULPRIT.
- What it does: This parameter tells
llama.cpp (and indirectly Ollama) how many layers of the neural network model to load into your GPU's VRAM. The more layers offloaded to the GPU, the faster the inference speed, provided you have enough VRAM.
- In
llama.cpp: You must specify this manually using the -ngl X (or --n-gpu-layers X) command-line flag. X is the number of layers. A common practice is to set X to a very high number (e.g., -ngl 99 or -ngl 1000). llama.cpp will then load as many layers as possible until it runs out of VRAM and report how many layers were actually offloaded during startup. If you don't specify -ngl or set it too low (like -ngl 0), most or all of the work will be done on the CPU, resulting in very low t/s.
- In
Ollama: Ollama attempts to automatically determine the optimal number of layers to offload based on your available VRAM. However, this detection isn't always perfect, especially with different drivers or system configurations. If Ollama underestimates your available VRAM or fails to properly engage the GPU, performance will suffer. You can check Ollama's logs (location depends on OS, often via journalctl -u ollama on Linux or the server console output) to see if it reports errors or mentions GPU usage. While less direct than llama.cpp, you can sometimes influence this via custom Modelfiles.
-
Correct Backend/Build for AMD (ROCm):
llama.cpp: If you compiled llama.cpp yourself, you must ensure you built it with ROCm support enabled (e.g., using LLAMA_ROCM=1 make). If you downloaded a pre-built binary, verify it's the version intended for AMD GPUs with ROCm. Using a CPU-only or CUDA (Nvidia) build will result in no GPU acceleration on AMD.
Ollama: Ollama typically bundles the necessary ROCm libraries. However, conflicts or installation issues can still occur. Check the Ollama logs for any errors related to ROCm or GPU detection.
-
AMD Drivers and ROCm Installation:
- Running GPU-accelerated tasks on AMD requires the correct AMD Adrenalin drivers (Windows) or the ROCm compute stack (Linux). Ensure your drivers are up-to-date. On Linux, installing and configuring ROCm correctly is crucial and can sometimes be complex depending on the distribution and kernel version. An incomplete or faulty ROCm installation will prevent GPU offloading.
-
Model Quantization:
- Which specific Qwen3 GGUF file are you using? (e.g.,
qwen2-7b-instruct-q4_K_M.gguf) Lower quantizations (like Q2_K, Q3_K_S/M) are generally faster but sacrifice quality. Higher quantizations (Q5_K_M, Q6_K, Q8_0) are slower and use more VRAM. Ensure you're comparing apples-to-apples with the reports you're seeing online. 15 t/s might be reasonable for a very high quantization or a much larger model variant (e.g., 72B), but not for a 7B Q4_K_M.
-
System Monitoring:
- Use monitoring tools while running the model:
- Windows: Task Manager (Performance tab, select GPU, check "Compute" engine usage and dedicated VRAM usage) or AMD Adrenalin Software overlay.
- Linux:
radeontop, nvtop (often works for AMD too), or watch -n 1 rocm-smi.
- Check:
- GPU Compute Utilization: Is it high (e.g., 80-100%) during token generation? If it's low or 0%, the GPU isn't being used correctly (likely an
-ngl or driver/ROCm issue).
- VRAM Usage: Is a significant portion of your GPU's VRAM being used? If very little is used,
-ngl is likely too low or offloading failed. If it's completely maxed out and performance is low, you might be offloading too many layers for the context size, causing swapping or issues, though this usually manifests as an out-of-memory error.
- CPU Usage: Is one CPU core hitting 100%? This can happen if the GPU isn't being used, or if there's a bottleneck in transferring data.
Troubleshooting Steps:
- Focus on
llama.cpp first for clarity:
- Confirm you have a ROCm-enabled build.
- Use a standard model like
qwen2-7b-instruct-q4_K_M.gguf.
- Explicitly add
-ngl 99 to your command. Example: ./main -m models/qwen2-7b-instruct-q4_K_M.gguf -p "Explain quantum physics simply" -n 256 -ngl 99
- Carefully read the startup messages from
llama.cpp. It should detect your AMD GPU and state how many layers (xx / yy) it successfully offloaded to the GPU.
- Monitor GPU utilization and VRAM usage while it generates tokens.
- Verify Drivers/ROCm: Double-check that your AMD drivers and (if on Linux) the ROCm stack are correctly installed and functional. Sometimes a reinstall is necessary.
- Test
Ollama again: Once you confirm llama.cpp works well with high -ngl, try Ollama again. Check its logs (journalctl -u ollama or console output) for GPU detection messages or errors. If performance is still low, the issue might be Ollama's automatic detection on your specific system.
The most frequent cause of slow performance on capable hardware is simply not telling the software to actually use the GPU by setting the appropriate number of layers to offload (-ngl).