Fine-Tuning Gemma 4 Edge Models for MATLAB Signal-Processing Code with SFT and QLoRA on a Laptop iGPU
Organizations: Independent researcher, Gölbaşı, Ankara, Türkiye
Abstract
Small language models that run on a laptop are attractive for writing signal-processing code offline, but they make systematic errors on digital signal processing (DSP) conventions. We apply supervised fine-tuning (SFT) to the Gemma 4 edge models E2B and E4B with 66 checked examples covering 11 signal-processing MATLAB subtasks, using low-rank adaptation (LoRA) and quantized LoRA (QLoRA) on the integrated GPU (iGPU) of a laptop, and deploy the 8-bit integer (int8) models with the adapters through OpenVINO. On held-out variants scored by deterministic checkers, the pass rate rises from 18/66 to 37/66 (LoRA) and 37/66 (QLoRA) for E2B and from 32/66 to 47/66 for E4B (QLoRA). Reading all 159 failing programs shows that the adapters remove most errors of convention, such as the sign of a lag, units and array shapes, but few errors in building signals and noise. Applied at run time, the adapter costs 17-19% of the generation speed.
Figures & tables
| Label | Subtask | Checks | |
|---|---|---|---|
| 1 | xcorr_delay | integer delay between two LFM channels from the xcorr peak | integer delay (from xcorr ); channel 2 = delayed channel 1 w |
| 2 | xcorr_fine | fractional delay in noise: xcorr peak refined by a parabola | refined delay ( samples) r ; channel 2 = delayed channel 1 w ; noise level of both channels w |
| 3 | noise_power | complex tone plus noise at a given SNR; measured powers | noise power r ; variance of the real part r ; power of r ; = tone + noise w |
| 4 | matched_output | matched filter of an LFM pulse with conv : length, peak index, peak | length; peak index; peak magnitude |
| 5 | conv_delay | delay of a pulse in a receive window from the matched-filter peak | peak index; delay from the peak index |
| 6 | fft_noise_power | mean of complex noise after an unscaled FFT, measured and theoretical | measured mean r ; theoretical mean |
| Adapter | Base weights | Trainable | Loss per epoch | Time | Peak iGPU |
|---|---|---|---|---|---|
| E2B LoRA | bf16 | 24.2 M | 0.35 / 0.23 / 0.17 | 31 min | 6.9 GB |
| E2B QLoRA | NF4 | 24.2 M | 0.38 / 0.25 / 0.19 | 53 min | 4.4 GB |
| E4B QLoRA | NF4 | 34.9 M | 0.40 / 0.27 / 0.20 | 44 min | 6.3 GB |
| Passed | Mean | Mean | Time | |||
|---|---|---|---|---|---|---|
| Model | of 66 | of 63 ∗ | score | tokens | per run | OpenVINO |
| E2B base | 18 | 17 | 46.5 | 1769 | 50 s | 2026.4.1 / 2026.5 † |
| E2B LoRA | 37 | 35 | 71.3 | 1286 | 42 s | 2026.4.1 |
| E2B QLoRA | 37 | 35 | 69.9 | 1546 | 48 s | 2026.4.1 |
| E4B base | 32 | 30 | 68.7 | 1713 | 121 s | 2026.5 † |
| E4B QLoRA | 47 | 47 | 84.7 | 1283 | 106 s | 2026.4.1 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| E2B | E4B | |||||
|---|---|---|---|---|---|---|
| Class | Definition | base | LoRA | QLoRA | base | QLoRA |
| lag/index convention | lag sign from the xcorr argument order, zero-lag index, delay read from the conv peak without the pulse-length offset, 0-based index of max | 17 | 6 | 5 | 18 | 2 |
| units | MHz/µs not converted to Hz/s, µs mixed with s | 15 | 9 | 7 | 4 | 0 |
| array shape | row and column vectors mixed (an matrix), wrong matrix layout | 9 | 1 | 3 | 3 | 2 |
| sample count | number of samples or pulses or the time grid off by one ( ceil(T*fs) , linspace(0,T,N) , a missing ) | 2 | 2 | 1 | 7 | 1 |
| matched filter | matched filter without time reversal ( conj(s) or s ) | 4 | 0 | 1 | 0 | 0 |
Code Generation
Code generation studies methods for turning natural-language, visual, or formal specifications into executable programs and code edits.
See all 357 papers