Manuscript Offprint

arXiv:2610.38694

Geometry Matters in Packed 3D Attention

Amil Khan, Anantajit Subrahmanya, B. S. Manjunath

Abstract

Packing a 3D volume into a token sequence is not merely long-sequence modeling. Once the volume is packed, sequence order no longer encodes the geometry of the sample — so a positional mechanism indexed by sequence position can learn the memory layout rather than the object. This is a general failure mode for attention over packed geometric data. We introduce PACK3D, a local–global attention operator that separates memory layout from attention geometry. PACK3D keeps local neighborhood attention exact, compresses only distant context into contiguous 3D block summaries, and indexes every query–key interaction with axial RoPE on true token-grid coordinates rather than packed positions. Because the rotation is applied before a block is summarized, the query-to-summary logit remains a weighted sum of query-relative 3D displacements; compressed global context therefore stays spatially interpretable after packing, instead of collapsing to anonymous pooled content. We measure the failure mode directly. On a controlled synthetic task—train on one packing, change only the memory order of the tokens, hold the physical labeling rule fixed—learned positional embeddings and packed-sequence RoPE solve the training layout perfectly yet collapse under Morton, block-contiguous, and random repacking, while axial grid-coordinate RoPE stays exact throughout. The same coordinate system carries to real data: on Allen WTC–11 hiPSC microscopy, PACK3D improves over a parameter-matched 3D U-Net on the 15-structure joint task and over a matched learned-position local–global baseline, with controls isolating the coordinate system, not encoder capacity, as the source of the gain. A fused Triton implementation matches windowed-attention latency at 65k tokens while supplying the long-range context windowing cannot—so the operator is not only correct but trainable at scale.

1 Introduction

High-token 3D fields arise across volumetric domains: live-cell microscopy [Viana et al., 2023], medical imaging [Fang et al., 2025], learned image compression for microscopy [Zhou et al., 2024], and spectral-spatial sensing cubes such as hyperspectral methane detection [Kumar et al., 2023]. In each, a volume is patchified and linearized into a token sequence for processing. But linearization discards something physical: once a 3D field is flattened, physical geometry no longer coincides with token order in memory. Tokens may be packed in raster, Morton, or block-contiguous order for systems efficiency, yet those layout choices are not coordinate systems. When a positional mechanism reads the layout as if it were geometry, attention learns the memory order rather than the object. This is the packed-geometric attention problem.

Dense and window attention fail in opposite ways. Dense attention preserves global access but scales quadratically with token count; window attention scales but sees only locally. Local–global attention is the natural compromise — exact nearby, compressed far away — and it is exactly where the problem bites, because the compression step inherits whatever coordinate the positional mechanism

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

uses. If that coordinate is sequence position, a packed operator can reduce the attention graph correctly and still attend over the wrong geometry. Reducing the graph and fixing the geometry are independent requirements, and a method can satisfy the first while failing the second.

Three-dimensional microscopy is where this is unavoidable, and it is our claim-grade domain. A single live-cell crop holds tens to hundreds of thousands of tokens, while the signal spans puncta, membranes, cytoplasmic networks, nuclear geometry, and cell-scale organization. The Allen WTC-11 hiPSC Single-Cell Image Dataset v1 contains more than 200,000 live cells in 3D across 25 tagged structures, and its analysis framework is built on cell shape, intracellular coordinates, average structure locations, variability, and pairwise structure interactions [Viana et al., 2023]. When the scientific objects are themselves spatial, a model that confuses storage order with location is not merely inefficient; it is answering the wrong question.

We introduce PACK3D, a geometry-aware local–global attention operator for packed high-token 3D fields. PACK3D keeps local neighborhood attention exact, compresses only distant context into contiguous 3D block summaries, and indexes every query–key interaction with axial RoPE on true token-grid coordinates rather than packed positions. The mechanism that makes this more than a renaming of position is that compression preserves query-relative geometry: for a block BB with normalized weights aB,ua_{B,u} and coordinate-aware compressed key k~BR\tilde{k}_{B}^{R},

(qiR)⊤k~BR=∑u∈BaB,uqi⊤R(cu−ci)ku.\left(q_{i}^{R}\right)^{\top}\tilde{k}_{B}^{R}=\sum_{u\in B}a_{B,u}q_{i}^{\top}R(c_{u}-c_{i})k_{u}.

A query therefore does not attend to an anonymous pooled block; it attends to block content through the relative 3D displacement of the tokens that formed the summary. Rotating before pooling is what keeps the summary spatial.

The systems contract is part of the method, not an afterthought to it. A sparse pattern that materializes dense route tensors or gathered local-neighbor tensors is sparse only on paper, not as a trainable high-token operator. PACK3D is a fused forward/backward block with Triton local attention, contiguous block summaries, and explicit backend reporting, following the lesson of natively trainable sparse attention: useful sparsity must align with accelerator memory movement and the backward pass, not only with asymptotic complexity [Yuan et al., 2025].

We are deliberate about what we do and do not claim. The Allen task predicts Allen-generated masks from target fluorescence, brightfield, and DNA channels; it is neither label-free prediction nor manual-label segmentation. We claim neither segmentation state of the art, nor universal superiority over U-Nets, nor a general speed law for sparse attention. The finding is architectural and narrower than any of these: for packed 3D fields, local–global attention over compressed summaries is reliable only when positional geometry is tied to physical coordinates rather than to memory order.

Our contributions are:

  1. A design principle and an operator. We formulate PACK3D and elevate the separation of memory layout from attention geometry into a design principle for packed geometric attention: packing is a systems decision, coordinates are a modeling decision, and the two must not be conflated.

  2. The geometry of compressed attention. We show that applying RoPE before block compression makes query-to-summary logits preserve query-relative 3D displacement, so compressed summaries remain spatially interpretable rather than merely pooled. A summary-center variant is a competitive approximation in short ablations, so the supported principle is coordinate-aware compression, not the necessity of one specific placement.

  3. A hardware-aligned realization. We implement the operator as a fused forward/backward training block: Triton local attention avoids local-neighbor materialization, contiguous summaries preserve locality, and the sparse graph is trainable without materializing dense route tensors on the main path.

  4. Evidence that the coordinate system, not capacity, drives the gain. On a controlled synthetic repacking benchmark, learned and packed-sequence positional encodings solve the training layout yet collapse under Morton, block-contiguous, and random repacking, while axial grid-coordinate RoPE stays exact. On Allen WTC-11 microscopy, PACK3D improves over a parameter-matched TokenGrid 3D U-Net on the 15-structure joint task and over a matched learned-position local–global baseline; capacity-controlled ablations attribute the gain to the coordinate system rather than to position-encoding parameters.

The operator is reusable beyond the domain we test. Any task whose tokens carry physical coordinates — volumetric medical segmentation, density-field and NeRF-style representations, spatial transcriptomics — inherits the same packing invariant: the attention should be built in the coordinates of the sample, not in the sequence used to store it. What we do not study here is equally explicit: label-free prediction, U-Net replacement, and transfer across imaging modalities are out of scope and left to future work.

References (43)