Skip to content

Test by-element sdot/udot codegen on ARM - #9544

Open
alexreinking wants to merge 1 commit into
mainfrom
alexreinking/arm-dot-by-element-test
Open

alexreinking wants to merge 1 commit into
mainfrom
alexreinking/arm-dot-by-element-test

Conversation

@alexreinking

Copy link
Copy Markdown
Member

Adds correctness_arm_dot_product_by_element, which locks in by-element sdot/udot codegen on ARM (sdot vD.4s, vN.16b, vM.4b[lane], the vdotq_laneq_s32 instruction).

The test compiles an 8-row gemv with weights interleaved 4 rows at a time in 4-byte groups, as in ggml's q4_0_4x4 and KleidiAI's dotprod kernels. It stages 16 activation bytes in a register and unrolls 4 groups.

It requires the by-element form on all four lanes, for sdot and udot, with the broadcast operand on either side of the multiply. On an AArch64 host with dotprod it also checks values against a scalar reference.

This relies on CodeGen_ARM moving the broadcast to the second operand of dot_product (since 8aa778c), which had no test. With that swap removed, the test fails (found 0 lanes).

Test-only; no compiler changes.

Validation on macOS arm64: ctest --test-dir build/macOS -R correctness_arm_dot_product_by_element passes, and fails with the swap removed.


Authored by GitHub Copilot

Lock in that a dot product against a 4-byte group broadcast from a
register-staged vector lowers to the by-element form
`sdot/udot vD.4s, vN.16b, vM.4b[lane]`, for either operand order. This
relies on CodeGen_ARM moving the broadcast to the second operand, which
had no test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexreinking

Copy link
Copy Markdown
Member Author

I'm adding this test because Copilot spent well over an hour discovering this recipe even after searching the repo for key terms.

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.05%. Comparing base (ee9f17a) to head (1db2602).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9544   +/-   ##
=======================================
  Coverage   71.05%   71.05%           
=======================================
  Files         262      262           
  Lines       81084    81084           
  Branches    19770    19770           
=======================================
+ Hits        57615    57618    +3     
+ Misses      17502    17488   -14     
- Partials     5967     5978   +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexreinking
alexreinking marked this pull request as ready for review October 10, 2026 12:07

This branch has not been deployed

No deployments
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