Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Mojo Dojo
Search
Henry Cui
October 28, 2023
Programming
0
190
Mojo Dojo
Henry Cui
October 28, 2023
Tweet
Share
More Decks by Henry Cui
See All by Henry Cui
プロダクション言語モデルの情報を盗む攻撃 / Stealing Part of a Production Language Model
zchenry
0
150
Direct Preference Optimization
zchenry
0
350
Diffusion Model with Perceptual Loss
zchenry
0
320
レンズの下のLLM / LLM under the Lens
zchenry
0
170
Go with the Prompt Flow
zchenry
0
150
ことのはの力で画像の異常検知 / Anomaly Detection by Language
zchenry
0
520
驚愕の事実!LangChainが抱える問題 / Problems of LangChain
zchenry
0
220
MLOps初心者がMLflowを触る / MLflow Brief Introduction
zchenry
0
100
{{guidance}}のガイダンス / Guidance of guidance
zchenry
0
150
Other Decks in Programming
See All in Programming
Develop Faster With FrankenPHP
dunglas
2
3.3k
SwiftUI API Design Lessons
niw
1
280
サービスレベルを管理してアジャイルを加速しよう!! / slm-accelerate-agility
tomoyakitaura
1
170
Empowering Developers with HTML-Aware ERB Tooling @ RubyKaigi 2025, Matsuyama, Ehime
marcoroth
2
470
Deoptimization: How YJIT Speeds Up Ruby by Slowing Down / RubyKaigi 2025
k0kubun
0
770
KawaiiLT 登壇資料 キャリアとモチベーション
hiiragi
0
110
趣味全開のAITuber開発
kokushin
0
200
Signal-Based Data FetchingWith the New httpResource
manfredsteyer
PRO
0
170
AI時代の開発者評価について
ayumuu
0
140
「”誤った使い方をすることが困難”な設計」で良いコードの基礎を固めよう / phpcon-odawara-2025
taniguhey
0
140
AWSで雰囲気でつくる! VRChatの写真変換ピタゴラスイッチ
anatofuz
0
150
Exit 8 for SwiftUI
ojun9
0
130
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
331
21k
How STYLIGHT went responsive
nonsquared
99
5.5k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
52
2.4k
Faster Mobile Websites
deanohume
306
31k
A better future with KSS
kneath
239
17k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Building Applications with DynamoDB
mza
94
6.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.5k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
13
670
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Building an army of robots
kneath
304
45k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Transcript
Mojo Dojo 機械学習の社会実装勉強会第28回 Henry 2023/10/28
WELCOME 2
Barbie Mojo ▪ Modular社がリリースしたPythonのスーパーセット ▪ Modular社の共同創業者・CEO Chris Lattner は、今まで SwiftやTPUなどを携わってきた
▪ MojoはPythonより何倍も速い! ▪ スーパーセットなので、既存のPytorchなどのコードもそのまま 動く! ▪ Pythonの柔軟性を維持しつつ、Rustにあるような厳密性も! 3
Mojo Toolbox ▪ Mojo driver • 実行シェル • 実行ファイルのビルドも •
Linux版とMac版がすでにリリース • 今日主に見ていく ▪ VS Code 拡張 • 文法ハイライトなど ▪ Jupyter kernel • Mojo notebookが書ける ▪ デバッグツール(未公開) 4
Mojoのインストール ▪ https://developer.modular.com/download から ▪ アカウント作成が必要 ▪ 認証コード付きのURLが生成される ▪ https://github.com/modularml/mojo/tree/main/examples
• 認証コードを使ったDocker環境も作れます 5
Hello World ▪ Mojo ▪ mainで名付けているので、別途呼び出さなくて良い ▪ mojo buildで単体で実行可能なファイルをビルド ▪
Pythonファイルの場合、怒られる • mojo hello.py ▪ mojo: error: no such command 'hello.py' • mojo build hello.py ▪ mojo: error: cannot open 'hello.py', since it does not appear to be a Mojo file (it does not end in '.mojo' or '.🔥') • mojo hello_py.mojoの場合は文法エラー 6
Hello Worldの時間 ▪ timeコマンドで計測 ▪ python hello.py は 0.017s ▪
mojo hello.mojo は 0.089s ▪ ./hello はなんと 0.005s 7
matmulベンチマーク ▪ https://github.com/modularml/mojo/blob/main/examples/m atmul.mojo に用意されている ▪ 比較用のPythonはナイーブな行列掛け算しか実装されてない ▪ mojoのほうは様々な最適化が施されている 8
matmulベンチマーク ▪ ビルド自体は0.825s ▪ ビルドした実行ファイルを実行時に下記のエラーになることが ある • Mojo/Python interoperability error:
Unable to locate a suitable libpython, please set `MOJO_PYTHON_LIBRARY` • https://github.com/modularml/mojo/issues/551 を参考に、export MOJO_PYTHON_LIBRARY="/usr/lib/x86_64-linux-gnu/libpython3 .8.so" してからビルドし直すことで解決 9
matmulベンチマーク ▪ 恐ろしい実行結果 • mojo matmul.mojo • ./matmul 10
matmulベンチマーク ▪ Pythonでforループをやめて、np.matmulを使う場合 • それでも速かった 11
まとめ ▪ mojoの紹介 ▪ 簡単なベンチマーク 12