Skip to content

feat(vpto): add A2/A3 gather lowering#971

Open
castigli wants to merge 4 commits into
hw-native-sys:mainfrom
castigli:feature/a2a3-tgather-mgather-vpto
Open

feat(vpto): add A2/A3 gather lowering#971
castigli wants to merge 4 commits into
hw-native-sys:mainfrom
castigli:feature/a2a3-tgather-mgather-vpto

Conversation

@castigli

@castigli castigli commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add A2/A3 VPTO lowering for pto.tgatherb through pto.ub.vgatherb to packed llvm.hivm.VGATHERB.b16/.b32 calls.
  • Lower pto.tgather index form through vmuls + vgather, preserving count-mode mask lifetime and chunking wide rows.
  • Model A2/A3 tgatherb as a 32-byte block gather with one compact i32 block address per output block, padded to eight entries per repeat.
  • Add UB op verification/effects, synchronization modeling, design notes, lit coverage, and NPU e2e tests.
  • Build on the generic PTODSL/A5 tgatherb support merged in Add TGATHERB #932 without duplicating its wrapper or namespace registration.

Notes

  • tgatherb is a 32-byte block gather, not scalar element gather.
  • Scalar arbitrary-element gather is handled by the tgather index form and vgather.
  • A2/A3 mgather is supported by PTO-ISA/EmitC; GM-to-UB VPTO lowering is intentionally split into a stacked follow-up because it requires scalar index/OOB handling and MTE2 decomposition.

Validation

  • Hardened Docker ptoas build: passed.
  • Gather-filter lit tests: 40 passed, including all 11 PR-specific gather tests.
  • 910B2 NPU e2e on devices 2 and 3: 15 passed.

Covered NPU shapes:

  • tgatherb f32: 1x8, 1x64, 1x96, 2x64, 1x128, 4x64
  • tgatherb f16: 1x16, 1x128, 1x192
  • scalar tgather f32/f16: 1x64, 2x64, 2x128

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request implements tile-level gather lowering (pto.tgather and pto.tgatherb) for the A2/A3 vpto backend, introducing new flat UB-pointer gather ops (pto.ub.vgather and pto.ub.vgatherb) and their lowerings to LLVM intrinsics with packed config words. It also adds synchronization macro models, extensive end-to-end tests, and lit verification tests. The review feedback suggests several improvements: emitting a compilation error instead of silently skipping lowering when srcAddr cannot be resolved, using safer defensive checks for validCol, explicitly casting mixed signed/unsigned types to prevent compiler warnings, and using castOp->getOperand(0) to avoid potential C++ name hiding issues.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lib/PTO/Transforms/LowerPTOToUBufOps.cpp Outdated
Comment thread lib/PTO/Transforms/LowerPTOToUBufOps.cpp
Comment thread lib/PTO/Transforms/LowerPTOToUBufOps.cpp
Comment thread lib/PTO/Transforms/VPTOLLVMEmitter.cpp
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.

1 participant