Skip to content

[Triton/Gluon] Move the sage-attention launch params into the config tree - #5106

Merged
Boss2002n merged 5 commits into
mainfrom
satya/triton-sage-config-to-json
Sep 2, 2026
Merged

Boss2002n merged 5 commits into
mainfrom
satya/triton-sage-config-to-json

Conversation

@Boss2002n

Copy link
Copy Markdown
Contributor

No description provided.

@Boss2002n
Boss2002n requested review from a team and a lite review from Copilot August 29, 2026 04:44
@github-actions

Copy link
Copy Markdown
Contributor

🏷️ CI Guide

Runs automatically on every PR:

  • ✅ Pre-checks (submodule verification, code formatting)
  • ✅ Aiter op tests (gfx942 + gfx950)
  • ✅ Triton tests on MI35X (only when aiter/ops/triton/** or related paths are changed)

Extended tests (opt-in via labels):

Label Tests
ci:gfx1250-ffm-triton Run the five-shard gfx1250 FFM Triton test suite
ci:triton-300x Run an additional Triton test job on MI300X in PRs; main branch always runs both MI35X and MI300X
multigpu Aiter multi-GPU tests on the 8-GPU runner
ci:sglang SGLang integration tests: DeepSeek-R1-MXFP4 accuracy, Qwen 3.5 accuracy
ci:atom ATOM benchmark: DeepSeek-R1-0528, GPT-OSS-120B
ci:atom_full ATOM accuracy suite for PR and main models from ATOM models_accuracy.json
ci:vllm vLLM benchmark: GPT-OSS-120B, DeepSeek-R1-0528, Kimi-K2.5
ci:all All standard extended tests (excludes ci:atom_full)

Only add ci:atom_full for FlyDSL or Triton upgrades.
Add labels via the sidebar or gh pr edit 5106 --add-label <label>

PR title tags:
Component tags ([Triton/Gluon], [HIP], [CK], [ASM], ...) are added to the PR title automatically from the changed files and re-synced on every push — change-type tags like [fix]/[Perf] and op tags like [MLA] are left untouched. Add the no-auto-title label to opt this PR out of title tagging.

@github-actions github-actions Bot changed the title [Triton] Move the sage-attention launch params into the config tree [Triton/Gluon] Move the sage-attention launch params into the config tree Aug 29, 2026

Copilot AI left a comment

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.

Pull request overview

Moves Sage-attention (fav3_sage) forward launch parameters out of Python and into the nested Triton config tree, so launch tuning is data-driven and consistent with the rest of the config-loading machinery.

Changes:

  • Add nested-layout DEFAULT.json config tables for fav3_sage on gfx942 and gfx950, and for fav3_sage_mxfp4 on gfx950.
  • Update fav3_sage to load per-arch configs via resolve_config_dir()/load_config_json(), with a deterministic gfx942 fallback when the running arch has no table.
  • Update the MXFP4 wrapper to load its forward launch config from the config tree (gfx950-only).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
aiter/ops/triton/configs/gfx950/triton/attention/fav3_sage/DEFAULT.json Adds gfx950 default + optional fwd_a3_tuned preset for fav3_sage forward launch params.
aiter/ops/triton/configs/gfx950/triton/attention/fav3_sage_mxfp4/DEFAULT.json Adds gfx950 default forward launch params for the MXFP4 variant.
aiter/ops/triton/configs/gfx942/triton/attention/fav3_sage/DEFAULT.json Adds gfx942 default + optional fwd_a3_tuned preset for fav3_sage forward launch params.
aiter/ops/triton/attention/fav3_sage.py Replaces hardcoded arch-specific dicts with config-tree loading + gfx942 fallback.
aiter/ops/triton/attention/fav3_sage_attention_mxfp4_wrapper.py Replaces hardcoded launch dict with config-tree loading for gfx950.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@zufayu
zufayu requested review from a team and Dewei-Wang-sh August 31, 2026 01:17
"Tuning values live in JSON, never in Python" -- two sage config selectors
still returned hardcoded dicts:

  attention/fav3_sage.py                         three arch branches, one dict each
  attention/fav3_sage_attention_mxfp4_wrapper.py one dict behind an arch guard

Both now read <arch>/triton/attention/{fav3_sage,fav3_sage_mxfp4}/DEFAULT.json
through resolve_config_dir() + load_config_json(). The a3_tuned preset moves
into the JSON as a `fwd_a3_tuned` overlay on `fwd`; the `if a3_tuned:` branch
and the mxfp4 wrapper's non-gfx950 guard are control flow and stay in Python.

The JSON carries exactly the numbers the Python returned. Verified by
extracting both versions of the function and comparing their output for every
architecture across the full block_m x block_n x a3_tuned matrix -- equal in
value, key order and value type (PRE_LOAD_V stays a bool, not 0).

Two things a reviewer should weigh in on:

- The old `else:` branch was byte-identical to gfx942, so arches with no tuned
  table of their own read the gfx942 file through an explicit
  `arch=_FALLBACK_ARCH` retry. That preserves today's behaviour exactly, but it
  is a second instance of the arch-fallback pattern that so far only MHC uses.
  Tuning those arches and dropping the fallback is the better end state.
- Both functions copy before returning. load_config_json hands back the shared
  cached dict and get_sage_fwd_configs mutates what it returns, so without the
  copy an a3_tuned=True call would poison the cache for every later caller.
Copilot AI review requested due to automatic review settings August 31, 2026 06:05
@Boss2002n
Boss2002n force-pushed the satya/triton-sage-config-to-json branch from 60081ea to 9c09646 Compare August 31, 2026 06:05

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comment thread aiter/ops/triton/attention/fav3_sage.py Resolved
Copilot AI review requested due to automatic review settings August 31, 2026 14:35
Removed comments regarding import behavior and tracing paths.

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (1)

aiter/ops/triton/attention/fav3_sage.py:44

  • os.scandir() returns an iterator that holds an open directory handle; relying on implicit closure after sorted() can leave the fd open longer than intended (especially on non-CPython runtimes). Use a context manager to deterministically close the scandir handle once the entries are consumed.
    for entry in sorted(os.scandir(AITER_TRITON_CONFIGS_PATH), key=lambda e: e.name):

brunomazzottiamd

This comment was marked as outdated.

@brunomazzottiamd brunomazzottiamd left a comment

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.

I have a small change request: please guarantee that fallback arch is present in the config table after loading it.

Comment thread aiter/ops/triton/attention/fav3_sage.py Resolved
get_sage_fwd_configs() reads

    _SAGE_FWD_TABLES.get(arch_info.get_arch(), _SAGE_FWD_TABLES[_FALLBACK_ARCH])

and dict.get() evaluates its default eagerly, so the gfx942 lookup runs on
every call whether or not the fallback is needed. A missing gfx942 table would
therefore raise KeyError on every architecture, including the ones that ship a
tuned table of their own, and it would surface deep inside a launch rather than
where the file is actually absent.

Assert the invariant in _load_sage_fwd_tables() instead, naming the path that
is missing. Two arches ship a table today, gfx942 and gfx950, so the assert
holds; removing the gfx942 file makes it fire at import with that path in the
message.

Reported by @brunomazzottiamd in review.
Copilot AI review requested due to automatic review settings September 2, 2026 02:54

Copilot AI left a comment

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.

🟡 Changes recommended

The new config-loading path has avoidable import-time exception overhead and relies on an assert plus a potentially non-optional "fwd_a3_tuned" key access that can lead to harder-to-diagnose runtime failures.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

aiter/ops/triton/attention/fav3_sage.py:96

  • get_sage_fwd_configs(a3_tuned=True) assumes every per-arch table contains "fwd_a3_tuned"; if an arch later adds a minimal table without that key, this will raise KeyError even though the docstring describes it as optional. Use a default empty dict (or guard) so a3_tuned remains optional.
    aiter/ops/triton/attention/fav3_sage.py:52
  • _load_sage_fwd_tables() probes every arch directory via load_config_json(..., required=False). In this repo only gfx942/gfx950 ship the file, so the other probes trigger FileNotFoundError exceptions at import time, which is unnecessarily expensive and can slow module import.
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread aiter/ops/triton/attention/fav3_sage.py Resolved

@brunomazzottiamd brunomazzottiamd left a comment

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.

LGTM!

Copilot AI review requested due to automatic review settings September 2, 2026 14:03

Copilot AI left a comment

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.

🟡 Changes recommended

The new import-time config loader uses assert for a required runtime invariant (bypassable under -O) and should close os.scandir() via a context manager to avoid leaking a file descriptor.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

aiter/ops/triton/attention/fav3_sage.py:50

  • os.scandir() returns an iterator that should be closed; wrapping it in a context manager avoids leaking a file descriptor during module import.
    for entry in sorted(os.scandir(AITER_TRITON_CONFIGS_PATH), key=lambda e: e.name):
        if not entry.is_dir():
            continue
        cfg_dir = resolve_config_dir(
            "attention", _CONFIG_NAME, backend="triton", arch=entry.name
        )
        table = load_config_json(f"{cfg_dir}/DEFAULT.json", required=False)

aiter/ops/triton/attention/fav3_sage.py:63

  • Using assert to enforce the presence of the fallback config can be bypassed when Python is run with optimizations (-O), which would defer the failure to a later KeyError and make it harder to diagnose. Prefer an explicit runtime check that raises a deterministic exception naming the missing file.
    assert _FALLBACK_ARCH in tables, (
        f"no {_CONFIG_NAME} table for the fallback architecture "
        f"{_FALLBACK_ARCH!r}: expected "
        f"{resolve_config_dir('attention', _CONFIG_NAME, backend='triton', arch=_FALLBACK_ARCH)}"
        "/DEFAULT.json"
    )
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread aiter/ops/triton/attention/fav3_sage.py Resolved
@Boss2002n
Boss2002n merged commit 7b64611 into main Sep 2, 2026
69 of 72 checks passed
@Boss2002n
Boss2002n deleted the satya/triton-sage-config-to-json branch September 2, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants