ASAP: Amortized Doubly-Stochastic Attention via Sliced Dual Projection

Huy Tran, Max Milkert, David HydearXiv 2026

TL;DR

ASAP (Amortized Doubly-Stochastic Attention via Sliced Dual Projection) introduces a "train-then-compile" framework that delivers the benefits of doubly-stochastic attention without the typical computational penalties. By training a model with a standard, low-overhead Sinkhorn loop and then compiling it into a fast, non-iterative sliced-dual projection operator for inference, ASAP achieves up to a 5.3× inference speedup while completely avoiding the massive training costs of alternative non-iterative methods.

What Problem Does This Paper Address?

Standard Transformer models use row-softmax normalization, which scales attention weights independently for each query. While simple, this one-sided constraint can lead to pathologies like "attention sinks" (where models dump attention onto uninformative tokens) and "rank collapse" in deep networks.

Doubly-stochastic attention fixes this by enforcing constraints on both rows and columns, treating attention as an optimal transport problem. The classic way to do this is via Sinkhorn scaling. However, Sinkhorn scaling requires an iterative loop during every single inference forward pass, adding significant latency.

Recent alternatives like ESPFormer eliminate the online inference loop using sliced transport plans, but they introduce a new nightmare: their training phase relies on soft-sorting approximations that materialize massive, dense tensors. This results in a doubly-stochastic attention trilemma, where you can have low training costs, efficient inference, or high attention fidelity—but historically, never all three.

The Doubly-Stochastic Attention Trilemma, showing how ASAP sits at the intersection of lower-cost training, efficient inference, and double stochasticity.

Methods

ASAP breaks this trilemma using a clever train-then-compile strategy:

  1. Train Cheaply: The model is trained normally using a standard, computationally lightweight Sinkhorn attention layer (the "teacher").
  2. Compile Offline: Once trained, the teacher's weights are frozen. A small, unlabeled calibration dataset is passed through the network to extract the query-side normalization vectors (known as source dual potentials). Simultaneously, the queries and keys are projected onto 1D lines (slicing) to compute exact 1D optimal transport potentials. ASAP then learns a lightweight linear mapping (via ridge regression or convex KL optimization) from these 1D features to the teacher's true source duals.
  3. Fast Inference: At inference time, the iterative Sinkhorn loop is completely removed. The model uses the learned linear map to predict the source dual vector in a single step, and then analytically reconstructs the full doubly-stochastic attention matrix using a fast, two-sided entropic c-transform.
The ASAP workflow: (1) Offline compilation learns a mapping from sliced features to the teacher's duals, and (2) Online inference predicts the duals and reconstructs the attention plan non-iteratively.

Datasets

The authors evaluated ASAP across both language and vision benchmarks:

  • IMDb: Used as the primary frozen-layer replacement and resource profiling benchmark.
  • Cats and Dogs: A full-data Vision Transformer (ViT) classification task.
  • CIFAR-100: Used as a challenging vision control setup.
  • Text Classification Suite: DBpedia-14, AG News, and Yelp Review Full were used to test downstream performance preservation across distinct topics and sentiment tasks.

Key Insights and Ideas

  • Decoupling Training from Inference: Instead of trying to design an attention mechanism that is perfectly efficient during both phases from scratch, ASAP accepts that iterative methods are fine for training but bad for deployment. Decoupling them allows developers to get the best of both worlds.
  • Compression via Dual Variables: Instead of trying to predict or approximate all $N \times N$ elements of an attention matrix, ASAP only predicts an $N$-dimensional vector (the source dual). The mathematical structure of optimal transport (the c-transform) inherently guarantees that the rest of the matrix will satisfy the required column constraints.

Key Results

  • Inference Speedup: In frozen-layer benchmarks on IMDb, ASAP was 5.3× faster than its trained Sinkhorn teacher ($S=20$) while matching its downstream accuracy.
  • Training Efficiency: ASAP completely sidesteps the training overhead of sliced-transport methods like ESPFormer, which was shown to use 5.7× more peak training memory and run 14.8× slower per training example than the Sinkhorn baseline.
  • Downstream Preservation: When replacing layers in downstream text classification models, ASAP recovered virtually all of the teacher's performance (within ~0.1 accuracy points) without requiring any retraining of the surrounding Transformer backbone.

Limitations and Future Work

While ASAP successfully eliminates the iterative scaling loop, it still operates on dense query-key scores, meaning the overall computational complexity remains quadratic ($O(N^2)$) relative to sequence length. It does not inherently make attention sparse or subquadratic.

Additionally, the current formulation assumes a uniform two-marginal setting, making it incompatible with the strict triangular masking required for causal (autoregressive) language modeling. The authors note that extending this compiler philosophy to causal attention and Sinkhorn-based sparse routing represents an exciting direction for future work.

Summary updated

BibTeX
@misc{tran2026asap,
  author = {Huy Tran and Max Milkert and David Hyde},
  title = {{ASAP: Amortized Doubly-Stochastic Attention via Sliced Dual Projection}},
  year = {2026},
  eprint = {2605.12879},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.12879},
}
Figure