CodeMerge: Codebook-Guided Model Merging for Robust Test-Time Adaptation in Autonomous Driving

Huitong Yang, Zhuoxiao Chen, Fengyi Zhang, Zi Huang, Yadan Luo

Abstract

Autonomous driving (AD) systems frequently encounter out-of-distribution (OOD) scenarios, ranging from adverse weather to sensor malfunctions, which can lead to catastrophic failures in perception and planning. While Test-Time Adaptation (TTA) offers a path to mitigate these shifts, existing methods often suffer from instability or prohibitive computational costs. This paper introduces CodeMerge, a lightweight framework that stabilizes TTA through efficient model merging. By utilizing low-dimensional "fingerprints" to represent model states, CodeMerge identifies and combines optimal checkpoints without the memory overhead of traditional methods. Our approach demonstrates significant improvements in 3D detection and downstream planning tasks while reducing memory and runtime by over 25%.

1. Introduction

The reliability of autonomous driving hinges on the perception system's ability to handle the "long tail" of real-world conditions. Sudden environmental changes—such as heavy snow, dense fog, or motion blur—and hardware issues like dropped camera frames can severely degrade a model's performance. When perception fails, the error propagates through the entire stack, leading to unsafe planning and control decisions.

Test-Time Adaptation (TTA) aims to update model parameters during inference to account for these shifts. However, applying TTA to complex 3D object detection tasks is challenging. Standard gradient-based updates often lead to "model collapse" or convergence to poor local minima. Recent research has explored model merging—maintaining a buffer of past checkpoints and interpolating between them—to stabilize the adaptation process. While effective, state-of-the-art merging techniques like Model Synergy (MOS) are computationally expensive, requiring multiple forward passes and the simultaneous loading of several large models. CodeMerge addresses this bottleneck by performing merging operations in a compact latent space.

2. The CodeMerge Framework

CodeMerge streamlines the merging process by avoiding the need to manipulate full model weights during the selection phase. The framework consists of three core components:

2.1 Model Codebook and Fingerprints

Rather than storing full weight sets for every checkpoint, CodeMerge maintains a "codebook" of compact fingerprints. These fingerprints are generated by taking the penultimate features of a source model and applying a fixed random projection to reduce dimensionality. This creates a low-dimensional representation that captures the essential behavior of the model at a specific point in time.

2.2 Curvature-Aware Merge Scores

To select the most relevant checkpoints for the current frame, CodeMerge calculates ridge leverage scores based on the fingerprints. This mathematical approach identifies which checkpoints are most informative and diverse relative to the current distribution. Crucially, the authors demonstrate that the geometry of this latent space mirrors the high-dimensional weight space, allowing for accurate selection without loading the actual models. This process approximates the inverse Hessian in parameter space, effectively selecting models that have explored diverse regions of the loss landscape.

2.3 Sign-Consistent Merging

After selecting the top-$K$ checkpoints (typically $K=5$), CodeMerge performs the merge. To prevent destructive interference—where the weights of different models cancel each other out—the framework aligns parameters based on a majority-sign consensus. This ensures that the averaged weights contribute constructively to the final adapted model.

3. Experimental Evaluation

The efficacy of CodeMerge was tested across several rigorous benchmarks:

  • nuScenes and nuScenes-C: Evaluated end-to-end AD performance against eight real-world corruptions, including camera crashes and weather-induced noise.
  • Cross-Dataset LiDAR Detection: Tested adaptation from Waymo to KITTI and nuScenes to KITTI to evaluate robustness across different sensor configurations and urban environments.
  • LiDAR Corruptions: Used KITTI-C to simulate specific LiDAR failures, such as missing beams and sensor crosstalk.

4. Key Results and Insights

CodeMerge achieves a superior balance between accuracy and efficiency compared to previous baselines.

4.1 Performance Improvements

On the nuScenes-C benchmark, CodeMerge improved the nuScenes Detection Score (NDS) by 14.9%. In LiDAR-only settings, it achieved a 7.6% mAP boost during the nuScenes-to-KITTI transition. Notably, these improvements in perception translated directly to downstream benefits: online mapping mAP increased by 42.3%, and the risk of trajectory planning collisions was reduced by 6.1%, all without additional fine-tuning of the planning modules.

4.2 Computational Efficiency

A primary advantage of CodeMerge is its reduced resource footprint. When implemented on the SparseDrive architecture, CodeMerge reduced GPU memory usage by approximately 27% (from 39.4 GB to 29.8 GB) compared to the MOS baseline. Runtime for the adaptation process was similarly reduced by 27% on SparseDrive and by 41.8% on the SECOND architecture.

5. Conclusion and Future Work

CodeMerge demonstrates that efficient, stable Test-Time Adaptation is possible by leveraging the relationship between latent feature space and model weight space. By using fingerprints and leverage scores, the framework provides a robust defense against distribution shifts in autonomous driving.

However, challenges remain. The authors noted that certain monolithic architectures, such as UniAD and VAD, experience such extreme degradation under corruption that they become difficult to adapt. Future research will focus on enhancing the baseline robustness of these architectures and further accelerating the adaptation pipeline to ensure real-time safety in even the most volatile driving environments.

Summary updated

BibTeX
@inproceedings{yang2025codemerge,
  author = {Huitong Yang and Zhuoxiao Chen and Fengyi Zhang and Zi Huang and Yadan Luo},
  title = {{CodeMerge: Codebook-Guided Model Merging for Robust Test-Time Adaptation in Autonomous Driving}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=9eVXIN9Vij},
}
Figure