Fine-Tuning Gemma 4 on a Laptop iGPU: Debugging MATLAB Signal Processing Code in Practice

Fine-tuning Gemma 4 edge models with LoRA/QLoRA on a laptop iGPU nearly doubles MATLAB signal processing code pass rates.
This article reviews a study that fine-tuned Gemma 4 edge models E2B and E4B on a laptop integrated GPU to improve the correctness of generated MATLAB DSP code. Using 66 checked examples across 11 signal processing subtasks, LoRA and QLoRA reduced training memory, and OpenVINO deployed int8 models and adapters locally. E2B's pass rate rose from 18/66 to 37/66, and E4B (QLoRA) from 32/66 to 47/66. Analysis of 159 failing programs showed the adapters mainly fixed DSP convention errors (delay signs, units, array shapes) but improved signal construction and noise-addition logic only marginally. The adapters add 17-19% generation time overhead, and the fully localized pipeline suits offline and privacy-sensitive scenarios.
Small language models running locally make it convenient to write signal processing code offline, but they often make systematic mistakes about digital signal processing (DSP) conventions. A recent study tuned the Gemma 4 edge models E2B and E4B on a laptop's integrated GPU (iGPU) using supervised fine-tuning (SFT) and low-rank adaptation (LoRA/QLoRA), significantly improving the pass rate of generated MATLAB signal processing code. This article takes a deep dive into the experimental design, results, and implications.

Why Fine-Tune Edge Models?
Small models can run offline on a laptop, making them attractive for writing signal processing code, but they frequently make DSP convention errors, such as sign errors in delays, unit mistakes, or array shape errors. These errors are small but cause the code to fail checks. The researchers collected 66 checked examples covering 11 MATLAB signal processing subtasks to fine-tune Gemma 4's E2B and E4B models.
Fine-tuning used two lightweight methods, LoRA and QLoRA, performed on the laptop's integrated GPU, and finally deployed 8-bit integer (int8) models and adapters via OpenVINO. This end-to-end localized pipeline offers a feasible example of model customization in resource-constrained environments.
Experimental Setup and Fine-Tuning Methods
The study used Gemma 4 edge models E2B and E4B, performing SFT on a laptop iGPU. The training data contained 66 checked examples covering 11 MATLAB signal processing subtasks, such as filter design and spectral analysis. LoRA and QLoRA were used to reduce training memory, and OpenVINO was used for int8 quantized deployment, with adapters dynamically loaded at inference time.
Evaluation used held-out variants, scored by a deterministic checker. This scoring approach avoids subjective bias and ensures reliable results. The experiment also recorded the impact of adapters on generation speed.
Difference Between LoRA and QLoRA: LoRA (low-rank adaptation) freezes the original model weights and injects trainable low-rank matrices (typically the product of two small matrices, A and B) into positions such as attention layers, updating only these parameters and thereby reducing the number of trainable parameters to roughly one-thousandth of the original model. QLoRA builds on this by first quantizing the base model weights to 4 bits (formats such as NF4), then attaching LoRA adapters on top, and dequantizing during backpropagation to compute gradients, so memory usage is lower and larger models can be fine-tuned on consumer-grade GPUs or even integrated GPUs. The cost is a small accuracy loss from quantization and extra dequantization overhead. The 8-bit int8 quantization mentioned in this article is an inference optimization at the deployment stage, which is a different step from the 4-bit quantization during QLoRA training and should not be confused.
Performance Gains: Pass Rate Nearly Doubles
On held-out variants, the E2B model's pass rate rose from 18/66 to 37/66 (identical for LoRA and QLoRA), and the E4B model (QLoRA) rose from 32/66 to 47/66. This shows that fine-tuning can substantially reduce convention errors. The researchers read all 159 failing programs and found that the adapters eliminated most convention errors (such as delay signs, units, and array shapes), but improved errors in constructing signals and noise only marginally.
The adapters impose a 17-19% generation speed overhead at runtime, a factor to weigh in local deployment. Nevertheless, the improvement in pass rate is significant, especially for the E4B model, where a pass rate approaching 50% means nearly half of the generated code can be used directly.
How the pass rate is measured: Here, the pass rate refers to the proportion of MATLAB code generated by the model that a deterministic checker judges as fully passing on given test cases, expressed as "number passed/total." The deterministic checker typically scores by running the code and comparing outputs (numerical error within tolerance, array dimensions matching, no exceptions thrown, etc.), rather than relying on human or another model's judgment, so results are reproducible and comparable across runs. Note that the 66 held-out variants are a small sample, with a single case corresponding to about 1.5 percentage points, so differences in pass rate should be interpreted alongside failure case analysis rather than by numbers alone. In addition, "passing" only means satisfying the assertions covered by the checker, not that the code is correct for all broader inputs.
Error Analysis: What Got Fixed?
By analyzing failure cases, the researchers categorized errors into convention errors and construction errors. Convention errors involve DSP-specific rules, such as signs, units, and shapes; construction errors involve the logic of signal generation and noise addition. The adapters mainly fixed the former, indicating that fine-tuning can effectively instill domain conventions but has limited ability to improve complex logic.
This suggests that for tasks relying on specific conventions, fine-tuning is an efficient approach; for tasks requiring deeper reasoning, more data or stronger models may be needed.
Deployment and Speed Trade-offs
Using OpenVINO to deploy int8 models and adapters enables offline operation on a laptop. The adapters add 17-19% to generation time but deliver a substantial improvement in pass rate. For interactive coding assistance, this overhead is acceptable; for batch generation, optimization should be considered.
The entire pipeline is fully localized, requiring no cloud resources, making it suitable for privacy-sensitive or offline scenarios.
Limitations and Future Directions
The current fine-tuning uses only 66 examples covering 11 subtasks, a limited data scale. Future work could extend to more tasks and examples and explore other parameter-efficient fine-tuning methods. In addition, errors in constructing signals and noise still need improvement, possibly by combining program synthesis or reinforcement learning.
This study demonstrates the feasibility of fine-tuning small models on edge devices to correct domain-specific errors, offering new ideas for local AI-assisted programming.
Key Takeaways
- Fine-tuning Gemma 4 edge models with LoRA/QLoRA on a laptop iGPU significantly improves the pass rate of MATLAB signal processing code.
- E2B's pass rate rose from 18/66 to 37/66, and E4B from 32/66 to 47/66.
- The adapters mainly fix convention errors (signs, units, shapes), with limited improvement in signal construction errors.
- Runtime adapters impose a 17-19% speed overhead, but the pass rate improvement is significant.
- The fully localized pipeline deploys int8 models via OpenVINO, suitable for offline scenarios.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.