Skip to content

Guard unsupported layouts in unary operator dispatch - #5742

Open
UD-mmcminn wants to merge 1 commit into
ROCm:mainfrom
UD-mmcminn:fix-unary-layout-dispatch
Open

UD-mmcminn wants to merge 1 commit into
ROCm:mainfrom
UD-mmcminn:fix-unary-layout-dispatch

Conversation

@UD-mmcminn

Copy link
Copy Markdown

Summary

  • Restrict the native sigmoid/tanh tile path to supported CUDA tensors:
    • FP16, BF16, or FP32
    • contiguous 2-D or 3-D layouts
    • non-empty tensors
    • compatible tile dimensions
  • Route unsupported tensors through the corresponding PyTorch operation.
  • Replace the profiler-only unary test with deterministic native and fallback correctness coverage.
  • Cover CPU tensors, unsupported dtypes, empty tensors, noncontiguous layouts, rank mismatches, and vector tails.

Motivation

The native unary dispatcher assumed a contiguous 2-D or 3-D supported tensor. Other inputs could access nonexistent dimensions or dispatch an unsupported native kernel instead of using the existing fallback.

This is a general correctness fix and is not specific to gfx908.

Testing

Tested on AMD Instinct MI100 (gfx908):

AITER_REBUILD=1 python op_tests/test_aiter_sigmoid.py \
  -d bf16 fp16 fp32 \
  --op sigmoid tanh \
  --mode all

48 passed, 0 failed

@UD-mmcminn
UD-mmcminn requested a review from a team September 22, 2026 01:30
@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 5742 --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.

@github-actions github-actions Bot changed the title [HIP] Guard unsupported layouts in unary operator dispatch Guard unsupported layouts in unary operator dispatch Sep 22, 2026
@zufayu
zufayu requested a review from junhaha666 September 23, 2026 01:13
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Oct 9, 2026
@junhaha666

Copy link
Copy Markdown
Contributor

@aiter-bot review

@aiter-bot

Copy link
Copy Markdown

aiter-bot — queued behind 1 review(s); expect to start in about 50 min. The box reviews one PR at a time.

@aiter-bot

Copy link
Copy Markdown

[ROCm/aiter] PR #5742 — Guard unsupported layouts in unary operator dispatch

Restricts aiter.sigmoid/aiter.tanh's native tile kernel to contiguous, non-empty 2-D/3-D fp16/bf16/fp32 CUDA tensors (routing everything else to the torch op) and replaces the profiler-based test with a routing-plus-correctness test.

Review (advisory): ⚠️ NEEDS WORK
Validation (deterministic): NOT RUN — REVIEW_AUTO_VALIDATE=0 (auto-validation disabled) and no python environment with torch exists on this box to run op_tests/test_aiter_sigmoid.py by hand; environment gap, not a PR defect
Perf (advisory): NOT RUN — no python environment with torch on this box to execute the target (all 8 GPUs at 98–99% VRAM); environment gap, not a PR defect

📝 [verified] op_tests/test_aiter_sigmoid.py defaults to --dtype bf16, and both CI entry points run it with no arguments (.github/workflows/test-whl.yaml:168 and .github/scripts/aiter_test.sh:91), so the fp16 and fp32 native tile instantiations (vec=8 vs vec=4 template variants) are exercised only by the author's gfx908 (MI100) run — an arch outside aiter's CI matrix — leaving the fp32 vec=4 path untested on every arch aiter ships for. Reviewer should ask for a gfx942/gfx950 run with -d fp16 fp32, or a CI default that sweeps all three dtypes.
📝 [inferred] The rewrite deletes the profiler-based script, so sigmoid/tanh is left with no in-tree timing harness while every call now runs four extra Python attribute checks (device.type, dtype, dim, numel) before the existing contiguity check in aiter/ops/aiter_operator.py:198-204 — if host dispatch dominates at small shapes, could this add measurable per-call latency that no harness would catch? Reviewer should ask for a base-vs-head spot timing on a small supported shape (e.g. (8, 4096) fp16).

@junhaha666 junhaha666 added HIP and removed stale The PR hasn't been updated in 2 weeks labels Oct 23, 2026
@github-actions github-actions Bot removed the HIP label Oct 23, 2026
expected = torch_op(x)
actual = aiter_op(x)
tolerance = 1e-2 if dtype in (torch.float16, torch.bfloat16) else 1e-4
torch.testing.assert_close(

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.

Please uniformly use "checkAllclose"

choices=("all", "native", "fallback"),
default="all",
)
args = parser.parse_args()

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.

The shape/stride cannot be specified through the command line.

f"noncontiguous={case.noncontiguous}: expected native={case.native}, got {native}"
)

expected = torch_op(x)

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.

The performance test has been removed.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

No activity for 15 days, so this is now labelled stale. A push or a comment clears it; keep-open exempts it. Nothing is closed automatically.

@github-actions github-actions Bot added the stale The PR hasn't been updated in 2 weeks label Nov 8, 2026
@aiter-bot

Copy link
Copy Markdown

WAITING ON AUTHOR

PR Self-Review

Revision 875b96c9d6dc · mode shadow

Waiting for the PR author. The readiness report will appear after the self-review answers are complete for this revision.

Questions to answer in the PR description

  1. What behavior does this PR change, and why is the existing behavior insufficient?
  2. What did you validate, and what remains unverified? Include commands, hardware/configuration and results.
  3. What behavior would each changed op test fail on before this PR, and why is that coverage not already provided by an existing canonical test?
  4. For every changed op_tests/ file, what behavior does it cover and why is it not redundant? Write None if no op test changed.

Edit the PR Self-Review section in the PR description. Include the current revision SHA; this comment refreshes automatically.

Missing or invalid answers

  • FAIL — missing ### Reviewed revision in the PR description
  • FAIL — missing ### Behavior and intent in the PR description
  • FAIL — missing ### Validation and unverified scope in the PR description
  • FAIL — missing ### PR-specific question in the PR description
  • FAIL — missing ### Changed op tests in the PR description
  • FAIL — Reviewed revision must contain at least the first 7 characters of the current head SHA
  • FAIL — Behavior and intent has no substantive answer
  • FAIL — Validation and unverified scope has no substantive answer
  • FAIL — PR-specific question has no substantive answer
  • FAIL — changed op test not explained in Changed op tests: op_tests/test_aiter_sigmoid.py
  • FAIL — Changed op tests must explain why each changed op test is necessary and non-redundant

Shadow mode reports what would block but keeps the status successful. Set AITER_PR_SELF_REVIEW_MODE=enforce only after reviewing real false positives.

@github-actions github-actions Bot removed the stale The PR hasn't been updated in 2 weeks label Nov 23, 2026

This branch has not been deployed

No deployments
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.

3 participants