SlideShare a Scribd company logo
Numba:

A JIT Compiler for Scientific
Python
1
Stan Seibert
Continuum Analytics
January 22, 2015
Why Python?
• For many programs, the most important resource
is developer time.
• The best code is:
• Easy to read
• Easy to understand
• Easy to modify
• But sometimes execution speed does matter.

Then what do you do?
2
Achieving Performance in Python
When you need speed in Python the most important
things you can do are:
1. Use profiling to understand where your
program spends time.

(Most of your code is irrelevant. Only worry
about the parts that matter.)
2. Leverage NumPy and SciPy when working
with numerical code.
3. Take a look at Numba…
3
How can Numba help?
• Numba is an open source Just-In-Time compiler
for Python functions.
• From the types of the function arguments, Numba
can often generate a specialized, fast, machine code
implementation at runtime.
• Designed to work best with numerical code and
NumPy arrays.
• Uses the LLVM library as the compiler backend.
4
Numba Features
• Numba supports:
• Windows (XP and later), OS X (10.7 and later), and
Linux
• 32 and 64-bit x86 CPUs and NVIDIA GPUs
• Python 2 and 3
• NumPy versions 1.6 through 1.9
• It does not require a C/C++ compiler on the user’s system.
• Requires less than 70 MB to install.
• Does not replace the standard Python interpreter

(all of your existing Python libraries are still available)
5
Creating a Ufunc
• Numba is the best way to make new ufuncs for
working with NumPy arrays
6
Compiling a Function
• Sometimes you can’t create a simple or efficient
array expression or ufunc. Use Numba to work
with array elements directly.
• Example: Suppose you have a boolean grid and you
want to find the maximum number neighbors a
cell has in the grid:
1 1 1
1 1 1 1 1
1 1 1 1 2 1
1 1 1 1 3 2 1
2 2 1 1 2 1
2 2 2 2 2
1 1 1 1 1
1 1 1
Compiling a Function
Compiling a Function
• Very hard to express this calculation purely as
array operations (and even if you do, it is likely
unreadable to non-NumPy experts).
• Numba let’s you write out the loops, but avoid the
penalty for having to loop over individual elements
in the Python interpreter:
169x faster!
9
Different Modes of Compilation
• Numba automatically selects between two different
levels of optimization when compiling a function:
• “object mode”: supports nearly all of Python, but
generally cannot speed up code by a large factor

(exception: see next slide)
• “nopython mode”: supports a subset of Python,
but runs at C/C++/FORTRAN speeds
10
Loop-Lifting
• In object mode, Numba will attempt to extract
loops and compile them in nopython mode.
• Works great for functions that are bookended by
uncompilable code, but have a compilable core
loop.
• All happens automatically.
11
Loop-Lifting
object mode
object mode
nopython mode
12
Nopython Mode Features
• Standard control and looping structures: if, else, while, for, range
• NumPy arrays, int, float, complex, booleans, and tuples
• Almost all arithmetic, logical, and bitwise operators as well as
functions from the math and numpy modules
• Nearly all NumPy dtypes: int, float, complex, datetime64,
timedelta64
• Array element access (read and write)
• Array reduction functions: sum, prod, max, min, etc
• Calling other nopython mode compiled functions
• Calling ctypes or cffi-wrapped external functions
13
Compiling for the GPU
GPU functions are called differently, but it is still Python!
MacBook Pro w/ GTX 650M GPU
Advanced Use Cases
• Compile new functions based on user input.
• Great for inserting a user-provided math
expression into a larger algorithm, while still
achieving C speeds.
• Optimization (least squares, etc) libraries that can
recompile themselves to inline a specific objective
function right into the algorithm
• Multithreaded calculation without having to worry
about the global interpreter lock (GIL).
15
NumbaPro
• NumbaPro adds higher level features on top of
Numba:
• Create ufuncs that run multithreaded on the
CPU or on the GPU
• GPU linear algebra
• GPU FFTs
16
Conclusion
• Numba is a JIT compiler than understands Python!
• Achieve the same speeds as compiled languages for
numerical and array-processing code.
• Can be used to create advanced workflows where
user input drives compilation at runtime.
• Open source, available at:
http://numba.pydata.org/
• Or:
conda	
  install	
  numba
17

More Related Content

What's hot

実用Brainf*ckプログラミング
実用Brainf*ckプログラミング実用Brainf*ckプログラミング
実用Brainf*ckプログラミング
京大 マイコンクラブ
 
[DL輪読会] Residual Attention Network for Image Classification
[DL輪読会] Residual Attention Network for Image Classification[DL輪読会] Residual Attention Network for Image Classification
[DL輪読会] Residual Attention Network for Image Classification
Deep Learning JP
 
新分野に飛び入って半年で業績を作るには
新分野に飛び入って半年で業績を作るには新分野に飛び入って半年で業績を作るには
新分野に飛び入って半年で業績を作るには
Asai Masataro
 
アルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化するアルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化する
AtCoder Inc.
 
libpgenでパケット操作
libpgenでパケット操作libpgenでパケット操作
libpgenでパケット操作
slankdev
 
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
Deep Learning JP
 
Go-ICP: グローバル最適(Globally optimal) なICPの解説
Go-ICP: グローバル最適(Globally optimal) なICPの解説Go-ICP: グローバル最適(Globally optimal) なICPの解説
Go-ICP: グローバル最適(Globally optimal) なICPの解説
Yusuke Sekikawa
 
PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門Yosuke Onoue
 
C++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISるC++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISる
Hideyuki Tanaka
 
Power Automateってどんな子?(気ままに勉強会#01)
Power Automateってどんな子?(気ままに勉強会#01)Power Automateってどんな子?(気ままに勉強会#01)
Power Automateってどんな子?(気ままに勉強会#01)
た な
 
NIP2015読み会「End-To-End Memory Networks」
NIP2015読み会「End-To-End Memory Networks」NIP2015読み会「End-To-End Memory Networks」
NIP2015読み会「End-To-End Memory Networks」
Yuya Unno
 
Batch Reinforcement Learning
Batch Reinforcement LearningBatch Reinforcement Learning
Batch Reinforcement Learning
Takuma Oda
 
ICLR2020読み会 (neural-tangents)
ICLR2020読み会 (neural-tangents)ICLR2020読み会 (neural-tangents)
ICLR2020読み会 (neural-tangents)
RyuichiKanoh
 
論文紹介: Fast R-CNN&Faster R-CNN
論文紹介: Fast R-CNN&Faster R-CNN論文紹介: Fast R-CNN&Faster R-CNN
論文紹介: Fast R-CNN&Faster R-CNN
Takashi Abe
 
データに内在する構造をみるための埋め込み手法
データに内在する構造をみるための埋め込み手法データに内在する構造をみるための埋め込み手法
データに内在する構造をみるための埋め込み手法
Tatsuya Shirakawa
 
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
Deep Learning JP
 
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
Hideki Takase
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミング
Ransui Iso
 
ひたすら楽してスライド作成
ひたすら楽してスライド作成ひたすら楽してスライド作成
ひたすら楽してスライド作成
Masanori Morise
 
Ml system in_python
Ml system in_pythonMl system in_python
Ml system in_python
yusuke shibui
 

What's hot (20)

実用Brainf*ckプログラミング
実用Brainf*ckプログラミング実用Brainf*ckプログラミング
実用Brainf*ckプログラミング
 
[DL輪読会] Residual Attention Network for Image Classification
[DL輪読会] Residual Attention Network for Image Classification[DL輪読会] Residual Attention Network for Image Classification
[DL輪読会] Residual Attention Network for Image Classification
 
新分野に飛び入って半年で業績を作るには
新分野に飛び入って半年で業績を作るには新分野に飛び入って半年で業績を作るには
新分野に飛び入って半年で業績を作るには
 
アルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化するアルゴリズムのイメージを擬人化する
アルゴリズムのイメージを擬人化する
 
libpgenでパケット操作
libpgenでパケット操作libpgenでパケット操作
libpgenでパケット操作
 
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
[DL輪読会]Auto-DeepLab: Hierarchical Neural Architecture Search for Semantic Ima...
 
Go-ICP: グローバル最適(Globally optimal) なICPの解説
Go-ICP: グローバル最適(Globally optimal) なICPの解説Go-ICP: グローバル最適(Globally optimal) なICPの解説
Go-ICP: グローバル最適(Globally optimal) なICPの解説
 
PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門PyOpenCLによるGPGPU入門
PyOpenCLによるGPGPU入門
 
C++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISるC++コミュニティーの中心でC++をDISる
C++コミュニティーの中心でC++をDISる
 
Power Automateってどんな子?(気ままに勉強会#01)
Power Automateってどんな子?(気ままに勉強会#01)Power Automateってどんな子?(気ままに勉強会#01)
Power Automateってどんな子?(気ままに勉強会#01)
 
NIP2015読み会「End-To-End Memory Networks」
NIP2015読み会「End-To-End Memory Networks」NIP2015読み会「End-To-End Memory Networks」
NIP2015読み会「End-To-End Memory Networks」
 
Batch Reinforcement Learning
Batch Reinforcement LearningBatch Reinforcement Learning
Batch Reinforcement Learning
 
ICLR2020読み会 (neural-tangents)
ICLR2020読み会 (neural-tangents)ICLR2020読み会 (neural-tangents)
ICLR2020読み会 (neural-tangents)
 
論文紹介: Fast R-CNN&Faster R-CNN
論文紹介: Fast R-CNN&Faster R-CNN論文紹介: Fast R-CNN&Faster R-CNN
論文紹介: Fast R-CNN&Faster R-CNN
 
データに内在する構造をみるための埋め込み手法
データに内在する構造をみるための埋め込み手法データに内在する構造をみるための埋め込み手法
データに内在する構造をみるための埋め込み手法
 
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
【DL輪読会】DINOv2: Learning Robust Visual Features without Supervision
 
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
ロボットシステムのつくりかた 〜Robot Operating Systemというアプローチ〜
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミング
 
ひたすら楽してスライド作成
ひたすら楽してスライド作成ひたすら楽してスライド作成
ひたすら楽してスライド作成
 
Ml system in_python
Ml system in_pythonMl system in_python
Ml system in_python
 

Viewers also liked

Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
Travis Oliphant
 
Scala.io
Scala.ioScala.io
Scala.io
Steve Gury
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...
PyData
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Intel® Software
 
Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentationkammeyer
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
Travis Oliphant
 

Viewers also liked (7)

Scaling PyData Up and Out
Scaling PyData Up and OutScaling PyData Up and Out
Scaling PyData Up and Out
 
Scala.io
Scala.ioScala.io
Scala.io
 
PyData Paris 2015 - Track 3.3 Antoine Pitrou
PyData Paris 2015 - Track 3.3 Antoine PitrouPyData Paris 2015 - Track 3.3 Antoine Pitrou
PyData Paris 2015 - Track 3.3 Antoine Pitrou
 
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Numba:  Flexible analytics written in Python with machine-code speeds and avo...Numba:  Flexible analytics written in Python with machine-code speeds and avo...
Numba: Flexible analytics written in Python with machine-code speeds and avo...
 
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
 
Buzzwords Numba Presentation
Buzzwords Numba PresentationBuzzwords Numba Presentation
Buzzwords Numba Presentation
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
 

Similar to Numba Overview

Scale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataScale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyData
Travis Oliphant
 
SciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with NumbaSciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with Numba
stan_seibert
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pieTomas Doran
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_monTomas Doran
 
Want to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's howWant to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's how
Jim Arlow
 
Python for ML.pptx
Python for ML.pptxPython for ML.pptx
Python for ML.pptx
Dr. Amanpreet Kaur
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
Travis Oliphant
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Luis Goldster
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Fraboni Ec
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Young Alista
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
James Wong
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Harry Potter
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Tony Nguyen
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
Hoang Nguyen
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
Fwdays
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with Pythran
Ralf Gommers
 
An Introduction to PyPy
An Introduction to PyPyAn Introduction to PyPy
An Introduction to PyPy
Michael Hudson-Doyle
 
Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)
AllineaSoftware
 

Similar to Numba Overview (20)

Scale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyDataScale up and Scale Out Anaconda and PyData
Scale up and Scale Out Anaconda and PyData
 
SciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with NumbaSciPy 2019: How to Accelerate an Existing Codebase with Numba
SciPy 2019: How to Accelerate an Existing Codebase with Numba
 
Cooking a rabbit pie
Cooking a rabbit pieCooking a rabbit pie
Cooking a rabbit pie
 
OpenMP
OpenMPOpenMP
OpenMP
 
Real time system_performance_mon
Real time system_performance_monReal time system_performance_mon
Real time system_performance_mon
 
Want to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's howWant to write a book in Jupyter - here's how
Want to write a book in Jupyter - here's how
 
Python for ML.pptx
Python for ML.pptxPython for ML.pptx
Python for ML.pptx
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Python your new best friend
Python your new best friendPython your new best friend
Python your new best friend
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Building SciPy kernels with Pythran
Building SciPy kernels with PythranBuilding SciPy kernels with Pythran
Building SciPy kernels with Pythran
 
Numba lightning
Numba lightningNumba lightning
Numba lightning
 
An Introduction to PyPy
An Introduction to PyPyAn Introduction to PyPy
An Introduction to PyPy
 
Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)Preparing Codes for Intel Knights Landing (KNL)
Preparing Codes for Intel Knights Landing (KNL)
 

Recently uploaded

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
wottaspaceseo
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 

Recently uploaded (20)

How Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptxHow Recreation Management Software Can Streamline Your Operations.pptx
How Recreation Management Software Can Streamline Your Operations.pptx
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 

Numba Overview

  • 1. Numba:
 A JIT Compiler for Scientific Python 1 Stan Seibert Continuum Analytics January 22, 2015
  • 2. Why Python? • For many programs, the most important resource is developer time. • The best code is: • Easy to read • Easy to understand • Easy to modify • But sometimes execution speed does matter.
 Then what do you do? 2
  • 3. Achieving Performance in Python When you need speed in Python the most important things you can do are: 1. Use profiling to understand where your program spends time.
 (Most of your code is irrelevant. Only worry about the parts that matter.) 2. Leverage NumPy and SciPy when working with numerical code. 3. Take a look at Numba… 3
  • 4. How can Numba help? • Numba is an open source Just-In-Time compiler for Python functions. • From the types of the function arguments, Numba can often generate a specialized, fast, machine code implementation at runtime. • Designed to work best with numerical code and NumPy arrays. • Uses the LLVM library as the compiler backend. 4
  • 5. Numba Features • Numba supports: • Windows (XP and later), OS X (10.7 and later), and Linux • 32 and 64-bit x86 CPUs and NVIDIA GPUs • Python 2 and 3 • NumPy versions 1.6 through 1.9 • It does not require a C/C++ compiler on the user’s system. • Requires less than 70 MB to install. • Does not replace the standard Python interpreter
 (all of your existing Python libraries are still available) 5
  • 6. Creating a Ufunc • Numba is the best way to make new ufuncs for working with NumPy arrays 6
  • 7. Compiling a Function • Sometimes you can’t create a simple or efficient array expression or ufunc. Use Numba to work with array elements directly. • Example: Suppose you have a boolean grid and you want to find the maximum number neighbors a cell has in the grid: 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 3 2 1 2 2 1 1 2 1 2 2 2 2 2 1 1 1 1 1 1 1 1
  • 9. Compiling a Function • Very hard to express this calculation purely as array operations (and even if you do, it is likely unreadable to non-NumPy experts). • Numba let’s you write out the loops, but avoid the penalty for having to loop over individual elements in the Python interpreter: 169x faster! 9
  • 10. Different Modes of Compilation • Numba automatically selects between two different levels of optimization when compiling a function: • “object mode”: supports nearly all of Python, but generally cannot speed up code by a large factor
 (exception: see next slide) • “nopython mode”: supports a subset of Python, but runs at C/C++/FORTRAN speeds 10
  • 11. Loop-Lifting • In object mode, Numba will attempt to extract loops and compile them in nopython mode. • Works great for functions that are bookended by uncompilable code, but have a compilable core loop. • All happens automatically. 11
  • 13. Nopython Mode Features • Standard control and looping structures: if, else, while, for, range • NumPy arrays, int, float, complex, booleans, and tuples • Almost all arithmetic, logical, and bitwise operators as well as functions from the math and numpy modules • Nearly all NumPy dtypes: int, float, complex, datetime64, timedelta64 • Array element access (read and write) • Array reduction functions: sum, prod, max, min, etc • Calling other nopython mode compiled functions • Calling ctypes or cffi-wrapped external functions 13
  • 14. Compiling for the GPU GPU functions are called differently, but it is still Python! MacBook Pro w/ GTX 650M GPU
  • 15. Advanced Use Cases • Compile new functions based on user input. • Great for inserting a user-provided math expression into a larger algorithm, while still achieving C speeds. • Optimization (least squares, etc) libraries that can recompile themselves to inline a specific objective function right into the algorithm • Multithreaded calculation without having to worry about the global interpreter lock (GIL). 15
  • 16. NumbaPro • NumbaPro adds higher level features on top of Numba: • Create ufuncs that run multithreaded on the CPU or on the GPU • GPU linear algebra • GPU FFTs 16
  • 17. Conclusion • Numba is a JIT compiler than understands Python! • Achieve the same speeds as compiled languages for numerical and array-processing code. • Can be used to create advanced workflows where user input drives compilation at runtime. • Open source, available at: http://numba.pydata.org/ • Or: conda  install  numba 17