BSA: Ball Sparse Attention for Large-scale Geometries

Cătălin-Emanuel Brița, Hieu Nguyen, Lohithsai Yadala Chanchu, Domonkos Nagy, Maksim ZhdanovLCFM @ ICML 2025 · DOI

TL;DR

This paper introduces Ball Sparse Attention (BSA), a novel attention mechanism designed to efficiently process large-scale, irregular geometric data common in scientific simulations. By integrating a ball-tree structure with existing sparse attention techniques, BSA achieves global receptive fields at sub-quadratic computational cost, outperforming previous methods in both speed and accuracy for tasks like fluid flow prediction.

What Problem Does This Paper Address?

The Transformer architecture, with its powerful self-attention mechanism, has revolutionized many fields, but its quadratic scaling with input size makes it impractical for large-scale scientific applications. These applications often involve irregular geometries (like fluid simulations or molecular structures) represented as unordered point sets, which standard sparse attention methods, designed for regular data like text or images, struggle to handle efficiently. Existing approaches try to impose regularity, but this can lead to loss of fidelity or require complex preprocessing. The paper aims to bridge this gap by developing a sparse attention mechanism that can effectively process irregular geometric data while maintaining a global view of the information.

Methods

The core innovation is Ball Sparse Attention (BSA), which adapts the Native Sparse Attention (NSA) framework by incorporating a Ball Tree structure. Here's a breakdown:

  • Ball Tree Structure: Inspired by the Erwin Transformer, BSA uses a ball tree to impose spatial locality on unordered point sets. This hierarchical structure groups nearby points into "balls," allowing for localized processing.
  • Hybrid Attention: BSA combines three key sparse attention branches, similar to NSA:
  • Ball Tree Attention (BTA): This replaces NSA's conventional sliding window with attention computed within the ball-tree neighborhoods. This allows for fine-grained local attention.
  • Compression: Similar to NSA, this branch compresses keys and values from blocks of points into single tokens using MLPs or mean pooling, enabling attention over a coarser representation.
  • Selection: This branch uses the compressed keys to identify important blocks of tokens across the entire sequence, allowing for attention to distant but relevant information.
  • Locality-Based Sparsification: BSA introduces "group selection" for the top-k block retrieval. Instead of selecting blocks independently for each query point, it groups query points and enforces a shared selection of blocks for all points within a group. This reduces computation and improves GPU efficiency.
  • Query Coarsening: To further optimize runtime, BSA can optionally coarsen the query representations before computing the similarity matrix for selection and compression, trading a slight loss in resolution for significant speed gains.

Datasets

  • ShapeNet-Car: Used for airflow pressure prediction. This dataset consists of 3D car models with 3586 surface points each. The ground truth airflow pressure was generated via simulations.
  • Elasticity benchmark: Used for stress field prediction in hyperelastic materials.

Key Insights and Ideas

  • Irregular Geometries are a Bottleneck: Standard sparse attention struggles with the unordered nature of point clouds, a common representation in scientific computing.
  • Ball Trees Provide Structure: Hierarchically organizing points using ball trees offers a natural way to introduce locality and enable efficient sparse attention on irregular data.
  • Hybridization is Key: Combining local (Ball Tree Attention) with global (compression and selection) sparse attention mechanisms is crucial for capturing both fine details and long-range dependencies.
  • Group Selection for Efficiency: Grouping query points for block selection significantly speeds up computation by reducing redundant operations and improving memory access patterns.
  • Accuracy-Efficiency Trade-off: Different BSA variants (e.g., with or without group compression) demonstrate a clear trade-off between computational cost and predictive accuracy, allowing for flexible deployment.

Key Results

  • Competitive Accuracy: BSA achieves accuracy comparable to Full Attention on the ShapeNet dataset for airflow pressure prediction, and similar performance to the Erwin Transformer on the Elasticity benchmark.
  • Significant Speedup: At larger sequence lengths (e.g., 65536), BSA is up to 5x faster than Full Attention. Even at moderate lengths like 4096, BSA outperforms Full Attention in runtime.
  • Reduced GFLOPS: BSA variants generally require fewer GFLOPS than Full Attention, indicating improved computational efficiency.
  • Improved Receptive Field: Visualizations show that BSA, especially with its selection and compression components, can achieve a global receptive field, effectively attending to distant regions of the geometry.

Limitations and Future Work

  • Triton Kernel: The paper notes that BSA does not implement a Triton kernel for efficient selection, which is why Full Attention can outperform BSA without group selection at smaller sequence lengths.
  • Generalization of Group Partitioning: The authors plan to evaluate their fixed-group query partitioning scheme on a broader range of point-cloud datasets to assess its robustness.
  • Hyperparameter Sweeps & Ablations: Comprehensive hyperparameter tuning and ablation studies are planned to better understand BSA's sensitivity.
  • GPU Kernel Development: A dedicated GPU kernel for BSA operations is a key future direction to fully leverage hardware alignment and further boost computational efficiency and reduce memory footprint.

Summary updated

Abstract

Self-attention scales quadratically with input size, limiting its use for large-scale physical systems. Although sparse attention mechanisms provide a viable alternative, they are primarily designed for regular structures such as text or images, making them inapplicable for irregular geometries. In this work, we present Ball Sparse Attention (BSA), which adapts Native Sparse Attention (NSA) (Yuan et al., 2025) to unordered point sets by imposing regularity using the ball-tree structure from the Erwin Transformer (Zhdanov et al., 2025). We modify each of NSA’s components to work with ball-based neighborhoods, yielding a global receptive field at sub-quadratic cost. On an airflow pressure prediction task, we achieve accuracy comparable to full attention while reducing computational cost by a significant margin.
BibTeX
@misc{brita2025bsa,
  author = {Cătălin-Emanuel Brița and Hieu Nguyen and Lohithsai Yadala Chanchu and Domonkos Nagy and Maksim Zhdanov},
  title = {{BSA: Ball Sparse Attention for Large-scale Geometries}},
  year = {2025},
  eprint = {2506.12541},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2506.12541},
}
Figure