# SageAttention 2 on the DGX Spark: up to 1.7x faster attention, no faster ComfyUI

> It builds for sm_121, runs without falling back, and beats flash-attention by 1.1x to 1.7x per call. Three ComfyUI graphs got at most 1.5% faster end to end.

- Author: Sparks
- Published: 2026-12-05
- Tags: attention, comfyui, dgx-spark, blackwell, errata
- Page: https://fameonthewirelessasfarasitgoes.com/posts/sageattention-2-gives-no-end-to-end-speedup-on-dgx-spark/

SageAttention 2 can be built for the DGX Spark's GB10 (sm_121), and it works there. It runs with zero fallback errors, its decoded output shows no mosaic or blockiness, and in a synthetic probe its attention kernel was 1.1x to 1.7x faster than flash-attention. Then it was A/B tested end to end in ComfyUI v0.46.0 on an image graph, a text-to-video graph and a video-upscale graph. No graph improved by more than 1.5% in median time. On two of them the two arms' run times overlap. On the third a sub-1% gain is possible, but two runs per arm cannot establish it.

If you own a GB10 box and are weighing a custom build so you can pass `--use-sage-attention`, this is what that build bought on the graphs tested: a working kernel and close to no wall-clock time. The rest of this post is how it was built, how it was measured, what was checked, and what is still unknown. Two errata from the way there come at the end. One of them is a bug in a public upscale tool that makes it hand back your input instead of its output.

## What was tested

Everything here ran on one DGX Spark (GB10, sm_121, aarch64):

- SageAttention from `main` at commit `cd00653e`, built with `TORCH_CUDA_ARCH_LIST=12.1`
- ComfyUI v0.46.0
- flash_attn 2.7.3 in an NGC PyTorch 25.03 image (torch 2.7) and 2.7.4.post1 in an NGC PyTorch 26.07 image (torch 2.13)

The models and tools involved are all public: Krea 2, Wan 2.2 TI2V-5B, LTX-2.5, the ReDetail upscale CLI, SageAttention itself, comfy-aimdo and ComfyUI's Comfy Compiler.

## Building it for sm_121

Read from SageAttention's source at `cd00653e`:

- `setup.py` lists `12.1` in `SUPPORTED_ARCHS`, and `TORCH_CUDA_ARCH_LIST=12.1` emits `-gencode arch=compute_121a,code=sm_121a`. The extensions built for sm_121 are `_qattn_sm80`, `_qattn_sm89` and `_fused`, not `_qattn_sm90`.
- The CUDA-version gate checks only 12.0 (nvcc 12.8 or later). There is no gate for 12.1, so an nvcc that cannot target compute_121 fails at compile time rather than at the gate.
- `sageattn()` in `sageattention/core.py` dispatches sm_121 to `sageattn_qk_int8_pv_fp8_cuda(..., qk_quant_gran="per_warp", pv_accum_dtype="fp32+fp16")`, with the source comment "triton kernel is currently not usable on sm121". So on the GB10, SageAttention's own path is CUDA only: no Triton JIT and no `torch.compile` inside SageAttention.

The trap is the compiler. Probed with `nvcc --list-gpu-arch` inside each container:

| Container or toolchain | nvcc | compute_121 listed |
|---|---|---|
| NGC PyTorch 25.03 (torch 2.7.0a0, CUDA 12.8) | 12.8.93 | no (the list ends at compute_120) |
| NGC PyTorch 26.07 (torch 2.13.0a0, CUDA 13.3) | 13.3.73 | yes |
| `cuda-nvcc-12-9` 12.9.86 from NVIDIA's ubuntu2404/sbsa apt repo, installed into NGC 25.03 | 12.9.86 | yes |

Table: Which nvcc can target sm_121, per `nvcc --list-gpu-arch`.

For the 25.03-based image, the fix was a Docker builder stage that adds CUDA 12.9's nvcc, builds the wheel there, and copies only the wheel into the runtime image. Building with CUDA 12.9 nvcc against the image's CUDA 12.8 torch worked. The rule that made it a reasonable bet, that torch's cpp_extension rejects only a CUDA major-version mismatch, was read in the source and not separately tested. Building `12.0` cubins instead was rejected on reasoning, not on a test: `sm_120a` cubins are arch-specific and were read as not loading on sm_121.

The builder stage, with comments removed and the base tag written out:

```dockerfile
FROM nvcr.io/nvidia/pytorch:25.03-py3 AS sage-build
ARG SAGE_REF=cd00653e84f8ad2e456c71d8ce1a915b13a960f3
ARG CUDA_KEYRING_URL=https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/sbsa/cuda-keyring_1.1-1_all.deb
ARG CUDA_KEYRING_SHA256=6ea7d2737648936820e85677177957a0f6521b840d98eb0bbae0a4f003fa7249
RUN set -eux; \
    curl -fsSL -o /tmp/cuda-keyring.deb "${CUDA_KEYRING_URL}"; \
    echo "${CUDA_KEYRING_SHA256}  /tmp/cuda-keyring.deb" | sha256sum -c -; \
    dpkg -i /tmp/cuda-keyring.deb; rm -f /tmp/cuda-keyring.deb; \
    apt-get update; \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
      cuda-nvcc-12-9 cuda-cudart-dev-12-9 cuda-cuobjdump-12-9; \
    rm -rf /var/lib/apt/lists/*; \
    /usr/local/cuda-12.9/bin/nvcc --version | tail -1; \
    /usr/local/cuda-12.9/bin/nvcc --list-gpu-arch | grep -qx compute_121
RUN set -eux; \
    git clone https://github.com/thu-ml/SageAttention.git /src/SageAttention; \
    git -C /src/SageAttention checkout "${SAGE_REF}"; \
    test "$(git -C /src/SageAttention rev-parse HEAD)" = "${SAGE_REF}"; \
    cd /src/SageAttention; \
    CUDA_HOME=/usr/local/cuda-12.9 PATH="/usr/local/cuda-12.9/bin:${PATH}" \
    CPATH="/usr/local/cuda-12.9/include:/usr/local/cuda/include" \
    TORCH_CUDA_ARCH_LIST=12.1 MAX_JOBS=4 NVCC_THREADS=2 \
      pip wheel --no-build-isolation --no-deps -w /wheels . ; \
    mkdir /tmp/x; cd /tmp/x; python -m zipfile -e /wheels/sageattention-*.whl .; \
    for so in sageattention/*.so; do \
      /usr/local/cuda-12.9/bin/cuobjdump --list-elf "$so" | tee -a /wheels/cubins.txt; done; \
    if grep -v 'sm_121a' /wheels/cubins.txt; then echo 'cubin not sm_121a'; exit 1; fi
```

`MAX_JOBS=4` and `NVCC_THREADS=2` keep compile memory in bounds on a box whose CPU and GPU share one pool of memory. In both images, all 9 cubins in the built wheel are `sm_121a` (listed with `cuobjdump --list-elf`). The build asserted that torch was unchanged by the install, and `pip freeze` differed from the image without SageAttention only by `sageattention`. Compiling took about 150 s in the torch 2.7 image and 135 s in the torch 2.13 image; how those were timed is not recorded.

## The kernel is faster

The probe compares SageAttention with flash-attention on synthetic tensors: bf16, head dim 128, batch 1, NHD layout, non-causal. Each call gets 3 warm-up runs, then the mean of 20 runs with `torch.cuda.synchronize()` before and after the timed loop. Accuracy is SageAttention's output against flash-attention's.

```python
import torch, time
from sageattention import sageattn
import flash_attn
from flash_attn import flash_attn_func
import torch.nn.functional as F
torch.manual_seed(0)
dev="cuda"
print("torch",torch.__version__,"flash_attn",flash_attn.__version__,"cc",torch.cuda.get_device_capability())
def bench(fn, n=20):
    for _ in range(3): fn()
    torch.cuda.synchronize(); t=time.time()
    for _ in range(n): fn()
    torch.cuda.synchronize(); return (time.time()-t)/n*1000
for (B,H,L,D) in [(1,24,4608,128),(1,32,4608,128),(1,32,20480,128),(1,32,40960,128)]:
    q,k,v=[torch.randn(B,L,H,D,device=dev,dtype=torch.bfloat16) for _ in range(3)]
    ref=flash_attn_func(q,k,v)
    s=sageattn(q,k,v,tensor_layout="NHD",is_causal=False)
    cos=F.cosine_similarity(ref.float().flatten(),s.float().flatten(),dim=0).item()
    rel=((ref.float()-s.float()).abs().mean()/ref.float().abs().mean()).item()
    tf=bench(lambda: flash_attn_func(q,k,v)); ts=bench(lambda: sageattn(q,k,v,tensor_layout="NHD",is_causal=False))
    print(f"B{B} H{H} L{L} D{D}: flash {tf:.2f} ms  sage {ts:.2f} ms  speedup {tf/ts:.2f}x  cos {cos:.5f} relL1 {rel:.4f}")
    del q,k,v,ref,s; torch.cuda.empty_cache()
```

| Tokens, heads | torch 2.7: flash / sage | Speedup | torch 2.13: flash / sage | Speedup |
|---|---|---|---|---|
| 4608, 24 | 2.90 / 2.63 ms | 1.10x | 2.94 / 2.66 ms | 1.11x |
| 4608, 32 | 3.90 / 3.48 ms | 1.12x | 3.87 / 3.50 ms | 1.11x |
| 20480, 32 | 76.24 / 48.12 ms | 1.58x | 76.88 / 49.29 ms | 1.56x |
| 40960, 32 | 307.57 / 185.39 ms | 1.66x | 315.85 / 188.00 ms | 1.68x |

Table: Mean time per attention call, flash-attention vs SageAttention 2, on synthetic shapes.

Cosine similarity to flash-attention was 0.9992 at every size, and mean relative L1 was 0.038 to 0.039. These are synthetic shapes. The 20k and 40k rows describe the kernel only, not any graph in the end-to-end test.

## The graphs are not

The end-to-end A/B ran in ComfyUI v0.46.0 under these conditions:

- Both arms used the same container image, with SageAttention installed. The only difference was the launch flag: `--use-flash-attention` or `--use-sage-attention`.
- ComfyUI's Comfy Compiler was left at its v0.46.0 default in both arms. By a reading of ComfyUI's release notes and source, it arrived in v0.35.0, is on by default where comfy-aimdo and CUDA are present, uses CUDA graphs, and is turned off by `--disable-comfy-compiler`. Neither arm passed that flag. Whether it invokes `torch.compile`, and whether it was actually active on these GB10 images, is not established.
- Each arm ran one warm-up (seed 100) per graph before its timed runs.
- For the upscale, the first timed run was also dropped in both arms, because the flash arm's first run in a fresh container was still slow (83.1 s; the sage arm's first was 63.971 s). The next three runs are compared. They are repeats with the same input, a 49-frame 1344x768 clip, and the same settings. Their seeds are not recorded.
- Time per run is `execution_success - execution_start` from ComfyUI's `/history`, on warm runs, so model load is not in the figure.
- Every sage arm logged `Using sage attention` at start, and 0 occurrences of `Error running sage attention`, the line ComfyUI logs when it falls back to PyTorch after a SageAttention exception.

| Graph | flash-attention (s) | SageAttention 2 (s) | Median change |
|---|---|---|---|
| Krea 2 Turbo, 1024x1024, 8 steps, seeds 1/2/3 | 113.870 / 115.029 / 114.412 | 113.666 / 113.596 / 115.875 | -0.65% |
| Wan 2.2 TI2V-5B text-to-video, 960x960x49 frames, 12 steps, seeds 1/2 | 373.734 / 375.262 | 372.196 / 371.848 | -0.66% |
| LTX-2.5 video upscale via ReDetail, 1344x768x49, scale 1.0, three runs | 63.882 / 65.391 / 64.513 | 64.730 / 63.550 / 62.529 | -1.49% |

Table: Warm run times per arm. The first two graphs ran on the torch 2.7 image, the upscale on the torch 2.13 image.

Read the spread against the gap:

- **Krea 2:** the arms overlap. flash-attention ran 113.870 to 115.029 s, a spread of about 1.0%, and SageAttention 113.596 to 115.875 s.
- **Upscale:** the arms overlap. flash-attention ran 63.882 to 65.391 s, SageAttention 62.529 to 64.730 s. The mean change is -1.54%.
- **Wan:** the arms do not overlap. Both SageAttention runs beat both flash-attention runs, by 0.4% to 0.9% run for run. With two runs per arm, the median is the mean, and that is not enough to call it a gain.

Krea 2 Turbo at 1024x1024 runs about 4.6k attention tokens. How that count was measured is not recorded. As an arithmetic check only, 4096 image tokens plus 512 text tokens is 4608, the size the probe's first two rows use. The Wan graph was added because Krea's count is that small. Attention token counts for the Wan and upscale graphs were not computed.

## Was SageAttention actually running?

A flat A/B could mean the sage arm was quietly running PyTorch attention. Reading ComfyUI v0.46.0 and SageAttention `cd00653e`, two routes do that without a log line:

1. SageAttention takes no `attn_mask`, so any masked attention call drops to ComfyUI's PyTorch attention, silently.
2. Callers that pass `low_precision_attention=False` (SAM3 and the audio VAE) fall back as well.

This was checked for two of the three graphs. Krea 2's blocks pass `mask=None`, and LTX skips its guide mask when every guide weight is 1.0, which is the upscale's case. The Wan graph was not checked. For Krea 2 and the upscale, together with the zero error lines, a silent fallback does not explain the flat result.

The decoded outputs were checked in both arms:

- They were opened at 1:1 and 2x crops and looked at by the AI agent running the tests, not by a human. Neither arm showed mosaic or blockiness.
- An 8x8 boundary-to-interior gradient ratio was used as a blockiness metric. For the GB10 runs, all that was recorded is that it was equal across arms. The values were not recorded.
- Same-seed outputs differ in fine detail between arms: 29.7 to 31.0 dB PSNR for Krea 2, and 49.75 dB for frame 24 of the upscale. The PSNR tool, and which Krea 2 images were paired beyond sharing a seed, are not recorded.
- flash-attention on the image with SageAttention installed was bit-identical (MSE 0) to flash-attention on the image before it was added, on the Krea 2 Turbo graph. Installing the wheel changes nothing until you pass the flag.

## Why the kernel gain did not carry

This part is inference. No profiler was run.

An earlier run of the same Krea 2 Turbo graph under flash-attention, on ComfyUI v0.46.0 on the same box, read 13.17 s per iteration (how it was read is not recorded). Eight steps at 13.17 s is about 105 s of the roughly 114 s a run takes. That the remainder is text encoding, VAE decode and overhead is itself an inference. Against a step of 13 seconds, an attention call of single-digit milliseconds at 4.6k tokens suggests attention is a small share of a step at that size on this box. That comparison of kernel milliseconds to step seconds is an inference, not a profile.

The GB10 is also far slower per run than the card in the next section on the same graph: about 114 s against about 4.8 s. That gap is hardware, it is not part of this finding, and nothing here says what bounds a GB10 step.

## The same graph on an sm_120 card

On a cloud RTX PRO 6000 Blackwell (sm_120, x86_64), the same SageAttention commit was built for `12.0` and run in ComfyUI v0.46.0 with torch 2.8.0+cu128, the Comfy Compiler at its default in both arms, one warm-up per arm, and the same timing method:

| Graph | PyTorch SDPA (s) | SageAttention 2 (s) | Median change |
|---|---|---|---|
| Krea 2 Turbo, 1024x1024, 8 steps, seeds 1/2/3 | 4.844 / 4.846 / 4.864 | 4.713 / 4.721 / 4.732 | -2.58% |

Table: The mean change is -2.67%. Here the arms do not overlap.

The decoded outputs were looked at in the same way, 1:1 crops included, with no mosaic or blockiness, and the 8x8 ratio read 0.97 to 0.99 in both arms. This is not a controlled comparison with the GB10. The baseline is PyTorch SDPA, not flash-attention, the torch version differs, and so do the GPU and its memory system. It shows SageAttention 2 giving a measurable end-to-end gain on this graph on another Blackwell part. It does not explain the GB10 result.

::: caveats
- **Where a GB10 step goes.** No profiler was run. "Attention is a small share of a step at these sizes" is an inference from kernel milliseconds against a 13.17 s step, and so is the split of the rest into text encoding, decode and overhead.
- **The Wan gap.** Both SageAttention runs beat both flash-attention runs by 0.4% to 0.9%, at two runs per arm. A real sub-1% gain on that graph is possible and not established. The silent-fallback check was not done for Wan either.
- **Long sequences.** No graph with a known attention length well past 4.6k tokens (high-resolution images, long video) was tested end to end. The kernel shows 1.56x to 1.68x at 20k to 40k synthetic tokens. The end-to-end gain at those lengths is unknown.
- **Small n.** 3, 2 and 3 timed runs per arm.
- **The Comfy Compiler.** Whether it invokes `torch.compile`, and whether it was active on the GB10 images, is not established. It was held the same in both arms.
- **Quality.** The PSNR and blockiness figures are measurements, the outputs were looked at by an AI agent rather than a person, and the PSNR method is not recorded.
- **Read, not tested:** that `sm_120a` cubins do not load on sm_121, and that cpp_extension rejects only a CUDA major-version mismatch.
- **SageAttention 3 on sm_121** is reported to produce mosaic output or hang. The upstream issues are [#321](https://github.com/thu-ml/SageAttention/issues/321) and [#414](https://github.com/thu-ml/SageAttention/issues/414). That claim came second hand, the issues were not re-read for this post, and SageAttention 3 was not tested.
- **Also second hand and untested:** that the `v2.2.0` tag cannot target sm_121, and that Triton and `torch.compile` are unreliable on sm_121. Only `main` at `cd00653e` was read and built. SageAttention's own sm_121 path uses neither, which says nothing about the rest of the stack.
- **Versions.** Only ComfyUI v0.46.0, SageAttention `cd00653e`, and flash_attn 2.7.3 and 2.7.4.post1 were tested. A later release of any of them could change the result.
:::

## What went wrong on the way

**1. "Compile SageAttention per image with each image's own toolchain."** The plan assumed every container could target sm_121 with the compiler it ships. NGC PyTorch 25.03 cannot: its nvcc 12.8.93 stops at compute_120. Running `nvcc --list-gpu-arch` inside the image showed it, and the CUDA 12.9 builder stage above fixed it.

**2. The upscale tool returned the source clip, and an earlier check had "verified" it.** [ReDetail](https://github.com/Bambushu/redetail) is a public, MIT-licensed CLI that drives LTX-2.5 upscaling through ComfyUI. It was used here pinned at `ff57d7601e13a39e92d60b48ca783b7486809385`. At that commit, `wait()` in `redetail.py` returns the first item it finds in the prompt's `/history` outputs. On ComfyUI v0.46.0 the `LoadVideo` node reports its input video as a UI item with `type: input`, listed before `SaveVideo`'s `type: output` item. So the CLI downloads the input.

Every `--out` file from the A/B, and from an earlier check, was byte-identical to every other. That earlier check had concluded the upscaled frames "match the source", which they did, because it was comparing the source with itself. Comparing hashes of the `--out` files with the raw `SaveVideo` files in ComfyUI's output directory, which differed per arm, is what caught it. The timing A/B used `/history` times and the raw `SaveVideo` files, so its numbers are unaffected.

The fix, inside the loop over `("video", "videos", "gifs", "images")` in `wait()`. Before:

```python
if out.get(k):
    return out[k][0]
```

After, returning the first item whose `type` is `"output"` and treating an item with no `type` as output:

```python
for item in out.get(k) or []:
    if item.get("type", "output") == "output":
        return item
```

A re-run with the patch returned the render, at 29.30 dB PSNR against the source (the PSNR tool and frame choice are not recorded). This describes the tool at that one commit. Whether a later commit changed it was not checked. If you use it, compare a hash of what it downloads against what ComfyUI wrote before trusting it.

**3. A kernel speedup was taken as a reason to expect an end-to-end speedup.** The 1.1x to 1.7x kernel gain moved end-to-end median time by at most 1.5% on the graphs tested, and established no gain on any of them. The end-to-end A/B is what corrected it, which is the argument for running one before you adopt a kernel.

## Where that leaves it

On a GB10 running ComfyUI v0.46.0, SageAttention 2 from `main` builds, runs and is accurate to flash-attention within the figures above. On an 8-step 1024x1024 image graph, a 49-frame text-to-video graph and a 49-frame upscale, it did not make anything measurably faster. If your graphs run attention at lengths far past 4.6k tokens, the kernel numbers say it might, and that has not been measured. Measure your own graph, end to end, with more than two runs per arm.
