Skip to content

More types for MPSGraph reduction/scan/sort support#863

Merged
maleadt merged 9 commits into
mainfrom
moretypes
Jun 30, 2026
Merged

More types for MPSGraph reduction/scan/sort support#863
maleadt merged 9 commits into
mainfrom
moretypes

Conversation

@christiangnrd

@christiangnrd christiangnrd commented Jun 23, 2026

Copy link
Copy Markdown
Member

Funny enough I tried to add & and | reductions but Base is broken for those until JuliaLang/julia#58418

Comment thread lib/mpsgraphs/scan.jl
Comment on lines +47 to +48
scan_operation(::Type{<:Integer}, ::typeof(min)) = :minimum
scan_operation(::Type{<:Integer}, ::typeof(max)) = :maximum

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had removed these because of incompatible NaN propagation, but you're right that it should work for integers.

@christiangnrd

christiangnrd commented Jun 23, 2026

Copy link
Copy Markdown
Member Author

Edit: I've decided Bool for scans and reductions is future work for someone who thinks they would benefit from it
A few quirks I'm probably overthinking:
- I don't include Bool for scan when it's technically supported and does something for min/max
- bitwise and and or reductions are broken in Base so I didn't add them butmaybe I should?
- Properly encoding support for types/operations will become a mess of lists/unions. Is it worth it?

@github-actions github-actions 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.

Metal Benchmarks

Details
Benchmark suite Current: 0477d5a Previous: 59e377f Ratio
array/accumulate/Float32/1d 521209 ns 573625 ns 0.91
array/accumulate/Float32/dims=1 492084 ns 571125 ns 0.86
array/accumulate/Float32/dims=1L 8949000 ns 8850292 ns 1.01
array/accumulate/Float32/dims=2 535041 ns 625125 ns 0.86
array/accumulate/Float32/dims=2L 2909729 ns 3358312 ns 0.87
array/accumulate/Int64/1d 930167 ns 894208 ns 1.04
array/accumulate/Int64/dims=1 1111333 ns 1095792 ns 1.01
array/accumulate/Int64/dims=1L 9806146 ns 9580896 ns 1.02
array/accumulate/Int64/dims=2 1466708 ns 1462208 ns 1.00
array/accumulate/Int64/dims=2L 6958729 ns 6584667 ns 1.06
array/broadcast 335750 ns 364209 ns 0.92
array/construct 3292 ns 3334 ns 0.99
array/permutedims/2d 613167 ns 633458 ns 0.97
array/permutedims/3d 1098209 ns 1098354 ns 1.00
array/permutedims/4d 1238750 ns 1590750.5 ns 0.78
array/private/copy 386625.5 ns 407917 ns 0.95
array/private/copyto!/cpu_to_gpu 367000 ns 382125 ns 0.96
array/private/copyto!/gpu_to_cpu 354208 ns 377459 ns 0.94
array/private/copyto!/gpu_to_gpu 325000 ns 357750 ns 0.91
array/private/iteration/findall/bool 1190709 ns 1140208 ns 1.04
array/private/iteration/findall/int 1321687.5 ns 1280458 ns 1.03
array/private/iteration/findfirst/bool 1326770.5 ns 1428334 ns 0.93
array/private/iteration/findfirst/int 1379270.5 ns 1466499.5 ns 0.94
array/private/iteration/findmin/1d 1520459 ns 1567125 ns 0.97
array/private/iteration/findmin/2d 1228771 ns 1270709 ns 0.97
array/private/iteration/logical 1984687.5 ns 1933750 ns 1.03
array/private/iteration/scalar 1752645.5 ns 2445416 ns 0.72
array/random/rand/Float32 599750 ns 616666 ns 0.97
array/random/rand/Int64 641333 ns 629708 ns 1.02
array/random/rand!/Float32 497916 ns 530625 ns 0.94
array/random/rand!/Int64 470875 ns 495291.5 ns 0.95
array/random/randn/Float32 557208 ns 570667 ns 0.98
array/random/randn!/Float32 453083 ns 477000 ns 0.95
array/reductions/mapreduce/Float32/1d 622542 ns 715520.5 ns 0.87
array/reductions/mapreduce/Float32/dims=1 448459 ns 492000 ns 0.91
array/reductions/mapreduce/Float32/dims=1L 700792 ns 689083 ns 1.02
array/reductions/mapreduce/Float32/dims=2 452250 ns 494792 ns 0.91
array/reductions/mapreduce/Float32/dims=2L 1005479.5 ns 1335459 ns 0.75
array/reductions/mapreduce/Int64/1d 800875 ns 943459 ns 0.85
array/reductions/mapreduce/Int64/dims=1 742750 ns 812625 ns 0.91
array/reductions/mapreduce/Int64/dims=1L 1101458 ns 1075667 ns 1.02
array/reductions/mapreduce/Int64/dims=2 826499.5 ns 987541 ns 0.84
array/reductions/mapreduce/Int64/dims=2L 2212833 ns 2168458 ns 1.02
array/reductions/reduce/Float32/1d 618167 ns 693083 ns 0.89
array/reductions/reduce/Float32/dims=1 451979 ns 496312.5 ns 0.91
array/reductions/reduce/Float32/dims=1L 704520.5 ns 687979.5 ns 1.02
array/reductions/reduce/Float32/dims=2 362458 ns 395834 ns 0.92
array/reductions/reduce/Float32/dims=2L 497583 ns 485542 ns 1.02
array/reductions/reduce/Int64/1d 804292 ns 962083 ns 0.84
array/reductions/reduce/Int64/dims=1 736437 ns 814541.5 ns 0.90
array/reductions/reduce/Int64/dims=1L 1098583 ns 1069500 ns 1.03
array/reductions/reduce/Int64/dims=2 292875 ns 973542 ns 0.30
array/reductions/reduce/Int64/dims=2L 687917 ns 2149542 ns 0.32
array/shared/copy 162833.5 ns 154083 ns 1.06
array/shared/copyto!/cpu_to_gpu 40875 ns 40708 ns 1.00
array/shared/copyto!/gpu_to_cpu 40291 ns 41000 ns 0.98
array/shared/copyto!/gpu_to_gpu 40167 ns 41208 ns 0.97
array/shared/iteration/findall/bool 1199667 ns 1148500 ns 1.04
array/shared/iteration/findall/int 1329167 ns 1285750 ns 1.03
array/shared/iteration/findfirst/bool 1029208 ns 1119667 ns 0.92
array/shared/iteration/findfirst/int 1021375 ns 1207312.5 ns 0.85
array/shared/iteration/findmin/1d 1278750 ns 1317938 ns 0.97
array/shared/iteration/findmin/2d 1229416 ns 1269625 ns 0.97
array/shared/iteration/logical 1793937.5 ns 1709354 ns 1.05
array/shared/iteration/scalar 3598.875 ns 3614.625 ns 1.00
array/sorting/1d 2004750 ns
array/sorting/2d 8449750 ns
integration/byval/reference 1151417 ns 1141958 ns 1.01
integration/byval/slices=1 1152125 ns 1136875 ns 1.01
integration/byval/slices=2 2080542 ns 2055750 ns 1.01
integration/byval/slices=3 18090625 ns 8460958 ns 2.14
integration/metaldevrt 440666.5 ns 451500 ns 0.98
kernel/indexing 329083 ns 351792 ns 0.94
kernel/indexing_checked 488729.5 ns 534209 ns 0.91
kernel/launch 1995.9 ns 1975 ns 1.01
kernel/rand 493667 ns 528250 ns 0.93
latency/import 1815418000 ns 1791534292 ns 1.01
latency/precompile 40257051458.5 ns 39637308833.5 ns 1.02
latency/ttfp 2150084542 ns 2124080375 ns 1.01
metal/synchronization/context 525.8229166666666 ns 523.9637305699482 ns 1.00
metal/synchronization/stream 276.61290322580646 ns 277.5974025974026 ns 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.61905% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.69%. Comparing base (59e377f) to head (0477d5a).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lib/mpsgraphs/scan.jl 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #863      +/-   ##
==========================================
+ Coverage   86.25%   86.69%   +0.44%     
==========================================
  Files          76       76              
  Lines        5130     5142      +12     
==========================================
+ Hits         4425     4458      +33     
+ Misses        705      684      -21     

☔ 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.

@christiangnrd

Copy link
Copy Markdown
Member Author

3x regression for the array/accumulate/Int64/dims=1L benchmark. Other Int64 benchmarks seem to be the same or improved.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit b8d46ce into main Jun 30, 2026
19 checks passed
@maleadt maleadt deleted the moretypes branch June 30, 2026 14:10
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