Skip to content

feat(tune): record untuned shapes for every GEMM family, not just bf16 - #5268

Open
ThomasNing wants to merge 7 commits into
ROCm:mainfrom
ThomasNing:thomas/untuned-shape-logging-all-families
Open

feat(tune): record untuned shapes for every GEMM family, not just bf16#5268
ThomasNing wants to merge 7 commits into
ROCm:mainfrom
ThomasNing:thomas/untuned-shape-logging-all-families

Conversation

@ThomasNing

Copy link
Copy Markdown
Contributor

Fixes #5267.

Why

AITER_TUNE_GEMM=1 makes tuned_gemm.py append every missed bf16 shape to bf16_untuned_gemm.csv. That single feature is why tuning a real bf16 deployment is self-service: run the server, collect the CSV, hand it straight back to the tuner.

The fp8 per-token, block-scale and mxfp4 families have no equivalent — they log misses at INFO and write nothing — so their shape lists have to be scraped out of server logs by hand. That is also how shape-key mistakes creep in: we shipped a tuned table that never matched anything because the engine fuses two projections and dispatches N=2688, while the tuned rows targeted the unfused N=2624. A recorded shape list makes that impossible to miss.

What

aiter/utility/untuned_shapes.pyrecord(tuned_file, row) appends one de-duplicated row in the schema that family's tuner consumes. The destination name is derived from the tuned table's own name (*_tuned_**_untuned_*), so a family never has to name its untuned file twice, and a merged /tmp/aiter_configs copy still resolves to the right destination.

Wired into the miss paths of:

  • gemm_op_a8w8.get_CKGEMM_config (block-scale, ± preshuffle) → M,N,K
  • gemm_op_a8w8.get_GEMM_config_with_quant_type (a8w8, a8w8_bpreshuffle) → M,N,K,q_dtype_w
  • gemm_op_a4w4.get_GEMM_configM,N,K

Behaviour

  • Same switch as before (AITER_TUNE_GEMM=1) — nothing new to learn; off by default.
  • AITER_TUNE_GEMM_DIR overrides the destination, for read-only package directories and containers (we had to copy the file out of a container image more than once).
  • Hot path cost after a shape has been seen is one set lookup; a serving run repeats its shapes, so the append happens a handful of times.
  • Never raises. A read-only configs dir or a full disk must not take down inference — it logs a warning and moves on.

Checked

Name derivation (including the merged-copy path), per-family schemas, de-duplication across repeats, disabled-by-default, and graceful degradation on an unwritable destination.

Same campaign as #5262 / #5263#5266.

🤖 Generated with Claude Code

AITER_TUNE_GEMM=1 makes tuned_gemm.py append each missed bf16 shape to
bf16_untuned_gemm.csv, which is why tuning a real bf16 deployment is
self-service: run the server, collect the CSV, hand it straight back to the
tuner. The fp8 per-token, block-scale and mxfp4 families log their misses to
INFO and write nothing, so their shape lists have to be scraped out of server
logs by hand -- which is also how shape-key mistakes creep in. We shipped a
tuned table that never matched because the engine fuses two projections and
dispatches N=2688 while the tuned rows target the unfused N=2624; a recorded
shape list would have made that impossible to miss.

Adds aiter/utility/untuned_shapes.py: record(tuned_file, row) appends one
de-duplicated row in the schema that family's tuner consumes. The destination
name is derived from the tuned table's own name (*_tuned_* -> *_untuned_*), so
a family never names its untuned file twice and a merged /tmp/aiter_configs
copy still resolves to the right one. Wired into the miss paths of
get_CKGEMM_config, get_GEMM_config_with_quant_type (a8w8 / a8w8_bpreshuffle /
blockscale) and gemm_op_a4w4.get_GEMM_config.

Same switch as before (AITER_TUNE_GEMM=1) so there is nothing new to learn;
AITER_TUNE_GEMM_DIR overrides the destination for read-only package dirs and
containers. Off by default. A set lookup on the hot path once a shape has been
seen, and it never raises -- telemetry must not take down inference.

Checked: name derivation incl. the merged-copy path, per-family schemas,
de-duplication across repeats, disabled-by-default, and graceful degradation
on an unwritable destination.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ThomasNing
ThomasNing requested a review from a team September 3, 2026 23:53
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-04T11:00:33.500518Z ce9845c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Sep 3, 2026

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 5268 --add-label <label>

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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5302edfe19

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/utility/untuned_shapes.py Outdated
Comment thread aiter/utility/untuned_shapes.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dc6d068e0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/ops/gemm_op_a8w8.py
Comment thread aiter/utility/untuned_shapes.py Outdated
Comment thread aiter/utility/untuned_shapes.py
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1b1688c5da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/ops/gemm_op_a8w8.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f906b11165

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/ops/gemm_op_a8w8.py Outdated
Comment thread aiter/utility/untuned_shapes.py Outdated
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 18285a371c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread aiter/ops/gemm_op_a8w8.py Outdated
Comment thread aiter/ops/gemm_op_a8w8.py
@ThomasNing

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: ce9845c0ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ThomasNing

ThomasNing commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Review is clean and all threads are resolved on ce9845c0e. The remaining CI entries are fork-workflow approvals, not executed test failures. Maintainer: please approve the Checks run and Aiter Test run.

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@yzhou103 Could you take a look?

@yzhou103

Copy link
Copy Markdown
Contributor

consider process-local de-duplication followed by append-only writes. The tuners already call drop_duplicates(), so re-reading the entire CSV under an interprocess lock for every new shape is unnecessary, scales roughly quadratically, and may introduce blocking file I/O in CUDA/HIP Graph capture paths. Per-worker output shards followed by an offline merge would avoid the interprocess lock entirely.

@yzhou103

Copy link
Copy Markdown
Contributor

maybe it is better to save the untuned csv like:
/tuning/glm-5.2/
├── a8w8_untuned_gemm.csv
├── a8w8_bpreshuffle_untuned_gemm.csv
├── a8w8_blockscale_untuned_gemm.csv
└── a4w4_blockscale_untuned_gemm.csv

@ThomasNing

Copy link
Copy Markdown
Contributor Author

@yzhou103 Addressed both comments in 6c648e4:

  • Recording now uses process-local de-duplication and one O_APPEND system write per new row. It no longer takes an interprocess lock, rereads the CSV body, truncates, or rewrites prior data. Cross-worker duplicates are intentionally left for the tuners existing drop_duplicates() step.
  • AITER_TUNE_GEMM_DIR=/tuning/glm-5.2 produces the requested model-specific layout with a8w8_untuned_gemm.csv, a8w8_bpreshuffle_untuned_gemm.csv, a8w8_blockscale_untuned_gemm.csv, and a4w4_blockscale_untuned_gemm.csv. The recorder docs and regression tests now show this layout.

The header is validated only once per process and is published atomically for concurrent workers. Added coverage for local de-duplication, single-write append behavior, concurrent complete rows, retry behavior, and model-directory routing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Untuned-shape logging exists only for bf16 (AITER_TUNE_GEMM); fp8/blockscale/a4w4 have none

2 participants