﻿# PyTorch 2.13 FlexAttention on MPS: sparse-window evidence

FlexAttention brings sparse attention to Apple Silicon MPS. Read the actual window-dependent benchmark, including its reversal, before projecting application gains.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/pytorch-2-13-flexattention-mps-sparse-window-benchmark/
Language: en

## The release result concerns sparse attention on MPS

The [PyTorch 2.13 announcement](https://pytorch.org/blog/pytorch-2-13-release-blog/), dated 8 July 2026, introduces FlexAttention on Apple Silicon's MPS path, including sparse prefill and decode. It marks the API unstable. This is a concrete backend addition, but the advertised attention speedup is not an overall model-training or application-throughput result.

The linked [author benchmark table](https://github.com/pytorch/pytorch/pull/182552) reports shape 1×8×32768×64 with a 256-element window and 0.8% density: 35.05 ms for FlexAttention versus 430.66 ms for SDPA. These conditions are part of the result. Removing the sparse window from the description would remove the main workload property associated with the advantage.

## A broader window changes the comparison

The same table includes an 8192-length case with window 4096 and 50% density: FlexAttention takes 78.11 ms versus 26.35 ms for SDPA. This observed reversal matters more than treating the largest reported speedup as a universal constant.

A sparse attention implementation has an opportunity to avoid work excluded by the requested pattern. A direct comparison therefore needs equivalent allowed query-key relationships. Replacing a model's intended attention with a narrower window merely to improve timing changes its computation and requires a separate quality assessment. The benchmark does not establish that any existing checkpoint tolerates that change.

The [mask-axis guide](/journal/broadcasting-attention-mask-axes/) explains why a legal tensor shape is insufficient evidence that the intended information flow is preserved. For this release, that semantic question comes before interpreting the kernel timing.

## Score modification and block sparsity have separate roles

The [versioned API reference](https://docs.pytorch.org/docs/2.13/nn.attention.flex_attention.html) distinguishes a score-modification function from the BlockMask controlling block sparsity. It specifies query, key and value axes and the grouped-query option. A mask's mathematical rule and its efficient blocked representation should therefore be preserved together in an experiment record.

A useful small reference comparison would inspect allowed positions for unequal query and key lengths before scaling the workload. Such a check is a proposed validation procedure, not a result reported here. It should establish semantic agreement between implementations rather than accept faster execution as proof of correctness.

## Measure the surrounding application separately

Even a large improvement in one attention operation accelerates only the time spent in that operation. Projection layers, other model blocks, input preparation and output handling remain part of an actual request. The end-to-end effect depends on their share of the original runtime and on whether the same sparse path is exercised at realistic lengths.

Preserve compilation, mask construction, warmup and repeated execution as identifiable phases. The [benchmark guide](/journal/inference-benchmark-method/) explains why startup and steady-state measurements should not be mixed. The cited material does not establish a precise Apple GPU model for these table results, so this article does not assign one. No MPS benchmark, model-quality test or whole-training speed measurement was performed during this review.
