Skip to content

refactor(hip): enforce explicit DPS shape contracts locally - #646

Draft
fhanuman wants to merge 1 commit into
pr/shape-stack-07-attention-normfrom
pr/shape-stack-08-contract-enforcement
Draft

refactor(hip): enforce explicit DPS shape contracts locally#646
fhanuman wants to merge 1 commit into
pr/shape-stack-07-attention-normfrom
pr/shape-stack-08-contract-enforcement

Conversation

@fhanuman

@fhanuman fhanuman commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Make shape-contract selection explicit for every HIP destination-style operation and enforce the contract during the default local LIT build.

  • classify every DPS operation as same-shape, broadcast, reduction, semantic, payload-dependent, or outs-authoritative;
  • migrate remaining unary, activation, scatter, RMSNorm, Rope, QMoE, and related operations to named-source same-shape contracts;
  • generate shared infer/reify/verify wiring for mechanical contract families;
  • require semantic operations to provide verifier wiring and explicitly review any destination-lift reification fallback;
  • cross-check TableGen contract metadata against the shape-contract inventory;
  • recursively audit ONNX-to-HIP converter sources for new positional destination construction;
  • use counted allowlists so additional occurrences in reviewed exception files fail the local audit;
  • include negative self-tests for malformed contract metadata and converter bypasses.

The inventory and source audits are invoked through LIT, so they run as part of the normal local build rather than relying on external CI policy.

Stack

This is PR 11 of 12 and depends on PR 10:

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
10. Attention/Normalization
11. Explicit contract enforcement ← this PR
12. Refinement hardening

AI assistance

AI tools assisted with the TableGen migration, audit implementation, and stack reconstruction. The changes were checked with the local build, audit self-tests, inventory LIT, dedup LIT, and same-shape reification/verifier 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 4.8668E-07 64 0
GroupQueryAttention_seq256 25.2366 2621440 0
MatMulNBits_o_seq128 259.906 368640 0
QMoE_seq128 34.957 368640 0

Threshold: 0.01 | Run: 3962 - Commit: c457b04

@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 7.52 6.47 365 3 1243
GroupQueryAttention_seq128 4525.00 1.74895 12 6 313
matmul_down_seq128 524.67 2.49 71 3 355

EPContext Export Performance

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 7.59 44.36 358 3 15591

EPContext Import Performance

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 7.56 8.98 358 3 15758

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 167.0 79.8 1.33 13.53
Llama-3.1-8B-awq-g128-int4-asym-fp16-onnx-dml 1 5 128 128 236.3 40.0 1.22 6.43

OGA Wheel Smoke (Python benchmark_e2e.py)

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

Run: 3962 - Commit: c457b04

@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from b19a841 to de1b182 Compare August 5, 2026 21:56
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from de1b182 to 0d93191 Compare August 6, 2026 21:00
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch 2 times, most recently from 2d456e9 to dca7d46 Compare August 7, 2026 20:25
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from dca7d46 to 540b8bc Compare August 10, 2026 21:59
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch 2 times, most recently from b5e615c to b0eefad Compare August 10, 2026 23:33
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch 2 times, most recently from 69c423a to d386631 Compare August 11, 2026 13:29
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from d386631 to def7ddf Compare August 11, 2026 14:19
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from def7ddf to c457b04 Compare August 11, 2026 16:25
Make each remaining DPS leaf declare its reviewed shape source and keep converter destinations aligned, then lock the inventory and frontend dedup rules with executable audits.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
Made-with: Cursor
@fhanuman
fhanuman force-pushed the pr/shape-stack-08-contract-enforcement branch from c457b04 to af000bf Compare August 11, 2026 21:22
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