Forward-Only Sim-to-Real Adaptation Inside Fused Normalization Kernels

Models trained on simulated data lose much of their accuracy when they meet real cameras and sensors. A strong fix is test-time adaptation, which nudges a few parameters of the deployed model using the unlabeled real data it is currently seeing. The best-performing versions compute these nudges by backpropagation. Backpropagation stores every intermediate activation and walks back through the whole network, which costs a great deal of memory and time on the small processors robots actually carry. We propose to compute the adaptation signal in a different way. Each normalization layer would align its own output distribution to a small stored sample of features from the simulator, using entropic optimal transport (a smoothed way of matching one cloud of points to another). The layer would then update its own scale and shift parameters inside the same GPU kernel that computes the normalization. The result is adaptation that needs only a forward pass, never builds a backward graph, and never writes intermediate tensors back to main memory.

Put in two sentences: replace end-to-end entropy gradients with layer-local distribution matching against stored synthetic statistics, and choose the matching loss so its gradient is a cheap on-chip reduction that can be fused into the normalization kernel. The scientific question is whether purely local, forward-only alignment can match backpropagation-based adaptation on genuine synthetic-to-real shifts. The systems question is whether fusion then makes it run at close to the cost of plain inference on edge hardware.

Core Claim

Three findings motivate the work. Tent (Tent) adapts only the per-channel scale and shift parameters of batch normalization by minimizing prediction entropy, and it lifts GTA5→Cityscapes segmentation from 28.8% to 35.8% mIoU. TTT++ (TTT++) shows that matching the mean and covariance of test features to stored training summaries gives about a 13% boost on the synthetic-to-real VisDA-C benchmark, reaching 22.46% per-class error. Bhardwaj et al. (Benchmarking Test-Time Unsupervised DNN Adaptation on Edge Devices) measure the cost of these methods on edge devices. Backpropagation-based adaptation fails outright on a 2 GB FPGA board even for a 26 MB model, and it takes more than 30 seconds per batch on a Raspberry Pi 4. Even backprop-free statistic recomputation adds 213 ms per batch on a Jetson Xavier NX.

The obvious combination of these lines is "write fused kernels for Tent's backward pass." We think that is the wrong target. Tent's gradient for an early layer still depends on every later layer, so the stored activations, which are the source of the memory wall, cannot be fused away.

Our claim is that the loss itself should be made local. For a normalization layer with normalized features $\hat{x}_{ic}$ at spatial position $i$ and channel $c$, the output is $y_{ic} = \gamma_c \hat{x}_{ic} + \beta_c$. The local loss is the entropic optimal transport cost between the test outputs $\{y_i\}$ and a stored bank $\{s_j\}$ of synthetic-source features for that layer. The gradient of this cost with respect to $y_i$ is the displacement $y_i - \bar{s}_i$, where $\bar{s}_i$ is the transport-weighted average of bank points assigned to $y_i$. The parameter gradients therefore reduce to per-channel sums:

$$\frac{\partial L}{\partial \gamma_c} = \sum_i (y_{ic} - \bar{s}_{ic})\,\hat{x}_{ic}, \qquad \frac{\partial L}{\partial \beta_c} = \sum_i (y_{ic} - \bar{s}_{ic}).$$

These have exactly the shape of the reductions a normalization kernel already performs.

The choice of transport over simpler moment matching is deliberate. If the local loss only matched per-channel mean and variance, the optimum would simply restore the source statistics, which is what plain statistic recomputation (BN-Norm) already does. The transport loss sees cross-channel and multi-modal structure that BN-Norm cannot. Because it compares spatial positions rather than batch statistics, it remains defined at batch size 1. That matters because L-TTA reports normalization-based methods collapsing to nearly 100% ImageNet-C error in that setting.

Research Program

The method borrows from FlashSinkhorn (FlashSinkhorn). That work rewrites Sinkhorn iterations as attention-style log-sum-exp reductions over tiles held in on-chip memory. It reports up to 161× end-to-end speedup over KeOps and under 1 GB peak memory beyond 50,000 points, but it has only been evaluated as a standalone solver on point clouds, dataset distances and cytometry data.

Its main restriction is that the cost must decompose into dot products. That restriction fits our case, because we use squared Euclidean cost on normalized features and never need a learned metric.

We will build a Triton kernel per normalization layer that runs as one tiled pass. The pass computes channel statistics and the normalized output. It then runs a small fixed number of Sinkhorn updates against a source bank resident in on-chip shared memory and L2 cache, warm-started from the previous frame's dual potentials so that a stream of frames needs few iterations. Finally, as an epilogue, it accumulates the two channel sums above and applies one damped update to $\gamma$ and $\beta$. Nothing except the layer output and the updated parameters is written to main memory.

The source bank holds a few thousand feature vectors per adapted layer, subsampled from simulator training data, in 16-bit precision. For a ResNet-50 stage with 256 channels and 4,096 bank points this is about 2 MB per layer. We will measure accuracy as a function of bank size and of which layers are adapted.

Two analyses accompany the build. The first concerns accuracy. Local updates at layer $l$ change the input to layer $l+1$ within the same forward pass, so the updates interact. We will study when this cascade helps and when it drifts, using the source-bank transport distance at every layer as a diagnostic. The second concerns the known failure mode of label-agnostic alignment, which is matching a real "car" region to a synthetic "road" cluster. Here we will compare a plain bank against a bank stratified by source-model pseudo-class.

Baselines

The naive reference is the source-trained model with no adaptation. The file reports 58.72% per-class error on VisDA-C and 28.8% mIoU on GTA5→Cityscapes for it.

BN-Norm, which recomputes normalization statistics on test data, is the cheapest competitor. Its 213 ms per-batch Jetson overhead (Benchmarking TTA) defines the latency we must approach.

Tent is the canonical gradient method. Its reported figures are 44.0% ImageNet-C error and 35.8% GTA5→Cityscapes mIoU (Tent). We will run it in two forms: eager PyTorch, and torch.compile with gradient checkpointing. The second gives the strongest generic-compiler version of the obvious idea.

TTT++ is the strongest reported synthetic-to-real accuracy at 22.46% VisDA-C error (TTT++). It is the accuracy bar.

L-TTA (L-TTA) adapts only a wavelet-based input stem. It uses 1.7% of Tent's memory on ImageNet-C and runs 4.25× faster. It is the strongest memory-efficient competitor.

SNAP (SNAP) runs gradient steps on only 1% of frames. It reports a 93.12% latency cut for CoTTA on a Raspberry Pi 4, and it is the strongest competitor on average latency.

Fairness rules apply to all of these. Every method uses the same source checkpoints, test streams, batch sizes (1 and 16) and hardware. Each gets the same hyperparameter search budget, tuned on one held-out corruption or sequence and then frozen.

Three ablations isolate our ingredients. Running the identical local algorithm unfused in PyTorch isolates the contribution of fusion. Swapping the transport loss for local diagonal moment matching, which reduces to BN-Norm, and then for local covariance matching in the style of TTT++'s alignment term isolates the contribution of the transport loss. Adapting the stem only versus all layers isolates depth.

Beating the field means two things. We must match or beat Tent's accuracy and come within reach of TTT++ on VisDA-C. At the same time, peak memory must stay within a few percent of inference-only and per-frame latency within 1.5× of BN-Norm on the Jetson. The method must also run at all on the 2 GB FPGA board where Tent fails.

Why not just…?

Why not just let torch.compile fuse Tent? A compiler can fuse the elementwise pieces, but it cannot remove the need to store activations for a full-network backward pass. That storage is what exhausts memory on edge devices. CUDA Agent reports that compiler output remains uncompetitive with specialized kernels for reduction-heavy work. FlashSinkhorn's tensorized baselines run out of memory near 20,000 points. Our compiled-and-checkpointed Tent baseline tests this directly, both in peak memory and in latency.

Why not just use BN-Norm and skip gradients? Bhardwaj et al. find that gradient adaptation beats BN-Norm by 2.65% on average, and L-TTA shows statistic-based methods collapsing at batch size 1. Our own ablation is the decisive check. Local diagonal matching is mathematically BN-Norm, so if the transport loss does not beat it, then the cross-channel information is not helping and the proposal fails.

Why not just adapt the stem, as L-TTA does? This is a real threat. L-TTA already achieves very low memory and beats full-network adaptation on CIFAR-10-C, which suggests that deep updates may be unnecessary. Synthetic-to-real shifts such as GTA5→Cityscapes, however, involve semantic and layout differences that a stem filter may not reach. The stem-only versus all-layer ablation, run on synthetic-to-real benchmarks rather than corruptions alone, settles this. If stem-only wins, we will fuse the transport update into L-TTA's stem and report it as the narrower result.

Why not just use SNAP's sparse updates? Skipping updates lowers average latency, but the 1% of frames that do update still pay full backpropagation cost. That produces latency spikes and memory spikes, which is what breaks hard real-time deadlines. We will report 99th-percentile latency and peak memory, not just the mean.

Proposed Experiments

The accuracy study uses three settings. On VisDA-C and GTA5→Cityscapes, the source models are trained only on synthetic data. On ImageNet-C and Cityscapes-C, we test corruption robustness and compare against L-TTA's reported mIoU gain over EcoTTA. In both settings we evaluate continual streams as well as per-domain resets, at batch sizes 1 and 16.

The systems study runs on the Jetson Xavier NX, the Raspberry Pi 4 (CPU fallback, unfused but still local and forward-only), and the Ultra96-v2 board. It reports per-frame latency (mean and 99th percentile), peak memory, and energy, matching the measurement protocol of Bhardwaj et al.

A third experiment probes sensor-level gaps. S2R-Bench (S2R-Bench) reports LiDAR glare degradation 85% worse than simulated noise and an 81–82% drop under misalignment. We will test whether forward-only alignment of the camera-branch features recovers part of the drop caused by real sensor degradation. No adaptation result on S2R-Bench was found on Lacuna, so this experiment is exploratory.

Three decisive checks determine the outcome. First, the transport loss must beat its own BN-Norm-equivalent ablation on VisDA-C. If not, the idea is wrong. Second, the fused kernel must stay within 1.5× of BN-Norm's per-frame latency on the Jetson while reaching Tent-level or better accuracy. If it only matches the unfused version, fusion added nothing beyond engineering. Third, all-layer adaptation must beat stem-only on at least one synthetic-to-real benchmark. If not, the contribution narrows to a faster version of L-TTA.