Skip to content

fix(hip): share Gather and tensor-shape contracts - #644

Draft
fhanuman wants to merge 1 commit into
pr/shape-stack-05-conv-poolfrom
pr/shape-stack-06-gather-tensor
Draft

fix(hip): share Gather and tensor-shape contracts#644
fhanuman wants to merge 1 commit into
pr/shape-stack-05-conv-poolfrom
pr/shape-stack-06-gather-tensor

Conversation

@fhanuman

@fhanuman fhanuman commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Unify result-shape construction, reification, and static verification for Gather-family and tensor-shape operations.

  • share Gather and GatherND dimension-splicing rules across converters, reifiers, and verifiers;
  • define GatherElements output shape from its indices operand through the named same-shape contract;
  • validate Transpose permutations through one shared rule before materializing dimensions;
  • define Resize output N/C from the input and static spatial extents from the imported result template;
  • define Size as a rank-zero i64 result through a shared semantic rule;
  • compute GatherBlockQuantized output shapes from the logical dequantized tensor rather than physical packed-byte storage;
  • account for packed int4 by doubling a surviving quantize-axis extent and keep the converter, lowering, runtime interpretation, and tests in the same layer.

GatherND retains its DPS-init fallback when the runtime tuple width prevents static output-rank inference.

Stack

This is PR 9 of 12 and depends on PR 8:

1. Constant carrier/externalization
2. Shape-rule foundation
3. Reshape provenance
4. MatMul/Gemm
5. Broadcast/Reduction
6. Loop carriers
7. Payload/Readback
8. Conv/Pool
9. Gather/Tensor ← this PR
10. Attention/Normalization
11. Explicit contract enforcement
12. Refinement hardening

AI assistance

AI tools assisted with the shape-contract refactoring and stack reconstruction. The changes were checked with the local build, focused Gather/Transpose/Resize/Size LIT, and targeted GPU-vs-CPU tests.

Made with Cursor

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

Thanks for opening a PR!

This project follows LLVM's incremental-development and AI-tool-use
guidance. See CONTRIBUTING.md
for the project workflow.

Before requesting review, please check that:

  1. The change is focused. Substantial work links the relevant issue
    or design discussion.
  2. The PR documents relevant test results and updates affected
    documentation.
  3. If AI tools provided substantial assistance, the description
    explains what was assisted and how it was validated, and commit
    trailers identify the tool. The contributor has reviewed and
    understands the result.

Reviewers are assigned through
CODEOWNERS where ownership
is configured.

@github-actions github-actions Bot added the large-pr Soft size threshold (>500 LOC or >10 files). Reviewer signal, not a block. label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

L2 Accuracy Results (EP vs CPU)

Model Combined L2 Total Elems Skipped NaN/Inf
conv_test_hybrid EP inference failed - -
GroupQueryAttention_seq256 EP inference failed - -
MatMulNBits_o_seq128 EP inference failed - -
QMoE_seq128 EP inference failed - -

Threshold: 0.01 | Run: 3893 - Commit: 9dd4ecb

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown

MorphiZen EP Performance Results

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 failed - - - -
GroupQueryAttention_seq128 failed - - - -
matmul_down_seq128 failed - - - -

EPContext Export Performance

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 failed - - - -

OGA Benchmark Results

Model Warmup Reps Prompt Len Gen Tokens TTFT (ms) TPS Peak Mem (GB) GPU Mem (GB)
gpt-oss-20b-webgpu-int4-rtn-block-32 1 5 128 128 - - - 0.00
Llama-3.1-8B-awq-g128-int4-asym-fp16-onnx-dml 1 5 128 128 - - - 0.00

OGA Wheel Smoke (Python benchmark_e2e.py)

Model TTFT (ms) TPS
Llama-3.1-8B-awq-g128-int4-asym-fp16-onnx-dml failed -

Run: 3893 - Commit: 9dd4ecb

@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from deb0a3f to 8db3876 Compare August 5, 2026 21:56
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from 8db3876 to 9f06ab6 Compare August 6, 2026 21:00
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from 9f06ab6 to 0858247 Compare August 7, 2026 19:51
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch 2 times, most recently from a0455ce to e337608 Compare August 10, 2026 21:59
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from e337608 to af6a5a5 Compare August 10, 2026 22:29
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from af6a5a5 to 2cb9720 Compare August 10, 2026 23:33
Unify Gather-family and tensor-shape contracts across conversion, reification, and verification while enforcing the runtime-supported i64 GatherND index ABI.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
Made-with: Cursor
@fhanuman
fhanuman force-pushed the pr/shape-stack-06-gather-tensor branch from 2cb9720 to 9dd4ecb Compare August 11, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

large-pr Soft size threshold (>500 LOC or >10 files). Reviewer signal, not a block.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant