Counting Memory Writes, Not Parameters: Keeping Retinal Vascular Biomarkers Calibrated on Endurance-Limited Screening Hardware

Retinal photographs are used more and more as a cheap window onto brain blood vessels. Deep networks trained on fundus images can flag silent strokes that would otherwise need an MRI to detect. These tools will be most useful on handheld, low-power cameras at the point of care. Two problems follow. The models' vessel measurements shift when the camera changes. And any correction the device learns in the field has to be saved in non-volatile memory, meaning memory that keeps data without power, such as flash, resistive RAM or ferroelectric transistors. Each memory cell in these technologies survives only a limited number of rewrites. This note proposes treating the number of persisted memory-cell changes as the cost of on-device recalibration, and designing the recalibration module to minimize that cost. The design borrows two ideas from coding theory. The first is from post-quantum cryptography, which shrinks huge key matrices by forcing them to be block-circulant, so that each block is determined by a single stored row. The second is from endurance-limited memory codes, which cap how many times any cell may toggle.

In two sentences: a portable fundus camera must keep adjusting a small translation module so that its vessel-caliber and fractal-dimension estimates match a reference device. We make that module block-circulant, update it only when its error is large and only in ternary steps, and schedule the writes under a per-cell toggle budget. The goal is to stay calibrated for the device's whole life at orders of magnitude fewer memory-cell changes than a standard adapter that is checkpointed to storage.

Core Claim

Cross-device alignment of retinal vascular biomarkers can be maintained in the field with a recalibration module whose persisted state changes by far fewer cell toggles than a parameter-matched low-rank adapter. The claim holds at equal biomarker fidelity. Three ingredients carry it: a compact structured representation, write-triggered sparse updates, and a toggle-budgeted schedule.

The proposal also makes a secondary, clinically important claim. Quantitative vascular biomarkers such as venular caliber degrade under camera drift well before disease-classification AUROC does. Monitoring AUROC alone would therefore hide the failure that matters for using the retina as a proxy for the brain.

Where This Sits

The retinal side motivates the problem. RETFound pretrains a masked-autoencoder Vision Transformer on 1.6 million retinal images and transfers it to systemic prediction. DeepRETStroke uses a similar backbone to detect MRI-confirmed silent brain infarction at AUC 0.797, against 0.633 for clinical traits. Neither addresses how outputs drift when the camera changes. Rastogi et al. do address it. They map RETFound embeddings to AutoMorph vascular parameters across paired Topcon Triton and Maestro2 images in AI-READI, reporting cross-device CRVE R² of 78.50% and fractal-dimension recovery R² of 87.50%. They also note that geometric biomarkers align poorly. Their translation is fit once, offline, with tabular models. We take their task and data as our benchmark and move the problem into the field, where the correction must be updated repeatedly and saved to wearable memory.

The memory side constrains the design and supplies part of the method. Rasch et al. show that on-chip training in analog memory arrays places about four orders of magnitude more write demand on gradient-accumulation cells than on weight cells. That is why we refuse to backpropagate through the backbone on device. Payvand et al. cut writes by up to 88x on DVS Gestures by updating memristive weights only when a local error exceeds a threshold, and then only by −1, 0 or +1. We reuse this trigger-and-ternarize rule. Endurance-Limited Memories formalizes storing data over $t$ writes with at most $\ell$ toggles per cell, and shows that naive wear-leveling reaches sum-rate log 6 where the optimal code reaches log 7 at $\ell=2, t=3$. Locally rewritable codes reduce cells rewritten per update from $n-1$ to $n/2-1$. Both papers treat the stored data as arbitrary bits. We instead shape the data itself, the adapter, so that it changes little, and then apply these codes on top.

The cryptographic side supplies the structural idea and a caution. MDPC-McEliece makes the parity-check matrix quasi-cyclic, meaning built from circulant blocks, so only one row per block is stored. This compresses a 1,537,536-bit Goppa key to 9,857 bits at 128-bit security. The same literature warns that excessive algebraic structure invites attacks, which is why block size is tuned rather than maximized. We transfer both the representation and the lesson. For an adapter, the price of too much structure is lost expressivity rather than broken security, so block size becomes the knob we sweep. To be explicit, we do not propose any new cryptosystem, and no paper in the file connects key compression to retinal imaging.

Research Program

The backbone is a frozen RETFound encoder whose weights are written once and only read afterwards. On-device state is limited to a translation module $A$ applied to the $d$-dimensional embedding. The output of $A$ feeds fixed heads that predict AutoMorph biomarkers and disease scores. $A$ is constructed from $b\times b$ circulant blocks, each specified by its first row, so that it holds $d^2/b$ free parameters. At $b=d$ it is fully circulant. The parameters are quantized to a fixed bit width before being persisted.

Adaptation happens in rounds. After each session the device receives a small number of reference-labelled images, either from a periodic calibration target or from paired reference captures. It computes the biomarker loss, triggers an update for a stored row only if that row's error signal exceeds a threshold, and applies ternary quantized steps. The persisted cost over $R$ rounds is

$$T = \sum_{r=1}^{R} d_H\big(s_{r-1}, s_r\big), \qquad \text{subject to } \max_{j} \tau_j \le \ell,$$

Here $s_r$ is the bit string written to non-volatile memory after round $r$, $d_H$ counts differing bits, $\tau_j$ is the number of toggles experienced by cell $j$, and $\ell$ is the per-cell budget derived from device endurance. The per-cell cap is the endurance-limited memory constraint. We enforce it with a scheduler that defers updates to cells near their budget, and optionally with an endurance-limited code layered under $s_r$.

We will analyze three questions. The first is how biomarker R² trades against $T$ as block size $b$, trigger threshold and quantization width vary. The second is whether caliber, tortuosity and fractal dimension degrade at different rates under drift, compared with AUROC. The third is whether each device's lifetime toggle budget ($10^4$ to $10^7$ cycles for ferroelectric transistors, higher for resistive RAM and phase-change memory) supports years of weekly recalibration.

Baselines

The naive reference point is no field adaptation. We use the source-device model directly on target-device images and report biomarker R² and AUROC. This bounds how much drift costs.

The strongest existing method is Rastogi et al.'s feature-space translation. It fits TabPFN or TabM regressors with a Wasserstein objective from RETFound embeddings to target-device AutoMorph biomarkers. The reported figures are CRVE cross-device R² 78.50%, fractal dimension R² 87.50% and vessel density R² 76.00% on AI-READI. It is the strongest competitor because it already solves the alignment task without touching the backbone. We rerun it on the same AI-READI participant splits as a one-shot factory calibration, so it incurs zero field writes. In the drift experiments we also refit it every round and count its persisted bytes as toggles. Our method beats it if, under drift, it matches or exceeds its R² at lower lifetime $T$. Alternatively, it beats it if the one-shot version falls measurably below our continually adapted module.

The strongest adaptation baseline is a dense low-rank adapter (rank chosen to match our parameter count) held in volatile memory and checkpointed to non-volatile memory after each round. It is trained with the same loss, data, number of rounds and hyperparameter search budget. This is what an engineer would build by default. We need at least a tenfold reduction in $T$ at equal R² to claim a win.

Three ablations isolate the ingredients. The first is a circulant module updated densely without a trigger. The second is the low-rank adapter with the error-triggered ternary rule from Payvand et al.. The third is the low-rank adapter with only an endurance-limited code under its storage. If the triggered low-rank adapter alone captures most of the savings, the structural ingredient is not pulling its weight, and we will say so.

Why not just…?

Why not just keep the adapter in SRAM and ignore endurance? Volatile memory does not survive power-off, and handheld screening devices power-cycle constantly. Every correction worth keeping must eventually be written to flash or an emerging non-volatile memory. Our cost $T$ counts exactly those persisted changes, so the SRAM-plus-checkpoint design is not an escape. It is the dense baseline above, and the experiment measures how much it costs.

Why not just calibrate once at the factory with feature translation? This is the most serious threat. If camera behaviour is fixed per device, a single Rastogi-style calibration needs no field writes at all, and our method is unnecessary. The drift experiment settles it. If one-shot calibration loses less than a few R² points over the simulated lifetime, we conclude that field adaptation is not warranted. The contribution then narrows to the measurement finding about biomarker fragility versus AUROC.

Why not just apply endurance-limited or locally rewritable codes to a standard adapter? These codes bound toggles for whatever data they store, but they cannot make that data change less. A dense adapter that alters most of its parameters each round still produces large $d_H$ before coding. The code-only ablation measures this directly, and combining the codes with our module tests whether the savings compound.

Why not just use a low-rank adapter instead of circulant blocks? At small ranks, low-rank adapters are equally compact, so compactness alone does not favour circulants. The open question is whether full-rank circulant structure aligns biomarkers better per stored bit. The parameter-matched comparison across block sizes answers it, and a loss for circulants is an acceptable, reportable outcome.

Proposed Experiments

All experiments use AI-READI paired Triton/Maestro2 images with AutoMorph targets and a frozen RETFound backbone. Non-ideal device behaviour, including stuck-at cells after budget exhaustion and conductance noise, is simulated in AIHWKit following Rasch et al..

Progressive drift is simulated on the target device by composing illumination decay, colour cast and defocus that grow with round index. AI-READI contains no temporal drift, and we state plainly that this is a limitation. Disease-level checks use the diabetic retinopathy benchmarks from RETFound. DeepRETStroke's silent-infarct cohorts are not available to us, so its 0.797 AUC serves only as context, not as a reproduced target.

The first decisive check is the Pareto curve of mean biomarker R² against lifetime $T$ across all methods. The second is the one-shot-versus-continual gap, which is the kill criterion. The third is the ordering of degradation across CRVE, AVR, fractal dimension, tortuosity and AUROC under matched drift. If CRVE R² falls by more than 0.05 while AUROC moves by less than 0.01, AUROC monitoring would be unsafe for vascular-proxy deployments. The fourth is a lifetime projection. For each method and memory technology, we compute how many recalibration rounds fit before any cell exceeds its endurance, and whether biomarker R² stays above the one-shot factory level throughout.