Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions benchmark/linear_attention/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2404/sbs
RUN git clone https://github.com/NVIDIA/cudnn-frontend.git
RUN pip install -v /workspace/cudnn-frontend

# Install the Cutlass DSL runtime (cuDNN FROST engines) and FLA
RUN pip install nvidia-cutlass-dsl[cu13]==4.5.0 flash-linear-attention
# Install the Cutlass DSL runtime (cuDNN FROST engines) and FLA.
RUN pip install nvidia-cutlass-dsl[cu13]==4.7.0 apache-tvm-ffi flash-linear-attention

# Install FlashQLA from source.
RUN git clone https://github.com/QwenLM/FlashQLA.git
RUN pip install -v /workspace/FlashQLA
Comment on lines +22 to +27

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

printf '%s\n' '--- Dockerfile ---'
cat -n benchmark/linear_attention/Dockerfile

printf '%s\n' '--- dependency and benchmark references ---'
rg -n -i --glob '!node_modules' --glob '!dist' \
  'FlashQLA|flash-linear-attention|apache-tvm-ffi|nvidia-cutlass-dsl|constraints|requirements|lock' \
  benchmark README* .github 2>/dev/null || true

printf '%s\n' '--- tracked files near the benchmark ---'
git ls-files benchmark/linear_attention

Repository: NVIDIA/cudnn-frontend

Length of output: 36203


🌐 Web query:

QwenLM FlashQLA GitHub README benchmark instructions pinned dependencies release notes API alignment

💡 Result:

FlashQLA is a high-performance linear attention library by QwenLM designed to accelerate Gated Delta Networks (GDN) [1]. Benchmark Instructions To benchmark FlashQLA, you must have the required dependencies installed, including flash-linear-attention (FLA) and flashinfer [2][3]. The benchmark scripts are located in the benchmark directory [2][4]. For example, to run the gated delta rule benchmark, ensure the correct versions are installed and run the script [2][4]: pip install flash_linear_attention==0.5.0 flashinfer-python==0.6.13 python benchmark/bench_gated_delta_rule.py Detailed benchmark results for H200 (SM90) and GB200 (SM100) are available in the repository's benchmark directory [2][5]. Pinned Dependencies The project enforces specific dependency versions for compatibility [1]. As of version 0.1.2, these include: - torch: >=2.8 [1] - tilelang: ==0.1.9 [1] - apache-tvm-ffi: ==0.1.9 [1] - flash_linear_attention: ==0.5.0 (for comparison/API alignment) [2][3] Release Notes - v0.1.2 (July 2026): Added forward pass support for SM120 (Blackwell) architectures and established the library as a backend for the flash-linear-attention GDN, enabling plug-and-play acceleration [1]. - v0.1.1 (June 2026): Introduced intra-card sequence parallelism for the backward pass and added SM100 architecture support [5][1]. This release also upgraded the tilelang dependency to v0.1.9 and aligned entry function signatures with the latest flash-linear-attention interface [5][6][1]. API Alignment FlashQLA is aligned with the flash-linear-attention (FLA) API, allowing it to serve as a high-performance backend [1]. The high-level API is accessed via chunk_gated_delta_rule, and the low-level API provides separate forward (chunk_gated_delta_rule_fwd) and backward (chunk_gated_delta_rule_bwd) functions, mirroring standard interfaces used in linear attention research [1].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

cat -n benchmark/linear_attention/Dockerfile
rg -n -i 'FlashQLA|flash-linear-attention|apache-tvm-ffi|nvidia-cutlass-dsl|constraints|requirements|lock' \
  benchmark README* .github 2>/dev/null || true
git ls-files benchmark/linear_attention

Repository: NVIDIA/cudnn-frontend

Length of output: 36099


🌐 Web query:

QwenLM FlashQLA GitHub README benchmark pinned dependencies release notes API alignment

💡 Result:

FlashQLA is a high-performance linear attention kernel library developed by QwenLM that leverages the TileLang compiler to optimize GDN (Gated Delta Network) Chunked Prefill operations [1][2]. Key technical aspects include: Benchmarks: The library demonstrates significant performance improvements over the FLA (Flash Linear Attention) Triton kernel, achieving 2-3x speedup in forward passes and 2x speedup in backward passes on NVIDIA Hopper (SM90) and Blackwell (SM100) architectures [2][3]. Detailed benchmark results for H200 and GB200 systems are provided in the repository's benchmark directory [3]. Pinned Dependencies: The project maintains strict dependency requirements to ensure compatibility with its TileLang-based kernels. According to setup.py and README documentation, the library requires: - Python >= 3.10 [4] - PyTorch >= 2.8 [2][4] - TileLang == 0.1.9 [4] - Apache-tvm-ffi == 0.1.9 [4] - CUDA 12.8 or above [2] Release Notes & Alignment: Recent updates, such as v0.1.1, introduced support for the SM100 architecture and the state_v_first parameter [5][3]. A key focus in recent releases has been aligning the entry function signatures with the latest interfaces from the flash-linear-attention library, ensuring better interoperability [5][3]. API: FlashQLA provides both high-level and low-level APIs [1][6]: - High-level: Access via chunk_gated_delta_rule, which handles the core forward/backward computations and state management [1]. - Low-level: Access via separate chunk_gated_delta_rule_fwd and chunk_gated_delta_rule_bwd functions for fine-grained control over forward and backward passes [1]. The project is released under the MIT License [1][4].

Citations:


🏁 Script executed:

#!/bin/bash
set -eu

python3 - <<'PY'
import json
import urllib.request

urls = {
    "tags": "https://api.github.com/repos/QwenLM/FlashQLA/tags?per_page=20",
    "setup": "https://raw.githubusercontent.com/QwenLM/FlashQLA/main/setup.py",
    "readme": "https://raw.githubusercontent.com/QwenLM/FlashQLA/main/README.md",
    "releases": "https://api.github.com/repos/QwenLM/FlashQLA/releases?per_page=10",
}
for name, url in urls.items():
    print(f"--- {name} ---")
    request = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json"})
    with urllib.request.urlopen(request) as response:
        data = response.read().decode()

    if name in {"tags", "releases"}:
        for item in json.loads(data):
            if name == "tags":
                print(item["name"], item["commit"]["sha"])
            else:
                print(item["tag_name"], item["target_commitish"])
    else:
        for number, line in enumerate(data.splitlines(), 1):
            if any(term in line.lower() for term in (
                "install_requires", "apache-tvm-ffi",
                "flash_linear_attention", "tilelang",
                "pip install", "benchmark", "0.1.",
            )):
                print(f"{number}: {line}")
PY

cat -n benchmark/linear_attention/README.md | sed -n '45,110p'

Repository: NVIDIA/cudnn-frontend

Length of output: 2459


🏁 Script executed:

#!/bin/bash
set -eu

fetch() {
  curl -k -fsSL --retry 2 "$1"
}

printf '%s\n' '--- tags ---'
fetch 'https://api.github.com/repos/QwenLM/FlashQLA/tags?per_page=20' |
  jq -r '.[] | [.name, .commit.sha] | `@tsv`'

printf '%s\n' '--- releases ---'
fetch 'https://api.github.com/repos/QwenLM/FlashQLA/releases?per_page=10' |
  jq -r '.[] | [.tag_name, .target_commitish] | `@tsv`'

printf '%s\n' '--- setup.py dependency lines ---'
fetch 'https://raw.githubusercontent.com/QwenLM/FlashQLA/main/setup.py' |
  nl -ba |
  grep -Ei 'apache-tvm-ffi|flash[_-]linear[_-]attention|tilelang|install_requires|version'

printf '%s\n' '--- README install and benchmark lines ---'
fetch 'https://raw.githubusercontent.com/QwenLM/FlashQLA/main/README.md' |
  nl -ba |
  grep -Ei -C 3 'apache-tvm-ffi|flash[_-]linear[_-]attention|tilelang|benchmark|pip install'

Repository: NVIDIA/cudnn-frontend

Length of output: 406


🏁 Script executed:

#!/bin/bash
set -eu

fetch() {
  curl -k -fsSL --retry 2 "$1"
}

for ref in v0.1.2 main; do
  printf '%s\n' "--- setup.py at $ref ---"
  fetch "https://raw.githubusercontent.com/QwenLM/FlashQLA/$ref/setup.py" |
    grep -Ei -C 3 'apache-tvm-ffi|flash[_-]linear[_-]attention|tilelang|install_requires|version' || true

  printf '%s\n' "--- README at $ref ---"
  fetch "https://raw.githubusercontent.com/QwenLM/FlashQLA/$ref/README.md" |
    grep -Ei -C 3 'apache-tvm-ffi|flash[_-]linear[_-]attention|tilelang|benchmark|pip install' || true
done

Repository: NVIDIA/cudnn-frontend

Length of output: 8408


Pin the complete benchmark dependency set.

Pin the FlashQLA tag or commit, flash-linear-attention==0.5.0, and all transitive dependencies. FlashQLA v0.1.2 requires tilelang==0.1.9 and apache-tvm-ffi==0.1.9. Also pin the cudnn-frontend source clone. Record the tested versions in a constraints or lock file to keep benchmark results comparable across rebuilds.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@benchmark/linear_attention/Dockerfile` around lines 22 - 27, Pin the
benchmark environment in the Dockerfile around the FlashQLA installation: check
out a specific FlashQLA tag or commit, require flash-linear-attention==0.5.0,
and pin cudnn-frontend to a specific source revision. Add and apply a
constraints or lock file covering these packages and all transitive
dependencies, including tilelang==0.1.9 and apache-tvm-ffi==0.1.9, while
recording the tested versions.

Source: MCP tools


# Install the chart dependencies for plot_results.py
RUN pip install pandas matplotlib seaborn
12 changes: 11 additions & 1 deletion benchmark/linear_attention/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ python benchmark_single_linear_attention.py \
--la_backend fla --variant gdn --data_type bfloat16 \
--skip_ref --fwd_bwd

# FlashQLA (TileLang) comparison point (gdn variant only)
python benchmark_single_linear_attention.py \
--batch_size 1 --seqlen 8192 \
--num_q_heads 8 --num_kv_heads 64 --head_dim 128 \
--la_backend flash_qla --variant gdn --data_type bfloat16 \
--skip_ref --fwd_bwd

# Recurrent state ports: seed with an initial state and request the final
# state (its gradient feeds the backward pass)
python benchmark_single_linear_attention.py \
Expand All @@ -76,6 +83,7 @@ Dropping `--skip_ref` validates the forward output against FLA (the same way the
|---------|-------------|
| `cudnn` | cuDNN (native, via the cuDNN Frontend torch custom ops) |
| `fla` | FLA (flash-linear-attention, Triton) |
| `flash_qla` | FlashQLA (TileLang fused GDN kernels, `gdn` variant only) |

The cuDNN backend routes through the pygraph engines: FROST (Cutlass DSL) on SM100-class devices, the cuTile engines elsewhere. Both passes run through autograd, exactly like a training step.

Expand All @@ -89,9 +97,11 @@ The cuDNN backend routes through the pygraph engines: FROST (Cutlass DSL) on SM1

The benchmark runs `kda` and `gdn2` with the in-kernel q/k L2 normalization off (`use_qk_l2norm_in_kernel=False`) on every backend, for an apples-to-apples comparison.

Recent `fla` releases dispatch `chunk_gated_delta_rule` to FlashQLA whenever `flash_qla` is importable; the benchmark sets `FLA_DISABLE_BACKEND_DISPATCH=1` (unless already set) so the `fla` backend always measures FLA's own Triton kernels and the two backends stay distinct.

## Notes

- Head convention: `--num_q_heads` counts the query/key heads and `--num_kv_heads` counts the value heads; the gates, output, and recurrent state live at `max(num_q_heads, num_kv_heads)` heads. Both grouping directions are supported for `gdn`: grouped-value attention (`num_kv_heads > num_q_heads`, v-heads grouped over q-heads) and GQA (`num_q_heads > num_kv_heads`, q-heads grouped over v-heads, e.g. `--num_q_heads 64 --num_kv_heads 8`). The two counts must be equal or one a multiple of the other; `kda` and `gdn2` support the GVA direction only.
- Head convention: `--num_q_heads` counts the query/key heads and `--num_kv_heads` counts the value heads; the gates, output, and recurrent state live at `max(num_q_heads, num_kv_heads)` heads. Both grouping directions are supported for `gdn`: grouped-value attention (`num_kv_heads > num_q_heads`, v-heads grouped over q-heads) and GQA (`num_q_heads > num_kv_heads`, q-heads grouped over v-heads, e.g. `--num_q_heads 64 --num_kv_heads 8`). The two counts must be equal or one a multiple of the other; `kda` and `gdn2` support the GVA direction only, and so does the `flash_qla` backend.
- The cuDNN ops use the THD (token-packed) layout internally; the benchmark expresses the dense batch as `cu_seqlens = [0, T, 2T, ...]`.
- `--initial_state` provides a per-sequence fp32 recurrent state (its gradient is produced in the backward pass); `--store_on` requests the per-sequence final state from the forward pass and feeds its gradient in the backward pass. Both are once-per-kernel I/O ports (one `[head_dim_qk, head_dim_vo]` tile per sequence per state head).
- Performance is measured with the torch profiler (device time of the matched kernels), with a 256 MB L2 flush before each timed iteration and the median reported. TFLOPS use the chunked-BMM FLOPs model documented in the script's `flops()`.
50 changes: 43 additions & 7 deletions benchmark/linear_attention/benchmark_single_linear_attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def parse_args():
help="Linear attention backend to use",
choices=[
"fla",
"flash_qla",
"cudnn",
],
)
Expand Down Expand Up @@ -249,7 +250,7 @@ def run_benchmark(
head_dim_qk: Head dimension for Q/K (optional, for asymmetric)
head_dim_vo: Head dimension for V/O (optional, for asymmetric)
data_type: Data type ("bfloat16", "float16")
backend: Backend name ("cudnn", "fla")
backend: Backend name ("cudnn", "fla", "flash_qla")
variant: Linear attention variant ("gdn", "kda", "gdn2")
profile_pass: Which pass to profile ("fwd", "bwd", "both")
num_iterations: Number of benchmark iterations
Expand Down Expand Up @@ -436,6 +437,11 @@ def run_benchmark(
raise ValueError("gdn2 is forward only (the backward kernel is a stub); use --profile_pass fwd")
if args.variant == "gdn2" and args.la_backend == "fla":
raise ValueError("gdn2 is only supported with the 'cudnn' backend")
if args.la_backend == "flash_qla":
if args.variant != "gdn":
raise ValueError("flash_qla only supports the 'gdn' variant")
if num_q_heads > num_kv_heads:
raise ValueError("flash_qla does not support GQA (num_q_heads > num_kv_heads)")

l2_flush_size_mb = 256
l2_flush_size = l2_flush_size_mb * 1024 * 1024
Expand Down Expand Up @@ -507,9 +513,33 @@ def cudnn_linear_attention(query, key, value, gate, beta, write_gate, s0):
use_qk_l2norm_in_kernel=False,
)

if args.la_backend == "flash_qla":
attn_scale = head_dim_qk ** (-0.5)

from flash_qla import chunk_gated_delta_rule as fqla_chunk_gated_delta_rule

if args.verbose:
import flash_qla

print(f"[INFO] FlashQLA Version: {getattr(flash_qla, '__version__', 'unknown')}")

def flash_qla_linear_attention(query, key, value, gate, beta, write_gate, s0):
return fqla_chunk_gated_delta_rule(
query,
key,
value,
gate,
beta,
scale=attn_scale,
initial_state=s0,
output_final_state=args.store_on,
)

if args.la_backend == "fla" or (not args.skip_ref):
attn_scale = head_dim_qk ** (-0.5)

os.environ.setdefault("FLA_DISABLE_BACKEND_DISPATCH", "1")

if args.variant == "gdn":
from fla.ops.gated_delta_rule import chunk_gated_delta_rule
elif args.variant == "kda":
Expand Down Expand Up @@ -549,21 +579,23 @@ def fla_linear_attention(query, key, value, gate, beta, write_gate, s0):
def get_linear_attention_function(backend):
if backend == "fla":
return fla_linear_attention
elif backend == "flash_qla":
return flash_qla_linear_attention
elif backend == "cudnn":
return cudnn_linear_attention
else:
raise ValueError(f"Invalid backend: {backend}")

# Util function for addressing different qkv formats for each backend
# (cudnn is THD [B*T, H, D]; fla is dense [B, T, H, D])
# (cudnn is THD [B*T, H, D]; fla and flash_qla are dense [B, T, H, D])
def preprocess_qkv(query, key, value, backend):
if backend == "cudnn":
return (
query.reshape(batch_size * seqlen, *query.shape[2:]),
key.reshape(batch_size * seqlen, *key.shape[2:]),
value.reshape(batch_size * seqlen, *value.shape[2:]),
)
elif backend == "fla":
elif backend in ("fla", "flash_qla"):
return query, key, value
else:
raise ValueError(f"Invalid backend: {backend}")
Expand All @@ -575,7 +607,7 @@ def preprocess_gates(gate, beta, write_gate, backend):
beta.reshape(batch_size * seqlen, *beta.shape[2:]),
write_gate.reshape(batch_size * seqlen, *write_gate.shape[2:]) if write_gate is not None else None,
)
elif backend == "fla":
elif backend in ("fla", "flash_qla"):
return gate, beta, write_gate
else:
raise ValueError(f"Invalid backend: {backend}")
Expand All @@ -584,7 +616,7 @@ def preprocess_gates(gate, beta, write_gate, backend):
def postprocess_o(output, backend):
if backend == "cudnn":
return output.reshape(batch_size, seqlen, num_o_heads, head_dim_vo)
elif backend == "fla":
elif backend in ("fla", "flash_qla"):
return output
else:
raise ValueError(f"Invalid backend: {backend}")
Expand Down Expand Up @@ -800,8 +832,12 @@ def generate_gates(io_dtype):
query_ref = query.detach().reshape(batch_size, seqlen, num_q_heads, head_dim_qk)
key_ref = key.detach().reshape(batch_size, seqlen, num_q_heads, head_dim_qk)
value_ref = value.detach().reshape(batch_size, seqlen, num_kv_heads, head_dim_vo)
gate_ref = gate.detach().reshape(batch_size, seqlen, *gate.shape[1:])
beta_ref = beta.detach().reshape(batch_size, seqlen, *beta.shape[1:])
if args.la_backend == "cudnn":
gate_ref = gate.detach().reshape(batch_size, seqlen, *gate.shape[1:])
beta_ref = beta.detach().reshape(batch_size, seqlen, *beta.shape[1:])
else:
gate_ref = gate.detach()
beta_ref = beta.detach()
s0_ref = s0.detach() if s0 is not None else None
output_ref, _ = fla_linear_attention(query_ref, key_ref, value_ref, gate_ref, beta_ref, None, s0_ref)

Expand Down
164 changes: 164 additions & 0 deletions benchmark/linear_attention/plot_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

"""
Chart generation for linear attention benchmark results.

Reads the CSV emitted by the shmoo runner (one --format_output line per
(backend, batch, seqlen) case) and generates one comparison chart per batch
size, with Forward and Backward TFLOPS panels side by side — same style as
the SDPA training benchmark charts.

python plot_results.py results/gdn/b300/gdn_labench.csv \
--output-dir results/gdn/b300 --gpu-name B300 --cudnn-version 9.24.0
"""

import argparse
from pathlib import Path

import pandas as pd
import matplotlib

matplotlib.use("Agg")
import matplotlib.pyplot as plt
import seaborn as sns
Comment thread
coderabbitai[bot] marked this conversation as resolved.

# Backend display configuration; `order` fixes both bar grouping and legend order.
BACKEND_CONFIG = {
"fla": {"name": "FLA (Triton)", "color": "#FF8C00", "order": 0},
"flash_qla": {"name": "FlashQLA (TileLang)", "color": "#6495ED", "order": 1},
"cudnn": {"name": "cuDNN", "color": "#76b900", "order": 2},
}

LABEL_FONT_SIZE = 10
LEGEND_FONT_SIZE = 8
TITLE_FONT_SIZE = 12
BAR_LABEL_FONT_SIZE = 6

CSV_COLUMNS = [
"case_tag",
"backend",
"variant",
"batch_size",
"seqlen",
"num_q_heads",
"num_kv_heads",
"head_dim",
"fwd_ms",
"bwd_ms",
"fwd_tflops",
"bwd_tflops",
"max_diff",
"num_iters",
]


def get_backend_display_name(backend: str, cudnn_version: str = None) -> str:
base_name = BACKEND_CONFIG.get(backend, {}).get("name", backend)
if backend == "cudnn" and cudnn_version:
base_name = f"{base_name} {cudnn_version}"
return base_name


def generate_charts(df: pd.DataFrame, output_dir: Path, gpu_name: str = "", cudnn_version: str = None, variant: str = "gdn", batch_sizes: list = None) -> list:
output_dir.mkdir(parents=True, exist_ok=True)

df = df[df["variant"] == variant].copy()
if batch_sizes:
df = df[df["batch_size"].isin(batch_sizes)].copy()
if df.empty:
raise ValueError(f"No rows for variant {variant!r}")

df["backend_display"] = df["backend"].map(lambda b: get_backend_display_name(b, cudnn_version=cudnn_version))
df["backend_order"] = df["backend"].map(lambda b: BACKEND_CONFIG.get(b, {}).get("order", 99))

palette = {}
for _, row in df[["backend", "backend_display"]].drop_duplicates().iterrows():
palette[row["backend_display"]] = BACKEND_CONFIG.get(row["backend"], {}).get("color", "gray")

saved_paths = []
for batch_size in sorted(df["batch_size"].unique()):
sub = df[df["batch_size"] == batch_size].copy()
sub.sort_values(["seqlen", "backend_order"], inplace=True)
hue_order = list(sub.sort_values("backend_order")["backend_display"].drop_duplicates())

fwd_df = sub[sub["fwd_tflops"] > 0]
bwd_df = sub[sub["bwd_tflops"] > 0]
has_fwd = not fwd_df.empty
has_bwd = not bwd_df.empty

if has_fwd and has_bwd:
fig, (ax_fwd, ax_bwd) = plt.subplots(1, 2, figsize=(14, 6), dpi=150)
elif has_fwd:
fig, ax_fwd = plt.subplots(1, 1, figsize=(10, 6), dpi=150)
ax_bwd = None
else:
fig, ax_bwd = plt.subplots(1, 1, figsize=(10, 6), dpi=150)
ax_fwd = None

heads = sub["num_q_heads"].iloc[0]
head_dim = sub["head_dim"].iloc[0]
gpu_info = f" ({gpu_name})" if gpu_name else ""
fig.suptitle(
f"{variant.upper()} Linear Attention (BF16) — Batch = {batch_size}, Heads = {heads}, d = {head_dim}{gpu_info}",
fontsize=TITLE_FONT_SIZE,
)

for ax, pass_df, pass_name, y_col in (
(ax_fwd, fwd_df, "Forward", "fwd_tflops"),
(ax_bwd, bwd_df, "Backward", "bwd_tflops"),
):
if ax is None or pass_df.empty:
continue
sns.barplot(
data=pass_df,
x="seqlen",
y=y_col,
hue="backend_display",
hue_order=hue_order,
ax=ax,
palette=palette,
edgecolor="black",
linewidth=0.5,
errorbar=None,
)
ax.set_xlabel("Sequence Length", fontsize=LABEL_FONT_SIZE)
ax.set_ylabel("TFLOPS", fontsize=LABEL_FONT_SIZE)
ax.set_title(pass_name, fontsize=TITLE_FONT_SIZE)
ax.legend(title="Backend", fontsize=LEGEND_FONT_SIZE)
ax.tick_params(axis="x", rotation=45)
for container in ax.containers:
ax.bar_label(container, fmt="%.0f", fontsize=BAR_LABEL_FONT_SIZE)

plt.tight_layout()
output_path = output_dir / f"{variant}_b{batch_size}.png"
plt.savefig(output_path, dpi=150, bbox_inches="tight")
plt.close()
saved_paths.append(output_path)
print(f"Chart saved to {output_path}")

return saved_paths


def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("csv", type=Path, help="Results CSV from the shmoo runner")
parser.add_argument("--output-dir", type=Path, default=None, help="Output directory (default: alongside the CSV)")
parser.add_argument("--gpu-name", default="", help="GPU name for the chart title")
parser.add_argument("--cudnn-version", default=None, help="cuDNN backend version for the legend (e.g. 9.24.0)")
parser.add_argument("--variant", default="gdn", help="Linear attention variant to plot")
parser.add_argument("--batch-sizes", default=None, help="Comma-separated batch sizes to plot (default: all in the CSV)")
args = parser.parse_args()
batch_sizes = [int(b) for b in args.batch_sizes.split(",")] if args.batch_sizes else None

df = pd.read_csv(args.csv)
missing = [c for c in CSV_COLUMNS if c not in df.columns]
if missing:
raise ValueError(f"CSV is missing expected columns: {missing}")

output_dir = args.output_dir if args.output_dir is not None else args.csv.parent
generate_charts(df, output_dir, gpu_name=args.gpu_name, cudnn_version=args.cudnn_version, variant=args.variant, batch_sizes=batch_sizes)


if __name__ == "__main__":
main()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions benchmark/linear_attention/results/gdn/b300/gdn_20260806.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
case_tag,backend,variant,batch_size,seqlen,num_q_heads,num_kv_heads,head_dim,fwd_ms,bwd_ms,fwd_tflops,bwd_tflops,max_diff,num_iters
fla_B1_T2048,fla,gdn,1,2048,64,64,128,0.217,0.649,89,89,0.000000,20
flash_qla_B1_T2048,flash_qla,gdn,1,2048,64,64,128,0.102,0.352,190,165,0.000000,20
cudnn_B1_T2048,cudnn,gdn,1,2048,64,64,128,0.098,0.279,196,208,0.000000,20
fla_B1_T4096,fla,gdn,1,4096,64,64,128,0.416,1.260,93,92,0.000000,20
flash_qla_B1_T4096,flash_qla,gdn,1,4096,64,64,128,0.186,0.677,208,171,0.000000,20
cudnn_B1_T4096,cudnn,gdn,1,4096,64,64,128,0.129,0.428,301,271,0.000000,20
fla_B1_T8192,fla,gdn,1,8192,64,64,128,0.796,2.490,97,93,0.000000,20
flash_qla_B1_T8192,flash_qla,gdn,1,8192,64,64,128,0.347,1.342,223,173,0.000000,20
cudnn_B1_T8192,cudnn,gdn,1,8192,64,64,128,0.187,0.721,414,321,0.000000,20
fla_B1_T16384,fla,gdn,1,16384,64,64,128,1.567,4.957,99,94,0.000000,20
flash_qla_B1_T16384,flash_qla,gdn,1,16384,64,64,128,0.674,2.648,229,175,0.000000,20
cudnn_B1_T16384,cudnn,gdn,1,16384,64,64,128,0.305,1.309,506,354,0.000000,20
fla_B1_T32768,fla,gdn,1,32768,64,64,128,3.119,9.976,99,93,0.000000,20
flash_qla_B1_T32768,flash_qla,gdn,1,32768,64,64,128,1.329,5.294,233,175,0.000000,20
cudnn_B1_T32768,cudnn,gdn,1,32768,64,64,128,0.529,2.494,585,372,0.000000,20