Skip to content

Instantly share code, notes, and snippets.

@betatim
Created September 1, 2026 11:22
Show Gist options
  • Select an option

  • Save betatim/431e258b5090b27ce0ebb3c0b4e0f099 to your computer and use it in GitHub Desktop.

Select an option

Save betatim/431e258b5090b27ce0ebb3c0b4e0f099 to your computer and use it in GitHub Desktop.
Always store attributes as numpy in scikit-learn GPU
numpy
as-is as numpy difference added
search 1.18s 1.18s -0.0% -164us
predict 24.2ms 19.1ms -20.9% -5.1ms
serve/call 897us 930us +3.7% 33us
score 10.4ms 10.9ms +4.8% 493us
one 10-row predict, step by step:
scale.transform 111us 135us +22.2% 24us
kernel.transform 572us 588us +2.8% 16us
clf.predict 206us 202us -2.2% -5us
predictions agree: yes
torch-cpu
as-is as numpy difference added
search 1.32s 1.33s +0.9% 11.4ms
predict 13.4ms 13.4ms +0.1% 8us
serve/call 1.0ms 1.2ms +12.4% 129us
score 7.8ms 8.2ms +4.7% 373us
one 10-row predict, step by step:
scale.transform 132us 183us +37.8% 50us
kernel.transform 622us 672us +8.1% 50us
clf.predict 252us 282us +11.9% 30us
predictions agree: yes
torch-cuda
as-is as numpy difference added
search 422.5ms 431.0ms +2.0% 8.5ms
predict 3.7ms 4.0ms +7.5% 280us
serve/call 1.3ms 1.6ms +18.0% 237us
score 3.3ms 3.5ms +7.7% 253us
one 10-row predict, step by step:
scale.transform 176us 250us +42.0% 74us
kernel.transform 817us 912us +11.6% 95us
clf.predict 308us 380us +23.4% 72us
predictions agree: yes
torch-mps
skipped: torch reports no MPS device
cupy
as-is as numpy difference added
search 591.1ms 602.8ms +2.0% 11.7ms
predict 4.3ms 4.6ms +8.2% 351us
serve/call 1.4ms 1.7ms +21.8% 309us
score 4.1ms 4.4ms +7.9% 324us
one 10-row predict, step by step:
scale.transform 185us 287us +55.0% 102us
kernel.transform 903us 1.0ms +12.4% 112us
clf.predict 319us 416us +30.4% 97us
predictions agree: yes
numpy
as-is as numpy difference added
search 1.20s 1.20s +0.4% 5.0ms
predict 23.0ms 19.9ms -13.5% -3.1ms
serve/call 886us 927us +4.6% 41us
score 11.3ms 11.0ms -2.6% -298us
one 10-row predict, step by step:
scale.transform 110us 137us +24.8% 27us
kernel.transform 560us 581us +3.8% 21us
clf.predict 204us 198us -2.9% -6us
predictions agree: yes
torch-cpu
as-is as numpy difference added
search 1.40s 1.41s +0.5% 6.4ms
predict 12.9ms 13.3ms +2.5% 325us
serve/call 1.0ms 1.2ms +13.0% 132us
score 7.9ms 8.5ms +7.7% 607us
one 10-row predict, step by step:
scale.transform 129us 180us +39.2% 51us
kernel.transform 614us 662us +7.8% 48us
clf.predict 246us 274us +11.5% 28us
predictions agree: yes
torch-cuda
as-is as numpy difference added
search 424.3ms 433.3ms +2.1% 8.9ms
predict 3.7ms 4.0ms +6.8% 255us
serve/call 1.3ms 1.6ms +18.3% 244us
score 3.3ms 3.6ms +8.0% 264us
one 10-row predict, step by step:
scale.transform 182us 256us +40.8% 74us
kernel.transform 820us 920us +12.2% 100us
clf.predict 315us 390us +23.8% 75us
predictions agree: yes
torch-mps
skipped: torch reports no MPS device
cupy
as-is as numpy difference added
search 598.8ms 610.4ms +1.9% 11.6ms
predict 4.3ms 4.7ms +8.2% 357us
serve/call 1.4ms 1.8ms +21.6% 312us
score 4.1ms 4.5ms +8.5% 350us
one 10-row predict, step by step:
scale.transform 189us 290us +53.7% 101us
kernel.transform 916us 1.0ms +12.4% 114us
clf.predict 327us 426us +30.2% 99us
predictions agree: yes
numpy
as-is as numpy difference added
search 2.53s 2.50s -1.3% -33.9ms
predict 44.6ms 46.2ms +3.6% 1.6ms
serve/call 821us 878us +6.9% 56us
score 23.9ms 25.3ms +6.1% 1.5ms
one 10-row predict, step by step:
scale.transform 110us 141us +28.9% 32us
kernel.transform 588us 648us +10.2% 60us
clf.predict 200us 192us -4.0% -8us
predictions agree: yes
torch-cpu
as-is as numpy difference added
search 2.18s 2.18s -0.1% -1.6ms
predict 31.9ms 34.0ms +6.6% 2.1ms
serve/call 911us 1.0ms +13.8% 126us
score 18.5ms 18.9ms +2.1% 384us
one 10-row predict, step by step:
scale.transform 135us 186us +38.0% 51us
kernel.transform 623us 702us +12.6% 79us
clf.predict 228us 259us +13.2% 30us
predictions agree: yes
torch-cuda
skipped: torch reports no CUDA device
torch-mps
as-is as numpy difference added
search 2.13s 2.17s +1.8% 37.5ms
predict 12.6ms 14.8ms +17.4% 2.2ms
serve/call 5.0ms 7.0ms +40.1% 2.0ms
score 12.0ms 14.2ms +18.1% 2.2ms
one 10-row predict, step by step:
scale.transform 814us 1.3ms +59.8% 487us
kernel.transform 3.4ms 3.9ms +15.6% 528us
clf.predict 1.2ms 2.0ms +66.7% 817us
predictions agree: yes
cupy
skipped: cupy is not installed
numpy
as-is as numpy difference added
search 2.28s 2.45s +7.6% 171.9ms
predict 46.1ms 43.8ms -4.9% -2.3ms
serve/call 807us 863us +7.0% 57us
score 23.8ms 22.8ms -4.1% -987us
one 10-row predict, step by step:
scale.transform 116us 146us +25.5% 30us
kernel.transform 607us 617us +1.8% 11us
clf.predict 203us 193us -4.9% -10us
predictions agree: yes
torch-cpu
as-is as numpy difference added
search 2.16s 2.16s +0.2% 3.9ms
predict 33.7ms 34.4ms +2.1% 719us
serve/call 908us 1.0ms +14.9% 135us
score 19.4ms 19.1ms -1.5% -288us
one 10-row predict, step by step:
scale.transform 138us 179us +30.2% 42us
kernel.transform 657us 690us +4.9% 32us
clf.predict 233us 256us +9.7% 23us
predictions agree: yes
torch-cuda
skipped: torch reports no CUDA device
torch-mps
as-is as numpy difference added
search 2.09s 2.16s +3.1% 65.2ms
predict 12.4ms 14.7ms +18.5% 2.3ms
serve/call 4.9ms 6.9ms +39.3% 1.9ms
score 11.9ms 14.3ms +19.7% 2.3ms
one 10-row predict, step by step:
scale.transform 760us 1.3ms +75.1% 571us
kernel.transform 3.2ms 3.9ms +19.2% 622us
clf.predict 1.2ms 2.0ms +67.7% 801us
predictions agree: yes
cupy
skipped: cupy is not installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment