MacFormer: Map-Agent Coupled Transformer for Real-time and Robust Trajectory Prediction

Chen Feng, Hangning Zhou, Huadong Lin, Zhigang Zhang, Ziyao Xu, Chi Zhang, Boyu Zhou, Shaojie Shen · DOI

Abstract

Accurate and efficient trajectory prediction is a fundamental requirement for the safe operation of autonomous vehicles (AVs). While existing methods have achieved high accuracy, they often suffer from high computational latency or a lack of robustness when faced with noisy sensor data. We present MacFormer, a Map-Agent Coupled Transformer designed for real-time and robust trajectory prediction. MacFormer introduces a novel bilateral query mechanism and an explicit map-coupling architecture that significantly reduces parameter counts while improving prediction groundedness. Evaluated on Argoverse 1, Argoverse 2, and nuScenes, MacFormer achieves state-of-the-art performance, with the small variant (MacFormer-S) delivering a 10x speedup over competitive models with only 0.88M parameters.

Introduction

Predicting the future trajectories of surrounding agents—such as vehicles, cyclists, and pedestrians—is a critical task for an autonomous driving system's planning module. To generate realistic and safe paths, models must integrate two primary sources of information: the historical motion of the agents and the static constraints of the environment, typically represented as high-definition (HD) maps.

Existing research generally follows two paradigms: implicit-fusion and target-driven models. Implicit-fusion models blend map and agent features into high-dimensional embeddings, but they often struggle with "off-road" predictions when historical data is noisy. Target-driven models focus on identifying potential goal points on the map, which improves groundedness but introduces significant computational overhead. MacFormer addresses these limitations by explicitly coupling map constraints with agent motions through a lightweight, parallelized Transformer architecture.

Methodology

Coupled Map and Reference Extractor

Unlike traditional models that rely on deep stacks of attention layers to implicitly learn road rules, MacFormer utilizes a Coupled Map & Reference Extractor. This component explicitly calculates the relative motion between agents and lane segments. The Reference Extractor employs learnable tokens to identify specific map-based "guides," such as centerlines, for each potential future trajectory. This ensures that the model's predictions are inherently aligned with the topological structure of the road.

Bilateral Query Scheme

Standard Transformer architectures in motion forecasting often use unilateral cross-attention, where agents query the map features. MacFormer introduces a Bilateral Query Scheme that utilizes a shared affinity matrix, allowing agents and map segments to query each other in parallel. This approach facilitates bidirectional information flow—allowing agents to understand the map and the map to contextualize agent behavior—while drastically reducing the number of parameters and the computational time required for context fusion.

Multi-Task Optimization Strategy (MTOS)

To ensure the model respects map topology, MacFormer is trained using a "tri-task" optimization strategy. Beyond the standard goal of minimizing final displacement error, the model is tasked with:

  1. Predicting future relative motions with respect to the map.
  2. Capturing motion priors based solely on historical data.

This multi-task approach regularizes the learning process, forcing the network to maintain a high degree of map-adherence even when input signals are degraded.

Experimental Results

Performance and Efficiency

MacFormer was evaluated on three premier benchmarks: Argoverse 1, Argoverse 2, and nuScenes. On the Argoverse 1 leaderboard, MacFormer-L achieved the top ranking for the official brier-minFDE6 metric.

Beyond accuracy, MacFormer demonstrates industry-leading efficiency. The MacFormer-S variant features an inference latency of just 14ms, making it at least 10x faster than established models like LaneGCN or DenseTNT. Furthermore, with only 0.88M parameters, it is highly optimized for deployment on edge hardware with limited memory and power budgets.

Robustness to Noisy Data

A key finding of the study is MacFormer's robustness to "imperfect tracklets." In scenarios where sensor data is missing frames or contains significant noise, MacFormer maintains higher accuracy than models relying purely on historical trajectories. By grounding its predictions in the map's geometry, the model can effectively "fill in the blanks" of an agent's likely path.

Conclusion

MacFormer represents a significant step forward in balancing the competing demands of accuracy, efficiency, and robustness in trajectory prediction. By replacing deep, implicit fusion with explicit map-agent coupling and a bilateral query mechanism, the framework achieves state-of-the-art results with a fraction of the computational cost.

While the model excels at following road rules, future work will focus on improving its ability to predict "abnormal" driving behaviors—instances where agents intentionally violate map constraints to avoid hazards. Balancing strict map-adherence with the flexibility to forecast unconventional maneuvers remains an open challenge for the field.

Summary updated

BibTeX
@article{feng2023macformer,
  author = {Chen Feng and Hangning Zhou and Huadong Lin and Zhigang Zhang and Ziyao Xu and Chi Zhang and Boyu Zhou and Shaojie Shen},
  title = {{MacFormer: Map-Agent Coupled Transformer for Real-time and Robust Trajectory Prediction}},
  journal = {IEEE Robotics Autom. Lett.},
  year = {2023},
  doi = {10.1109/lra.2023.3311351},
}
Figure