Dzung Phan, Vinicius Lima
INFORMS 2023
In this talk, we review the many ways, both obvious and less obvious, that tensor layouts affect performance — spanning cache locality, memory bandwidth utilization, NUMA effects, and hardware-specific tiling constraints. PyTorch tensors encode only minimal information about these physical considerations — size, stride, and storage offset — which is insufficient to capture the hardware layouts required by modern accelerators.
To address this, we introduce a tensor layout extension that enables device-aware specialization of tensor layouts, including tiling and NUMA-aware placement. This lightweight extension preserves standard PyTorch tensor semantics by introducing a separate, more expressive physical layout, allowing precise control over these layouts without modifying existing PyTorch code.
Finally, we report our experiences using this approach in practice. We demonstrate how torch.compile (Inductor) leverages these controls to automatically adapt layouts to the target device and transparently adjust computations. We discuss the resulting performance benefits, limitations, and lessons learned.
Dzung Phan, Vinicius Lima
INFORMS 2023
Hagen Soltau, Lidia Mangu, et al.
ASRU 2011
Hyungyo Kim, Apoorve Mohan, et al.
PyTorch Conference 2026
Saurabh Paul, Christos Boutsidis, et al.
JMLR