Skip to content

fix(shape): canonicalize host reshape provenance - #681

Draft
fhanuman wants to merge 1 commit into
pr/shape-stack-01-foundationfrom
pr/shape-stack-01b-reshape-provenance
Draft

fix(shape): canonicalize host reshape provenance#681
fhanuman wants to merge 1 commit into
pr/shape-stack-01-foundationfrom
pr/shape-stack-01b-reshape-provenance

Conversation

@fhanuman

@fhanuman fhanuman commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Canonicalize host-derived ONNX Reshape targets so descriptor dimensions remain host SSA instead of requiring synchronized payload readbacks.

  • analyze supported shape-producing SSA once per function;
  • materialize only complete conservative proofs while preserving synchronized fallback;
  • harden allowzero, -1, index-width, CFG, and malformed-IR handling.

Stack

This is PR 3 of 12 and depends on PR 2:

1. Constant carrier/externalization
2. Shape-rule foundation
3. Reshape provenance ← this PR
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
12. Refinement hardening

AI assistance

AI tools assisted with the shape-provenance implementation and stack reconstruction. The changes were checked with the authoritative local build, focused LIT, and a strict GPU-vs-CPU Reshape provenance test.

Made with Cursor

@github-actions

github-actions Bot commented Aug 7, 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 7, 2026
@github-actions

github-actions Bot commented Aug 8, 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: 3891 - Commit: 1fb8b3e

@github-actions

github-actions Bot commented Aug 8, 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.36 359 3 1243
GroupQueryAttention_seq128 4381.27 1.74488 12 6 312
matmul_down_seq128 527.41 2.39 75 3 354

EPContext Export Performance

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 7.58 44.92 356 3 15589

EPContext Import Performance

Model QPS Session (s) 1st Infer (ms) CPU% Mem (MB)
full_model_seq128 7.56 9.59 361 3 15760

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 146.1 79.9 1.33 13.53
Llama-3.1-8B-awq-g128-int4-asym-fp16-onnx-dml 1 5 128 128 205.4 40.1 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 215 39.5

Run: 3891 - Commit: 1fb8b3e

@fhanuman
fhanuman force-pushed the pr/shape-stack-01b-reshape-provenance branch 2 times, most recently from 064ea8d to b304218 Compare August 10, 2026 22:29
@fhanuman
fhanuman force-pushed the pr/shape-stack-01b-reshape-provenance branch from b304218 to 6801e55 Compare August 10, 2026 23:33
Analyze generic ONNX shape SSA once per function so proven Reshape targets reuse canonical host dimensions instead of synchronized payload readbacks and fragmented pools. Preserve conservative fallback and harden allowzero, minus-one, index, and control-flow edge cases.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
Made-with: Cursor
@fhanuman
fhanuman force-pushed the pr/shape-stack-01b-reshape-provenance branch from 6801e55 to 1fb8b3e 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