Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
thread_parallel_with_free-threaded_Python_and_N...
Search
Riku Sakamoto
September 10, 2026
Programming
390
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
Riku Sakamoto
September 10, 2026
More Decks by Riku Sakamoto
See All by Riku Sakamoto
物理量次元を持つテンソルをサポートした 深層学習ライブラリ Phlower の紹介
riku_sakamoto
0
130
論文紹介 “CKGConv: General Graph Convolution with Continuous Kernels"
riku_sakamoto
0
420
dagstreamでデータ前処理の順序関係を解決する #stapy105
riku_sakamoto
0
210
論文紹介“Infinite-Fidelity Coregionalization for Physical Simulation ”, Shibo. L. et, al
riku_sakamoto
0
490
Other Decks in Programming
See All in Programming
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
170
AWS CDKのカスタムリソースでContinuum(旧Security Agent)を実装した話 | Implementing Continuum (formerly Security Agent) via AWS CDK Custom Resource
akihisaikeda
2
150
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
110
Event is what happens
moro
1
120
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
990
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
150
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
110
contenteditable と日本語入力に向き合う
colorful12
0
190
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
150
JRuby: Past, Present, and Future
headius
0
230
Ghostty + Neovimで作る 透明でカッコ良い開発環境
j341nono
0
170
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
530
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
The Invisible Side of Design
smashingmag
301
52k
Scaling GitHub
holman
464
140k
Site-Speed That Sticks
csswizardry
13
1.6k
Rails Girls Zürich Keynote
gr2m
96
14k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
Skip the Path - Find Your Career Trail
mkilby
1
250
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.9k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
600
Tell your own story through comics
letsgokoyo
1
1.1k
Transcript
Free-Threaded Python とNumPyによる スレッド並列処理の紹介 みんなのPython勉強会#122 坂本 陸 2026-09-10
自己紹介 坂本 陸(Sakamoto Riku) • Tech Lead(所属:株式会社 RICOS) ◦ ◦
• 数値シミュレーション結果を予測する機械学習モデルの 研究開発 機械学習ツールの開発、管理 OSS活動: ◦ ◦ (Maintainer) Phlower, dagstream (Contributor) NumPy, PyVista GitHub: @riku-sakamoto 2
プロセス並列とスレッド並列 プロセス並列 スレッド並列 プロセス プロセス1 プロセス2 メモリ メモリ メモリ スレッド
スレッド スレッド 処理A 処理B スレッド 処理A 処理B スレッド並列を使うことで、同じメモリ空間を参照する処理を 同時に実行することができる 3
Free-Threaded Python • • Global Interpreter Lock (GIL)により、1つのPython Interpreter内では、 同時にPython
bytecodeを実行できるスレッドが1つに制限される GIL を外したFree-Threaded Python を利用することで、マルチコアを利用 したスレッド並列な処理を実現できる プロセス uv でinstall した例 メモリ スレッド 処理A スレッド 処理B 4
NumPy におけるマルチスレッド対応 • • NumPy では早くからFree-threaded Python への対応が行われていた 同一プロセス内のスレッド間では、NumPy配列をコピーせず共有できる 5
スレッド並列の注意点 • Race Conditions (データの競合) ◦ ◦ • 配列を Readonly
にして共有する スレッドが同時に書き込むデータを減らす CPU Oversubscription ◦ ◦ 各Pythonスレッドから呼び出したBLAS等が、内部でさらに複数のスレッドを生成する場合 に並列化効率が悪化する threadpoolctl を使うことでBLAS などが使用するスレッド数を制限できる 6
まとめ Free-Threaded Python と NumPy を用いることで、Pythonコードから スレッド並列な処理を広く活用できるようになる • Writing Performant
NumPy Code with Multi-Core CPUs ◦ ◦ • Scaling NumPy on Free-Threaded Python ◦ • NumPy の 公式ドキュメント PR-30820 (私が書きました) NumPy、CPython のコア開発者による実装の解説記事 Python Free-Threading Guide ◦ ◦ Free-Threaded Python 全般に関するドキュメント Quansight社(NumPy や SciPy のコアDeveloper やMaintainer が所属する会社)が管理す る記事 7
8