Skip to content

feat(hip): add payload-driven shapes and bulk readback - #642

Draft
fhanuman wants to merge 1 commit into
pr/shape-stack-03b-loop-carriersfrom
pr/shape-stack-04-payload-readback
Draft

feat(hip): add payload-driven shapes and bulk readback#642
fhanuman wants to merge 1 commit into
pr/shape-stack-03b-loop-carriersfrom
pr/shape-stack-04-payload-readback

Conversation

@fhanuman

@fhanuman fhanuman commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add a payload-driven shape path for operations whose output dimensions depend on runtime tensor values.

  • introduce hip.readback_shape with bufferization, LLVM lowering, and real/mock runtime support for one synchronized vector readback;
  • use bulk readback to size Tile outputs from runtime repeats, including partially static results;
  • share constant/stamped Pad, Slice, Expand, Range, and Tile shape rules between converter construction and reification;
  • preserve Slice’s distinction between physical destination capacity and runtime logical extent;
  • use DPS-init shape fallback when payload values cannot be resolved statically;
  • consolidate constant extraction used by payload converters and pre-lowering folds.

The readback operation, bufferization model, lowering, runtime ABI, and payload consumers are included in the same layer.

Stack

This is PR 7 of 12 and depends on PR 6:

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

AI assistance

AI tools assisted with the payload-shape refactoring and stack reconstruction. The changes were checked with the authoritative local build, focused payload LIT, and GPU-vs-CPU shape-operation 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: 3875 - Commit: 1c67817

@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: 3875 - Commit: 1c67817

@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from 9f56d5d to f2da195 Compare August 5, 2026 21:56
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from f2da195 to 45180d4 Compare August 6, 2026 21:00
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from 45180d4 to 6d2e2a1 Compare August 7, 2026 19:51
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from 6d2e2a1 to d729eba Compare August 7, 2026 20:25
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from d729eba to 9f4631e Compare August 10, 2026 21:59
@fhanuman
fhanuman changed the base branch from pr/shape-stack-03-broadcast-reduction to pr/shape-stack-03b-loop-carriers August 10, 2026 22:02
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch 2 times, most recently from 2d81f1c to 1c67817 Compare August 10, 2026 23:33
Keep payload-derived destinations exact across conversion and reification, consume visible constant carriers directly, and batch runtime integer controls into host SSA before allocation and dispatch.

Co-Authored-By: GPT-5.6 Sol <noreply@openai.com>
Made-with: Cursor
@fhanuman
fhanuman force-pushed the pr/shape-stack-04-payload-readback branch from 1c67817 to b2ad556 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