Skip to content

Numba: combine n-ary Add/Mul terms pairwise - #2363

Draft
velochy wants to merge 1 commit into
pymc-devs:mainfrom
velochy:pairwise-add
Draft

Numba: combine n-ary Add/Mul terms pairwise#2363
velochy wants to merge 1 commit into
pymc-devs:mainfrom
velochy:pairwise-add

Conversation

@velochy

@velochy velochy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

The numba dispatch for n-ary scalar Add/Mul emitted one flat left-to-right chain (x0 + x1 + ... + xn). Combining terms pairwise instead gives log-depth dependency chains and pairwise-summation float accuracy, at identical cost — as suggested in review of #2354.

Log-depth dependency chains and pairwise-summation accuracy instead of
one flat left-to-right chain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ricardoV94

Copy link
Copy Markdown
Member

Does this still shows compile cost benefits beyond #2354 ?

@velochy

velochy commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Measured: no compile benefit beyond #2354. Interleaved A/B/A/B at n=80 on top of #2354+#2361, cold caches: flat 354/361 s vs pairwise 361/322 s, RSS identical — pure noise. The flat chain was already linear to compile; this PR's value is only pairwise-summation float accuracy and log-depth dependency chains, per your suggestion on #2354. If that alone doesn't justify it, happy to close.

@ricardoV94

Copy link
Copy Markdown
Member

Let's leave it open, just no rush to merge

@ricardoV94
ricardoV94 marked this pull request as draft August 20, 2026 13:38
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.

2 participants