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
1
140
Mojo Dojo
Henry Cui
October 28, 2023
Tweet
Share
More Decks by Henry Cui
See All by Henry Cui
Direct Preference Optimization
zchenry
0
140
Diffusion Model with Perceptual Loss
zchenry
0
72
レンズの下のLLM / LLM under the Lens
zchenry
0
98
Go with the Prompt Flow
zchenry
0
100
ことのはの力で画像の異常検知 / Anomaly Detection by Language
zchenry
0
190
驚愕の事実!LangChainが抱える問題 / Problems of LangChain
zchenry
0
120
MLOps初心者がMLflowを触る / MLflow Brief Introduction
zchenry
0
61
{{guidance}}のガイダンス / Guidance of guidance
zchenry
0
110
MLOps初心者がApache Airflowを触る / Apache Airflow Introduction for an MLOps Beginner
zchenry
0
160
Other Decks in Programming
See All in Programming
try! Swift Tokyo 初参加報告LT
hinakko2
0
220
OpenAPIを中心に考えるAPI開発入門 / Introduction to API Development with a Focus on OpenAPI
seike460
PRO
2
170
Hanami and htmx
bkuhlmann
0
210
Elm Form Validation
bkuhlmann
0
510
Git Rebase
bkuhlmann
11
1.6k
『Railsオワコン』と言われる時代に、なぜブルーモ証券はRailsを選ぶのか
free_world21
0
260
Site Reliability Engineering for GMO
pyama86
8
1k
スクラムガイドのスプリントレトロスペクティブを改めて読みかえしてみた / Re-reading the Sprint Retrospective Section in the Scrum Guide
mackey0225
3
450
GitHub Actionsで泣かないためにやっておきたい設定 / Recommended GHA settings to avoid crying
pinkumohikan
3
540
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
310
はてなにおける CSS Modules、及び CSS Modules に足りないもの / CSS Modules in Hatena, and CSS Modules missing parts
mizdra
7
940
Behind VS Code Extensions for JavaScript / TypeScript Linnting and Formatting
unvalley
5
990
Featured
See All Featured
Building a Scalable Design System with Sketch
lauravandoore
456
32k
Six Lessons from altMBA
skipperchong
21
3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
648
58k
Building Better People: How to give real-time feedback that sticks.
wjessup
355
18k
The Language of Interfaces
destraynor
151
23k
Git: the NoSQL Database
bkeepers
PRO
422
63k
Why Our Code Smells
bkeepers
PRO
331
56k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
Large-scale JavaScript Application Architecture
addyosmani
504
110k
GraphQLの誤解/rethinking-graphql
sonatard
50
9.2k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
30
6k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
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