WorksComputer Science
Fine-Tuning Gemma 4 Edge Models for MATLAB Signal-Processing Code with SFT and QLoRA on a Laptop iGPU
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.
Introduction
Signal-processing engineers write much of their code in MATLAB: they synthesise pulses and chirps, correlate channels, filter, take fast Fourier transforms (FFTs) and set detection thresholds. Language models can draft such code, and small models that run on a laptop can do so without sending anything off the machine, which matters where the work cannot leave it. The Gemma 4 edge models E2B and E4B [1] are made for this kind of device. On our tasks, however, they often get the conventions of the field wrong: they read the delay with the wrong sign from xcorr, forget the gain of an unscaled FFT, write a chirp rate in the wrong unit or mix row and column vectors. Such code runs and prints a plausible number, which makes the errors hard to notice.
Low-rank adaptation (LoRA) [2] and its quantized variant QLoRA [3] make supervised fine-tuning (SFT) of such models possible with little memory. We ask how much a small set of checked examples, trained on the integrated GPU (iGPU) of the same laptop, improves the code these models write, and which errors it removes.
Answering this needs three things. First, tasks whose answers can be checked automatically. Following the practice of judging generated code by running it [4], we wrote 11 parametric subtasks from signal-processing work, run every answer in an emulator of a MATLAB subset, and score it with checkers that also reject values copied from the prompt or computed from a formula instead of measured. Earlier work compared commercial and open models on generating MATLAB code for automated-driving scenarios [5]; here the models are small enough to run on a laptop and the domain is digital signal processing (DSP). Second, training data. Instead of collecting the model’s own correct answers, which were too rare, we let the small model write the reasoning for an expert’s solution and then the answer itself, close to the rationalization step of the Self-Taught Reasoner (STaR) [6], and kept only answers that pass the checkers. Third, a way to train and deploy on a laptop: the Parameter-Efficient Fine-Tuning (PEFT) library [7] on the integrated GPU for training, and OpenVINO GenAI [8] with 8-bit integer (int8) weights for inference.
Our contributions are:
11 parametric MATLAB signal-processing subtasks with deterministic checkers; the prompts of the held-out variants are listed in appendix § 9;
a procedure in which the small model itself writes 66 training examples from expert solutions, with automatic filters and a reading of every example;
LoRA and QLoRA adapters for E2B and E4B trained on a laptop GPU in under an hour each and run with int8 OpenVINO models;
an evaluation on held-out variants in which the adapters double the pass count of E2B and raise that of E4B from 32 to 47 of 66, and an analysis of all 159 failing programs that shows which errors the adapters remove and which they do not.
§ 2 describes the subtasks, the emulator and the checkers, § 3 the training data and § 4 the training and deployment. § 5 gives the results, § 6 the error analysis and § 7 the limitations.
Tasks and evaluation
Subtasks
The tasks come from signal processing: delay estimation between two receive channels, matched filtering, FFT-based detection, frequency-modulated continuous-wave (FMCW) and linear frequency-modulated (LFM) waveform generation, and synthetic pulse descriptor words (PDWs), which list each pulse with its time of arrival (TOA) and other parameters. In a first measurement, E2B failed every run of most of these complete tasks, so we split them into the steps at which the models failed. This gives the 11 subtasks of Table 1. Each subtask asks for a short MATLAB script that builds a signal, processes it and prints a few numbers.
| 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{sup}w` |
| 2 | xcorr_fine | fractional delay in noise: xcorr peak refined by a parabola | refined delay ( samples){sup}r; channel 2 = delayed channel 1{sup}w; noise level of both channels{sup}w` |
| 3 | noise_power | complex tone plus noise at a given SNR; measured powers | noise power{sup}r; variance of the real part{sup}r; power of {sup}r; $x$ = tone + noise{sup}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{sup}r`; theoretical mean |
| 7 | exp_threshold | threshold on for a false-alarm probability (exponential law) | threshold on ; threshold on |
| 8 | fft_bin_snr | tone in noise: peak bin, measured and theoretical SNR after the FFT | peak bin (1-based); measured SNR{sup}r`; theoretical SNR |
| 9 | fmcw_freq | instantaneous-frequency vector of a sawtooth or triangular FMCW signal | length; minimum; maximum; value at a given time |
| 10 | lfm_single | one complex baseband linear chirp stored in a vector | instantaneous frequency of the vector{sup}w` |
| 11 | pdw_single | pulse descriptor words (PDW matrix) of one emitter with constant pulse repetition interval (PRI) | number of PDWs; last TOA; PDW matrix{sup}w; rows sorted by TOA{sup}w |
Table 1. Table 1. The 11 subtasks and the checks that score them. {sup}r: noise-dependent value, accepted only if it changes when the code runs again with another seed. {sup}w: workspace check on the arrays left by the code rather than on the printed output. Every subtask also scores the error-free run of the code.
Every subtask is a parametric template. A variant is drawn from a random generator seeded with the subtask name and the variant index, so every variant is reproducible. The generator draws sampling rates, lengths, delays, bandwidths, amplitudes and signal-to-noise ratios (SNRs), writes the prompt in English and computes the expected values with NumPy and SciPy. A variant is drawn again when an expected value equals a number in the prompt or a frequent constant (2, 10, 20, 100): such a value could be copied instead of computed. Variants 0–5 of each subtask are used to make training data (section 3); variants 6 and 7 are held out for evaluation. The held-out variants come from the same distribution as the training variants, so the evaluation measures generalisation to new parameters of known subtasks, not to new subtasks. Each template also has a reference solution, which scores 100 on both held-out variants of every subtask. Appendix § 9 lists the prompt of variant 6 of every subtask with its expected values.
MATLAB emulator
We run the generated code in our own MATLAB emulator, since no MATLAB installation was available. The emulator parses a subset of the MATLAB language into a syntax tree and evaluates it on NumPy arrays; it does not translate MATLAB to Python and never calls exec. It provides 445 built-in functions, among them xcorr, conv, fft, randn, repmat, interp1 and polyfit. Code cannot call system or eval, cannot read or write files and can create no array with more than 20 million elements. Error messages start with MATLAB’s own wording, so a model that knows MATLAB errors sees familiar text. N-dimensional arrays, struct arrays, integer types, global and classdef are not supported. The emulator can differ from MATLAB in corner cases; we return to this in section 7.
Checkers and score
The code is taken from the matlab blocks of the answer and run as written: there is no automatic repair, and the emulator’s own hints are switched off. A run stops after 120 s. The checker parses every number of the printed output and looks for each expected value within a tolerance. Several rules make sure that a value is computed by the code rather than copied or derived from the prompt.
Numbers written as literals in the code (comments excluded) are not accepted as results.
A noise-dependent value (marked ) is accepted only if it changes when the code runs a second time with another seed and with its own
rngcall disabled. A number printed identically twice was computed from a formula, not measured.
A value that must come from a peak index (the integer delay and the matched-filter peak) is checked by a second run in which the output of
xcorrorconvis shifted by one sample. The printed value must move with it. A delay printed fromtau*fsdoes not move.
Some values count only if the code called the function the prompt names (
xcorrorconv).
Workspace checks (marked {sup}w`) inspect the arrays the code leaves behind. They check that channel 2 is channel 1 delayed by , that the noise outside the pulse has the requested level in both channels, that is the tone plus noise, that the instantaneous frequency of the stored chirp or FMCW vector follows the requested profile, and that the PDW matrix holds the right rows.
The score of a run is 20 points for running without error plus 80 points shared among the checks of the subtask in proportion to their weights. All weights are 1, except the FMCW signal check (4) and the PDW matrix check (3). A run passes when it scores 100, that is, when the code runs and every check passes.
Protocol
Each model answers each held-out variant once per seed, with seeds 5000–5002. This gives runs per model and adapter. The answer is one-shot: one system message (“You are an assistant that writes MATLAB code. Give the code in a matlab block.”), the English prompt, no tools and no second attempt. Thinking is on, as the Gemma 4 chat template allows. The answer may use up to 5000 tokens; the longest answer had 3063 tokens and no run hit the limit. The models run as int8 OpenVINO models on the laptop’s integrated GPU behind an OpenAI-compatible server ({xref}section 4`). E2B samples with temperature 0.9 and E4B with temperature 0.8, both with top- 0.95 and top- 50. The E2B setting comes from an earlier search over sampling parameters on other MATLAB tasks; the E4B setting is the one we used with E4B before this work.
Training data
The training set has one example for each training variant: 66 examples, six per subtask. An example is a conversation with the system message and the prompt of § 2.4, followed by the model’s thinking and its answer with the MATLAB code, so training and evaluation use the same format. In a first measurement on training variants, E2B passed 16 of 53 runs and none of the runs of 4 subtasks, so rejection sampling of its own answers would have left several subtasks without data and others with very few examples. We therefore made the examples from expert reference solutions, but had E2B write all the text that enters the training set: the thinking and the answer. No larger model writes training text; a larger model wrote only the list of facts that guided some answers in step 3 (see below). Figure 1 shows the three steps; 64 examples come from this pipeline and 2 are answers that E2B wrote on its own and that passed.

Figure 1. How the training examples were made. Step 1 gives E2B the prompt with the expert solution and key points; step 3 gives it only the system message and the prompt, with the accepted thought inserted as its own thinking, so the answer is written as at evaluation time. Only the thought of step 1 and the answer of step 3 enter the training example.
Step 1: thought. E2B receives, with thinking off, the prompt of the variant, an expert’s reference solution of that variant and the key points of the subtask: a short paragraph that states its decisive steps, such as which lag of xcorr is the delay. The key points are written for one variant of each subtask; for 9 of the 64 accepted thoughts they belong to the same variant, otherwise they are introduced as written for a similar task with other numbers. E2B is asked to write the thinking an assistant would go through before writing code, in its own style and in at most 300 words. The instruction forbids mentioning the solution, asks to derive every number from the task and never to state a noise-dependent result as a value, to state each decision exactly, and to reason once without correcting itself. For 3 subtasks (fft_bin_snr, xcorr_delay, xcorr_fine) the instruction also forbids arithmetic: every derived value stays a formula or a MATLAB expression, such as tau*fs or lags(idx), for the code to compute, and every value with a unit is restated in seconds, hertz or Hz/s. In earlier attempts E2B computed bins and delays by hand and got them wrong, and those numbers then went into the code.
Step 2: filter. A thought is rejected when it is shorter than 150 or longer than 900 words, contains a code block, refers to the solution or the key points, corrects itself (wait, hmm), uses vague phrases (depending on), or writes randn(N), which gives an matrix in MATLAB. Every number in the thought must be traceable: it must be a number of the prompt, a value of the reference solution that does not change with the noise seed, or one step away from these (half, double, inverse, square root, dB, a product or quotient of two such numbers, a unit scale). A number that matches only a noise-dependent value of the solution is a measurement the thought cannot know and is rejected. For the formula-only subtasks only the numbers of the prompt and simple one-step forms are allowed, the chirp rate must be restated in Hz/s, and the thought must say that the delay is read from the lags output of xcorr. For the other subtasks every integer the task asks to print (an index, length or count) must appear in the thought as a number.
Step 3: answer. The accepted thought is inserted as E2B’s own thinking in a request that contains only the system message and the prompt, and E2B continues with the answer. The answer is scored by the checkers of § 2.3, and the first answer that scores 100 is accepted; this happened at the first attempt for 43 of the 64 examples and never needed more than 3 attempts. For 17 examples this step used a longer system message with 22 numbered facts about sampling, FFT scaling, correlation and noise, written by Claude Opus 5.5. These facts served only to obtain a correct answer: the training example keeps the plain system message, answers that referred to the facts were rejected, and fact numbers were removed from the answer text.
Reading and hand fixes. Every accepted example was read by hand, and 25 of the 66 were fixed. In 10 examples the fix changed what the code computes or prints. For example, five fft_bin_snr answers set the peak bin to zero and still averaged over all bins, one xcorr_fine answer added the same noise vector to both channels, and one xcorr_delay answer built channel 2 by shifting channel 1 by a whole number of samples. The checkers accepted these answers, because they test the printed values and some arrays, not every step (§ 7). The other 15 fixes changed only the thought, comments, variable names or unused lines, for example a wrong intermediate number in a thought ( MHz Hz) or a chirp rate called a carrier frequency. After the fixes, every example still scores 100 with the current checkers.
The resulting set. The thoughts have 228–436 words, 310 on average. For two subtasks the prompt of variant 3 repeated that of variant 0, and variant 8 was used instead. While writing this paper we found that one held-out variant, fft_noise_power variant 7, has the same prompt as a training example; § 5 also reports the results without it. The training set is not released; the prompts of the held-out variants are listed in appendix § 9.
Fine-tuning and deployment
Hardware. Everything runs on one laptop with an Intel Core Ultra 5 226V processor, its integrated Arc 130V GPU and 16 GB of memory (15.6 GB usable) shared between the CPU and the GPU. Training uses the GPU through PyTorch 2.9.1 with its XPU back end (PyTorch’s device type for Intel GPUs), Transformers 5.22 and PEFT 0.21; QLoRA adds bitsandbytes 0.50.2. Newer PyTorch builds gave wrong results with the installed GPU driver, so we kept 2.9.1.
Adapters. We train three adapters on the same 66 examples (Table 2): a LoRA adapter on the bfloat16 (bf16) weights of E2B, and QLoRA adapters on E2B and E4B, whose base layers are quantized to the 4-bit NormalFloat (NF4) type with double quantization and computed in bf16. E4B has only a QLoRA adapter, because its bf16 weights do not leave enough GPU memory for training. The adapters have rank 16 and , no dropout, and sit on the query, key, value and output projections and the three multilayer perceptron (MLP) projections of every language-model layer. The loss is computed only on the tokens of the thought and the answer, with the prompt formatted by the same chat template as at inference. Training uses AdamW with learning rate and no weight decay, one example per step, gradient clipping at 1, gradient checkpointing and 3 epochs with the examples shuffled in every epoch. There was one training run per adapter; we did not tune these settings.
| 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 |
Table 2. The three adapters, trained on the same 66 examples for 3 epochs. Loss is the mean training loss of each epoch; time is the training time without loading; peak iGPU is the largest memory allocated on the GPU during training.
Deployment. For inference we use the official int8 OpenVINO exports of the two models and OpenVINO GenAI on the GPU, behind a small OpenAI-compatible server. The adapter is loaded as saved by PEFT and applied at run time without merging it into the weights, so the adapter trained on bf16 or NF4 weights runs on int8 weights. The adapter evaluations used OpenVINO 2026.4.1. The E4B base model failed on its first requests with an out-of-resources error of the GPU runtime in that version, so the E4B base evaluation and the E2B base runs with seeds 5001–5002 on four subtasks used a 2026.5 nightly build; § 5 discusses this difference.
Speed. Applying the adapter at run time costs speed. On the E4B server, with the same three general prompts, greedy decoding and 1024 generated tokens each, generation ran at 15.9 tokens/s without the adapter and 13.0 tokens/s with it, a 19% drop. The same measurement on E2B gave 30.7 tokens/s without and 25.4 tokens/s with the LoRA adapter, a 17% drop. For E4B with the adapter, the nightly build and 2026.4.1 gave the same speed (12.9 and 13.2 tokens/s). Merging the adapter into the int8 weights would remove this cost; the run-time merge mode of OpenVINO GenAI accepts only floating-point weights. In the evaluations the adapters also shortened the answers, from 1713 to 1283 tokens on average for E4B, so a run took 106 s with the adapter and 121 s without (42 s and 50 s for E2B with and without LoRA). These run times come from evaluations with different OpenVINO versions and are only indicative.
Results
Pass rates. Table 3 gives the results of the five evaluated models on the 66 held-out runs. Both adapters double the pass count of E2B, from 18 to 37 with LoRA and 37 with QLoRA, and the E4B adapter raises it from 32 to 47. The mean score rises with the pass count, from 46.5 to 71.3 and 69.9 for E2B and from 68.7 to 84.7 for E4B. The adapted models also write shorter answers: E4B with the adapter uses 1283 tokens per answer instead of 1713, E2B with LoRA 1286 instead of 1769. Without the held-out variant whose prompt is also a training prompt (§ 3), the counts change by at most two and the order of the models stays the same (column of 63 in Table 3).
| Model | Passed of 66 | Passed of 63* | Mean score | Mean tokens | Time 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 |
Table 3. Results on the held-out variants (11 subtasks × 2 variants × 3 seeds). A run passes when it scores 100. Bold: the highest pass count and mean score within each model (ties are all bold). *Without fft_noise_power variant 7, whose prompt equals that of a training example. Time per run is the wall time of the answer, thinking included; it depends on the OpenVINO version and is only indicative. †2026.5 nightly build; for E2B base only the runs with seeds 5001–5002 on four subtasks.
Paired comparison. Two models answered the same 66 prompts with the same seeds, so we compare them run by run and count the runs that only one of them passes. The seed pairs the runs only loosely, since the sampled answer also depends on the adapter and on small numerical differences, so the pairing mainly matches prompts. We use the exact two-sided sign test (McNemar’s test) on the discordant pairs. For E2B, 22 runs pass only with LoRA and 3 only without it (); with QLoRA the counts are 25 and 6 (). For E4B, 21 runs pass only with the adapter and 6 only without it (). LoRA and QLoRA on E2B are indistinguishable: 11 runs pass only with one of them and 11 only with the other. The adapted E2B passes more runs than the unadapted E4B (37 and 37 against 32), but the difference is not significant (13 against 8 runs, , for LoRA). With 66 runs per model, only large differences reach significance.
Subtasks. Figure 2 breaks the passes down by subtask. The largest gains are on subtasks where the base models broke conventions of MATLAB and DSP, such as the sign and offset of a lag (§ 6 classifies the errors). The integer delay from xcorr goes from 0 to 2 (LoRA) and 5 (QLoRA) passes for E2B and from 0 to 4 for E4B, and the delay from the matched-filter peak from 0 to 3 and 2 for E2B and from 1 to 4 for E4B. The fractional delay in noise remains the hardest subtask: one run passes, with the E4B adapter. For E2B, the FMCW frequency profile (1, 1 and 1 passes) and the single chirp (3, 3 and 2) do not improve; for E4B the chirp goes from 3 to 6. On the theoretical FFT noise power E4B gets slightly worse with the adapter (4 to 3 passes), while E2B improves (1 to 4 and 5).
Figure 2. Passed runs per subtask (of 6: two held-out variants, three seeds) for E2B without an adapter and with the LoRA and QLoRA adapters (left), and for E4B without and with the QLoRA adapter (right). A missing bar means no run passed.
OpenVINO versions. The E4B base model was evaluated with the 2026.5 nightly build and its adapter with the 2026.4.1 (§ 4), so the E4B comparison mixes two versions. We did not repeat the 66 adapter runs on the nightly build, for three reasons. Both versions run the same int8 weights with the same template and sampling, and fixed seeds do not reproduce an answer exactly even within one version, so a version change acts like a change of seed. With the adapter, both versions generate at the same speed (§ 4). And the one adapter run we repeated on the nightly build, xcorr_delay variant 6, seed 5000, scored 100 as it did on 2026.4.1. For E2B base, 1 of the 16 nightly runs on four subtasks passed, and 0 of the 8 runs of the same subtasks on 2026.4.1. A version effect of the size of the differences in Table 3 would be needed to change the conclusions; we have no sign of one, but we cannot exclude a smaller one.
Error analysis
The checkers tell which value is wrong, not why. To see what the adapters change, every failing code of the five models, 159 in all, was read together with its output and given one or more of 12 error classes. The reading and labelling were done with Claude Opus 5.5. A run can contain several errors; we count, for each model, the runs out of 66 whose code contains a class (Figure 3). Appendix § 10 defines the classes and gives the counts as a table. Two limits apply. Only failing runs were read, so an error that does not change a printed value is not counted, and when a code stops with an error the later lines may hide further errors.
Figure 3. Runs (of 66) whose code contains each error class, for E2B without an adapter and with the LoRA and QLoRA adapters (left) and for E4B without and with the QLoRA adapter (right). Only failing runs were classified; a run can contain several classes.
Conventions are learned. The classes that shrink most are conventions that a reference solution states once and the model can copy. Lag and index conventions fall from 17 runs to 6 (LoRA) and 5 (QLoRA) for E2B and from 18 to 2 for E4B. Without an adapter both models often call xcorr(s1, s2), whose peak lies at the negative lag, and print the delay with the wrong sign; they read the conv peak index as the delay; and they add one to the 1-based index returned by max. Unit errors fall from 15 to 9 and 7 for E2B and from 4 to 0 for E4B, row–column errors from 9 to 1 and 3 for E2B, and the matched filter without time reversal from 4 to 0 and 1. E2B still makes unit errors in 9 (LoRA) and 7 (QLoRA) runs, mostly by writing the chirp rate of the delay subtasks with the wrong power of ten (for example k = 1.808e6 for 1.808 MHz/µs, which is Hz/s), although every training example of these subtasks converts it.
Signal models are not. Errors in how a signal is built change much less. For E2B, waveform errors fall only from 13 to 8 and 10, and 22 of the 25 failures of the chirp and FMCW subtasks in the three E2B models build the chirp phase or the frequency profile wrong: the phase written as instead of the integral of , the slope divided twice by the ramp duration, one ramp instead of four. Building the delayed channel as also stays hard for E2B (6, 6 and 4 runs): the models shift the window to but evaluate the phase at , or shift by a whole number of samples. The noise model is wrong in 11, 7 and 7 E2B runs and in 7 and 6 E4B runs. For the E4B adapter it is the main remaining error: in 3 of its 5 failures on the fractional delay the printed delay is right and only the noise level is wrong, because the pulse power is averaged over the whole vector, zeros included. No training example does this; all of them pass the noise-level check.
Knowledge of the FFT gain. The theoretical value of an unscaled FFT needs the factor : the mean of is and the SNR gain is . Without an adapter both models leave it out in most failing runs of these subtasks. For E2B the adapters reduce this error from 11 to 3 and 4 runs; for E4B it stays at 5 and 5. Six training examples per subtask were not enough to change this answer of E4B.
Examples. The following lines are taken from failing answers, shortened and with variable names abbreviated; the comments are ours.
[R, lags] = xcorr(s1, s2); % E4B base: prints -31, not 31
s2 = circshift(s, round(tau*fs)); % E4B base: delay 9.31 becomes 9
P = mean(abs(channel1).^2); % E4B QLoRA: zeros outside the pulse lower P
theory = variance_x; % E4B QLoRA: N*variance_x expected
k = 11.595e6; % E2B LoRA: 11.595 MHz/us = 11.595e12 Hz/s
n = sigma*randn(N, 1); % E4B base: column noise + row tone: N x N
chirp = exp(1i*2*pi*f.*t); % E2B base: the phase must integrate f
h = conj(s); y = conv(s, h); % E2B base: needs conj(fliplr(s))
Limitations
Emulator instead of MATLAB. All code runs in our own emulator of a MATLAB subset (§ 2.2), not in MATLAB. A difference between the two can fail a correct answer or pass a wrong one. We know of one probable case: an E4B adapter answer on xcorr_delay assigns into a scalar with a logical mask longer than the scalar. MATLAB grows the array in this case, as far as we know, while the emulator stops with an error. We could not check this in MATLAB, and the answer would not necessarily have passed there.
Checkers. The checkers test the printed values and some arrays of the workspace, not every line of the code. Reading the training examples showed that they had accepted wrong code (§ 3). The noise-level check of xcorr_fine was added before the final scoring, after a passing evaluation answer turned out to set the noise from the power of the whole vector; all evaluations were scored again with the final checkers. Other errors that do not change a checked value can remain in passing runs; for example, no check tests whether the two channels of xcorr_fine get independent noise.
Small samples. Each model was evaluated on 66 runs, six per subtask, and each adapter comes from one training run with settings we did not tune. Differences of a few passes between two models, or of one or two passes within a subtask, are within the noise. The seeds pair two models’ runs only loosely, so the paired tests mainly match prompts.
Training data. The 66 examples were made with expert reference solutions, filters, repeated sampling and hand fixes. 25 examples were fixed by hand, 10 of them in what the code computes, and 17 answers were obtained with a system message whose facts were written by a larger model (§ 3). The models therefore learn from text that E2B wrote under guidance, not from E2B’s unaided output. The training data are not released.
What the evaluation covers. The held-out variants come from the same templates as the training variants, and one of them, fft_noise_power variant 7, even has the same prompt as a training example (results without it are in Table 3). The evaluation thus measures new parameters of known subtasks. We did not test new subtasks, longer programs or whether the adapters harm the models on other tasks.
Software and hardware. Two OpenVINO versions were used (§ 5), the adapters were trained on bf16 or NF4 weights and run on int8 weights, and all measurements come from one laptop. Speeds and run times depend on the software version and on system settings and may differ on other machines.
Error labels. The error classes of § 6 were assigned by reading the failing codes with Claude Opus 5.5, and only failing runs were read. Another reader could draw some class boundaries differently, for example between a unit error and a waveform error caused by it.
Conclusion
Sixty-six checked examples, one per training variant, were enough to change how two small models write MATLAB signal-processing code. With a LoRA or QLoRA adapter trained in under an hour on the laptop’s integrated GPU, E2B passed 37 and 37 of 66 held-out runs instead of 18, and E4B 47 instead of 32; QLoRA was as good as LoRA on E2B. The error analysis shows what such a small set teaches: conventions that a solution states once, such as the sign of a lag, the unit of a chirp rate or the shape of an array, largely disappear. Errors in building a signal, such as the phase of a chirp, a delayed channel or the level of the noise, and the FFT gain for E4B, change little. These need more than six examples per subtask, or more examples aimed at the signal model.
The adapter costs 17–19% of the generation speed when it is applied at run time; merging it into the int8 weights would remove this cost. Further work should test the adapters on new subtasks and on tasks outside signal processing, and check the emulator against MATLAB.
Acknowledgements The numbered facts of the generation-time system message (§ 3) were written by Claude Opus 5.5. Assistance on many details was provided by Claude Opus 5.5.
Task prompts
This appendix gives the prompt of held-out variant 6 of every subtask, as the models received it, and the values the checker expects for that variant. Each prompt was sent after the system message of § 2.4. The prompts, the expected values and the reference solutions are generated by the task templates; the training data are not released. In the prompt of pdw_single, RF is the carrier frequency, PW the pulse width, PA the pulse amplitude and DOA the direction of arrival.
1. xcorr_delay: integer delay between two LFM channels from the xcorr peak.
Two channels are sampled at fs = MHz, samples each (t = (0:N-1)/fs). Channel 1 contains a complex LFM pulse s(t) = exp(1j*pi*k*(t - tc).^2) for t0 t0 + Tp and zero elsewhere, with t0 = ns, Tp = ns, k = $3.17 MHz/us and tc = t0 + Tp/2. Channel 2 contains s(t - tau) with tau = ns. There is no noise. Estimate the delay of channel 2 relative to channel 1 in whole samples from the peak of the cross-correlation computed with xcorr and print it.
Expected values: integer delay (from xcorr) 31.
2. xcorr_fine: fractional delay in noise: xcorr peak refined by a parabola.
Two channels are sampled at fs = MHz, samples each (t = (0:N-1)/fs). Channel 1 contains a complex LFM pulse s(t) = exp(1j*pi*k*(t - tc).^2) for t0 t0 + Tp and zero elsewhere, with t0 = ns, Tp = ns, k = 1.808 MHz/us and tc = t0 + Tp/2. Channel 2 contains s(t - tau) with tau = ns. Add independent complex white Gaussian noise to each channel with an SNR of dB relative to the pulse power. Estimate the delay of channel 2 relative to channel 1 in samples: find the peak of the cross-correlation magnitude computed with xcorr, then refine it with parabolic interpolation through the peak and its two neighbours. Print the refined delay in samples with 4 decimals.
Expected values: refined delay 9.31 .
3. noise_power: complex tone plus noise at a given SNR; measured powers.
Generate samples of a complex tone 2*exp(1j*2*pi*f0*t) with f0 = MHz and fs = MHz, and add complex white Gaussian noise so that the SNR (tone power to noise power) is dB; call the noisy signal x. From the noise you generated, print the measured noise power (mean of |noise|^2) and the measured variance of its real part, and print the measured power of x (mean of |x|^2).
Expected values: noise power 0.12649 ; variance of the real part 0.063246 ; power of 4.1265 .
matched_output: matched filter of an LFM pulse with conv: length, peak index, peak.Generate a complex baseband LFM pulse with amplitude 3, bandwidth 2 MHz and duration 10 us, sampled at 5 MHz (
N = T*fssamples,t = (0:N-1)/fs - T/2,s = A*exp(1j*pi*(B/T)*t.^2)). Apply its matched filter to the pulse withconvand print the length of the filter output, the 1-based index of its peak magnitude and the peak magnitude.Expected values: length 99; peak index 50; peak magnitude 450 ± 0.45.
conv_delay: delay of a pulse in a receive window from the matched-filter peak.Generate a complex baseband LFM pulse with amplitude 0.8, bandwidth 2 MHz and duration 40 us, sampled at 10 MHz (
N = T*fssamples,t = (0:N-1)/fs - T/2,s = A*exp(1j*pi*(B/T)*t.^2)). A receiver records 504 samples with no noise: zeros except this pulse, which starts 4.6 us after the first sample. Apply the matched filter withconv(rx, h), wherehis the matched filter of the pulse, and print the 1-based index of the output peak and the delay of the pulse in samples obtained from that index.Expected values: peak index 446; delay from the peak index 46.
fft_noise_power: mean of complex noise after an unscaled FFT, measured and theoretical.Generate 1024 samples of complex white Gaussian noise with variance 4 (total power of each complex sample) and compute
X = fft(x)without any scaling. Print the measured mean of|X|.^2over all bins and its theoretical value.Expected values: measured mean 4096 ± 410; theoretical mean 4096 ± 4.1.
exp_threshold: threshold on for a false-alarm probability (exponential law).In an FFT of pure complex white Gaussian noise, in each bin is exponentially distributed with mean 8192. Compute the threshold
Ton for which the probability of exceeding it is 0.01, and printTand the corresponding threshold on .Expected values: threshold on 37726 ± 75; threshold on 194.23 ± 0.39.
fft_bin_snr: tone in noise: peak bin, measured and theoretical SNR after the FFT.A complex tone
0.5*exp(1j*2*pi*f0*t)withf0 = 70373.5 Hzis in complex white Gaussian noise with an SNR of -10 dB per sample;fs = 1 MHzand 16384 samples,t = (0:N-1)/fs. ComputeX = fft(x)and print the 1-based index of the largest|X|, the measured SNR at the FFT output in dB (|X|^2at that bin divided by the mean|X|^2of all other bins) and the theoretical SNR at the FFT output in dB.
Expected values: peak bin (1-based) 1154; measured SNR ; theoretical SNR .
9. fmcw_freq: instantaneous-frequency vector of a sawtooth or triangular FMCW signal.
An FMCW signal uses sawtooth down-chirp modulation sweeping from down to with , ramp duration 40 us, sampled at 75 MHz, with 4 ramps. Build the vector of its instantaneous frequency in MHz at every sample (sample n at time (n-1)/fs) and print its length, its minimum, its maximum and its value at .
Expected values: length 12000; minimum ; maximum ; value at a given time .
10. lfm_single: one complex baseband linear chirp stored in a vector.
Write MATLAB code that generates a single complex baseband linear chirp sweeping from to with over 40 us, sampled at 20 MHz. Store it in a single vector and print its length.
No printed value is checked; the stored vector is checked in the workspace.
11. pdw_single: pulse descriptor words (PDW matrix) of one emitter with constant pulse repetition interval (PRI).
Write a PDW generator for one emitter. A PDW list is an N x 5 matrix with columns [TOA(us) RF(MHz) PW(us) PA(dBm) DOA(deg)], one row per pulse. The emitter has PRI 80 us, RF 9364 MHz, PW 1 us, PA -31 dBm, DOA 292 deg and its first pulse at TOA 63.5 us; constant PRI, no jitter. Build the PDW matrix of every pulse with TOA < 2000 us and print the number of PDWs and the TOA of the last one.
Expected values: number of PDWs 25; last TOA 1983.5 .
Error classes
Table 4 defines the error classes of § 6 and gives, for each model, the number of runs (of 66) whose code contains the class. A run can contain several classes, so a column does not sum to the number of failing runs.
| Class | Definition | E2B base | E2B LoRA | E2B QLoRA | E4B base | E4B QLoRA |
| lag/index convention | lag sign from the xcorr argument | 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 +1) | 2 | 2 | 1 | 7 | 1 |
| matched filter | matched filter without time reversal (conj(s) or s) | 4 | 0 | 1 | 0 | 0 |
| interpolation | parabolic interpolation wrong: formula, sign, fixed coefficient, rounding, index instead of lag | 5 | 3 | 3 | 2 | 0 |
| delayed channel | channel 2 not built as : advanced, shifted by a whole number of samples, or window shifted while the phase is not | 6 | 6 | 4 | 8 | 2 |
| noise model | noise level or independence wrong: pulse power averaged over the whole vector, missing factor 1/2, one noise vector for both channels, energy instead of power, inverted SNR | 11 | 7 | 7 | 7 | 6 |
| FFT gain | gain of the unscaled FFT missing in a theoretical value (, ) | 11 | 3 | 4 | 5 | 5 |
| waveform | chirp phase, pulse window or FMCW frequency profile wrong | 13 | 8 | 10 | 2 | 2 |
| statistics | exponential threshold with or with the mean taken as the rate | 1 | 1 | 0 | 0 | 0 |
| coding error | code that stops with an error: undefined variable, infinite range, fractional index, syntax error | 6 | 5 | 2 | 2 | 3 |
| failing runs | 48 | 29 | 29 | 34 | 19 |
Table 4. Table 4. Error classes and the number of runs (of 66) whose code contains each class. Only failing runs were classified.
References
- [1]Gemma Team. Gemma 4 technical report, 2026. arXiv:2607.02770.
- [2]Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, and Weizhu Chen. LoRA: Low-rank adaptation of large language models. In International Conference on Learning Representations (ICLR), 2022.arxiv.org/abs/2106.09685
- [3]Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. QLoRA: Efficient finetuning of quantized LLMs. In Advances in Neural Information Processing Systems 36 (NeurIPS 2023), 2023.arxiv.org/abs/2305.14314
- [4]Mark Chen et al. Evaluating large language models trained on code, 2021. arXiv:2107.03374.arxiv.org/abs/2107.03374
- [5]Haneul Yang, Hyoeun Kim, and Jonggu Kang. A comparative study on self-driving scenario code generation through prompt engineering based on LLM-specific characteristics. Applied Sciences, 15(23):12502, 2025. doi: 10.3390/app152312502.DOI
- [6]Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah D. Goodman. STaR: Bootstrapping reasoning with reasoning. In Advances in Neural Information Processing Systems 35 (NeurIPS 2022), 2022.arxiv.org/abs/2203.14465
- [7]Sourab Mangrulkar, Sylvain Gugger, Lysandre Debut, Younes Belkada, Sayak Paul, Benjamin Bossan, and Marian Tietz. PEFT: State-of-the-art parameter-efficient fine-tuning methods. https://github.com/huggingface/peft, 2022.
- [8]OpenVINO toolkit. OpenVINO GenAI: Run generative AI models with simple C++/Python API and using OpenVINO runtime. https://github.com/openvinotoolkit/openvino.genai, 2026. Accessed 2026-11-17.

