What is different, in one minute
A customary standalone tune is a batch process.
The tuner drives or loads the car on a dyno, records logs, edits tables on a laptop, flashes, and repeats. Between sessions the calibration is frozen, and every refinement costs tuner time.Medium1
GAINS splits the same work into layers. Hard real-time control runs from tables as usual. Above it, deterministic learners on the ECU adjust fuel trim cells continuously from the wideband, inside an envelope that the policy engine signed.
Learned trims are later promoted into the base map as an ordinary, reviewable change.16
The principle a tuner will recognise
Let the engine teach you fuel quickly, but never let software decide on its own to add timing, boost or cam authority. Those stay evidence-gated decisions with a named role and the right vehicle state.17
| Step | Customary process | GAINS |
|---|---|---|
| define the engine in about ten facts | the tuner builds a base map from experience and a similar engine's file, entering injector data, trigger setup, sensor calibrations and firing order by hand. | the trigger pattern and cam sync are auto-detected from tooth-period analysis on the first crank revolutions. Cylinders, displacement, firing order, injector flow and dead time (by part number), coil type and dwell, and sensor types come from the engine database by engine code, or from the app. |
| lambda targets come from the goal, not the tuner's habit | one target table, often copied between cars, edited by hand for a street or race setup. | targets are generated from the driver's goal (street, track or economy) and the hardware, then held to policy limits. The policy engine rejects any proposal that leaves a target leaner than lambda 0.85 in cells above 105 kPa, and any boost increase unless targets at and above the new boost are lambda 0.82 or richer. |
| learning while you drive, without stepping the fuel | a fuel error found on Tuesday's drive is fixed at the next laptop session. Until then the engine runs with it. | the L1 layer corrects the trim table during the drive, within the envelope, and keeps trims in keep-alive memory. After the drive, learned trims become a promotion proposal for the base map. When the new base activates, remaining trims are re-expressed relative to it, so delivered fuel does not step. |
| drivability, from plain language to a reviewable change | pedal maps, idle control and decel fuel are hand-edited, often last and often rushed. | the driver can ask in plain language. The request becomes a typed intent; a deterministic planner turns it into a specific change; the policy engine decides whether it may apply now, must wait for a vehicle state, or is rejected. |
| ignition is retard-only until there is evidence | timing is found on a dyno by sweeping toward best torque and backing away from knock, then trusted on the street with whatever knock control the ECU has. | the real-time layer and the knock learner can only take timing away. Knock events are attributed to ignition cells by bilinear weight, accumulate across drives, and once a cell's evidence reaches 0.5 it gets a 1.5° retard proposal, never more than the parameter's step limit. |
The five layers: who is allowed to change what, and how fast
L0 is hard real-time control
Injection, ignition, throttle and protections running from the active tables. Nothing above L0 can bypass its limits.1
L1 is the on-ECU adaptive layer. Deterministic controllers adjust trim tables (fuel now, knock retard now; others planned) at engine speed. They cannot exceed the envelope: for example ±15% fuel trim and zero ignition advance authority in the reference configuration.110
L2 is the signed authority envelope and goal weights. Widening it is itself a calibration change with a change class, so it goes through the policy engine like any other edit.17
L3 is the versioned base calibration. Each version carries a hash; the ECU reads back what it activated. L4 is fleet and AI tooling: explanation, triage and planning, never direct control.19
Step 1: define the engine in about ten facts
Customary process
The tuner builds a base map from experience and a similar engine's file, entering injector data, trigger setup, sensor calibrations and firing order by hand.Medium3
GAINS
The trigger pattern and cam sync are auto-detected from tooth-period analysis on the first crank revolutions. Cylinders, displacement, firing order, injector flow and dead time (by part number), coil type and dwell, and sensor types come from the engine database by engine code, or from the app.3
Step 2: one safety confirmation, then a deliberately conservative first start
Customary: crank with a guessed base map, adjust cranking fuel by feel, set base timing with a timing light, then nurse the engine to temperature.Medium3
GAINS keeps the one step no learner can replace: confirming base timing (trigger offset) with a timing light, unless the engine family's offset is verified in our database. A wrong offset shifts every spark event and cannot be observed reliably from sensors. The guided check also tests injector and coil outputs, fuel pressure, and sensor plausibility.3
The starter calibration is generated from physics defaults: a generic VE surface, rich lambda targets, retarded timing, no boost above wastegate spring pressure, a low rev limit and a high idle. Cranking fuel adapts across start attempts within bounds.3
Step 3: the fuel model the learners correct
GAINS uses speed density
Air per cylinder per cycle comes from a volumetric efficiency table over rpm and manifold pressure, corrected for charge temperature. Fuel mass follows from the lambda target and the fuel's stoichiometric ratio, and pulse width from injector flow plus dead time.1314
At 6,500 rpm a four-stroke cycle lasts 18.5 ms, so that pulse is a 53% duty cycle. The same arithmetic runs in the ECU every event. The learners never touch injector data or stoich; they correct the VE surface, which is where real engines differ from the model.134
Result
Planning estimate from the formula below, not a measurement.
Step 4: lambda targets come from the goal, not the tuner's habit
Customary process
One target table, often copied between cars, edited by hand for a street or race setup.Medium2
GAINS
Targets are generated from the driver's goal (street, track or economy) and the hardware, then held to policy limits. The policy engine rejects any proposal that leaves a target leaner than lambda 0.85 in cells above 105 kPa, and any boost increase unless targets at and above the new boost are lambda 0.82 or richer.27
Step 5: VE learning, in detail
Customary autotune tools average wideband error per cell and suggest corrections, but often attribute lambda to the cell the engine was in at the moment of the reading, include transients, and leave the tuner to judge noisy cells.Medium13
GAINS pairs each operating point with the lambda reading that belongs to it. Exhaust transport plus sensor response is modelled as 0.12 s plus 40/rpm seconds: about 0.17 s at 800 rpm, 0.133 s at 3,000 rpm and 0.127 s at 6,000 rpm. The ratio of measured to target lambda is attributed to the four surrounding cells by bilinear weight.413
Samples count only in steady state
Rpm changing under 300 rpm/s and MAP under 12 kPa/s across a ±0.25 s window, coolant at least 75 °C, no transient-fuel flag at the operating point or at the delayed lambda sample, and measured lambda between 0.6 and 1.3.4
A cell is corrected only when its accumulated weight reaches 12, its relative standard deviation is at most 4%, and its mean error is outside a 0.8% deadband. The correction is multiplicative and capped at 5% per iteration, and never beyond the parameter's own step limit.4
Every result is a proposal
A list of cell changes with the statistics behind each, which then has to pass the policy engine and the ECU's own checks.47
| Iteration | Mean |λ error| | p95 |λ error| | VE cells changed |
|---|---|---|---|
| 1 | 7.95% | 16.40% | 83 |
| 2 | 4.32% | 11.70% | 63 |
| 3 | 2.36% | 7.70% | 56 |
| 4 | 1.10% | 3.40% | 31 |
| 5 | 0.92% | 2.65% | 24 |
| 6 | 0.75% | 1.85% | 10 |
| 7 | 0.75% | 1.87% | 10 |
| 8 | 0.72% | 1.84% | 9 |
Synthetic engine in the reference simulator; not a vehicle result.
Step 6: learning while you drive, without stepping the fuel
Customary process
A fuel error found on Tuesday's drive is fixed at the next laptop session. Until then the engine runs with it.Medium1
GAINS
The L1 layer corrects the trim table during the drive, within the envelope, and keeps trims in keep-alive memory. After the drive, learned trims become a promotion proposal for the base map. When the new base activates, remaining trims are re-expressed relative to it, so delivered fuel does not step.16
Step 7: transient fuel (planned strategy)
Customary: accel enrichment tuned by feel and log review, usually as TPS-rate and MAP-rate tables with decay times.Medium15
GAINS's planned strategy models the fuel film on the port walls (the x-tau approach from Aquino's 1981 work) and learns its coefficients from tip-in and tip-out events, using the lean or rich excursion that follows each one, inside bounds.Medium152
Step 8: drivability, from plain language to a reviewable change
Customary process
Pedal maps, idle control and decel fuel are hand-edited, often last and often rushed.Medium2
Step 9: ignition is retard-only until there is evidence
Customary process
Timing is found on a dyno by sweeping toward best torque and backing away from knock, then trusted on the street with whatever knock control the ECU has.Medium13
GAINS
The real-time layer and the knock learner can only take timing away. Knock events are attributed to ignition cells by bilinear weight, accumulate across drives, and once a cell's evidence reaches 0.5 it gets a 1.5° retard proposal, never more than the parameter's step limit.5
Any cell with recent knock evidence is locked against advance by the policy engine. Adding timing is a dyno_only change: it requires an operator-authorized dyno session and the pro_tuner role. Torque-seeking spark is a research item, not a feature.571
Step 10: boost control (gated)
Customary: wastegate duty tables and a boost target, set on the dyno, sometimes with boost by gear added later.Medium2
GAINS plans a closed-loop boost target by gear and goal with knock protection active at boost. Raising boost authority is never automatic: it needs fuel margin by policy (lambda 0.82 or richer at the new target), the right role, and an independent over-boost protection outside the adaptive layer, which is an open item for the safety review.127
Step 11: cams, VTEC and direct injection (planned)
Cam phasing starts from conservative overlap with idle and cold overlap kept low.
Cam targets per load cell are then chosen with torque and knock in mind, and widening cam authority follows the same evidence-gated path as spark.Medium2
VTEC engagement is treated as a load and rpm surface where the two cam profiles cross on torque, learned from logs, rather than one fixed rpm.Medium2
Direct injection runs on the DI
Rail pressure targets and injection phasing, with a port and DI split on dual-injection engines that starts from the factory's general strategy and is refined from logs.Medium2
The policy engine: what makes this safe to automate
Every calibration parameter carries a change class, a minimum role, step limits, a safer direction where one exists, and whether AI may propose it. Change classes are live_safe, stationary_only, engine_off, dyno_only and prohibited. Vehicle state for stationary or engine-off comes only from ECU-measured signals, never from phone GPS alone.7
Validation catches structural and safety errors before anything is staged: out of bounds, step too large, not monotonic or not smooth where shape matters, profile mismatch, integrity (hash) failure, lean under boost, and boost without fuel margin. Proposals are also capped at 400 changed values so a human can actually review them.7
The ECU re-validates whatever it receives. The app and the cloud can propose; only the ECU activates, and it reads back the version and hash it is running.19
On other ECUs: the same strategies as an advisor
On an ECU we did not build, the knowledge engine runs in advisor mode.
It reads your logs, applies the same steady-state gates and statistics, and tells you exactly which cells to change and why. You apply the change in the vendor's own tool.2
Direct writes to a third-party ECU happen only through an interface the vendor has authorized. We never imply otherwise.27
What this method does not do, and what is not proven yet
It does not find power by itself.
Ignition advance, boost authority and cam authority stay gated, and a dyno remains the right place to find best torque safely.15
Every number on this page that describes results comes from simulation on a synthetic engine. GAINS hardware is pre-release, and the layered design is pending review by a qualified engine-controls and functional-safety engineer before firmware implementation.13
Open safety-review items include independent over-boost and over-rev protection outside the adaptive layer, plausibility checks on the signals that define vehicle state, trim memory wear and corruption recovery, and the compute budget for the learners on the ECU.1
Frequently asked
Does GAINS replace a professional tuner?
It automates the parts of tuning that are measurable from sensors, mainly fuel, and makes everything else reviewable. Adding timing, boost or cam authority stays a gated decision for a qualified person, ideally on a dyno. Results so far are simulated; hardware is pre-release.17
How is GAINS's VE learning different from a typical autotune feature?
It pairs each operating point with the lambda reading that belongs to it using a transport-delay model, learns only in steady state, spreads evidence over the four surrounding cells, ignores noisy or thin cells, caps each correction at 5%, and outputs a proposal that a policy engine must accept.4
Can the ECU add ignition timing on its own?
No. Real-time and learned ignition changes are retard only. Advancing timing is a dyno_only change that needs an operator-authorized dyno session and the pro_tuner role, and any cell with recent knock evidence is locked against advance.57
What happens to fuel delivery when learned trims are saved into the map?
Nothing visible. Learned trims are promoted into a new base map version as a reviewable proposal, and when it activates the remaining trims are re-expressed relative to the new base, so the fuel actually delivered does not step. In simulation the effective fuel was unchanged at promotion.610
Does an AI model ever write to my ECU?
No. Language from the app or an assistant is turned into a small set of typed intents. A deterministic planner builds the specific change, the policy engine checks it, and the ECU re-validates it before anything activates. Unsupported requests are refused with a reason.87
Do I still need a wideband?
Yes. Closed-loop fuel learning depends on accurate lambda. GAINS ECUs include a Bosch LSU 4.9 controller; you fit the sensor. A factory narrowband sensor only tells rich from lean around stoichiometric, so it cannot guide power or economy targets.144
What still needs a timing light or a dyno?
Base timing (trigger offset) is confirmed with a timing light unless the engine family's offset is verified in our database. Finding best torque timing, raising boost authority and widening cam authority belong on a dyno or under a gated expert procedure.31
How long does it take to get a usable fuel map?
In simulation, starting from a map built from the engine specification only, mean lambda error fell from about 7% to about 2.3% within the first five-minute gentle drive and to about 0.7% by the fifth drive. Real engines and drive patterns will differ; hardware testing is still ahead.11
Related
Sources
Numbered as cited above. Hover or tap a citation chip to preview it.
15 sources
- internal GAINS architecture decision record: ADR-0004: Layered real-time adaptation under a signed authority envelope
- internal GAINS architecture decision record: ADR-0008: Tuning Knowledge Engine
- internal GAINS architecture decision record: ADR-0009: First-start self-commissioning
- internal GAINS source code: @aitune/autotune ve-learner.ts (reference implementation)
- internal GAINS source code: @aitune/autotune knock-learner.ts (reference implementation)
- internal GAINS source code: @aitune/autotune promote.ts (trim promotion)
- internal GAINS source code: @aitune/policy (change classes, roles, validation rules)
- internal GAINS source code: @aitune/intent (typed intents, planner)
- internal GAINS simulation: pnpm demo:autotune output, simulated engine, 2026-10-25
- internal GAINS simulation: pnpm demo:realtime output, simulated engine, 2026-10-25
- internal GAINS simulation: pnpm demo:firststart output, simulated engine, 2026-10-25
- internal GAINS simulation: pnpm demo:intent output, 2026-10-25
- Internal Combustion Engine Fundamentals (2nd ed.) · J. B. Heywood, McGraw-Hill, 2018 · book · retrieved 2026-10-25
- Automotive Handbook · Robert Bosch GmbH · book · retrieved 2026-10-25
- Transient A/F Control Characteristics of the 5 Liter Central Fuel Injection Engine (SAE 810494) · C. F. Aquino, SAE International, 1981 · sae-paper · retrieved 2026-10-25
Methodology outline, not a validated calibration. Results so far are simulated.

