SlideShare a Scribd company logo
Numba
NumPy-aware dynamic Python compiler

               Travis E. Oliphant


   SciPy 2012. Austin, TX, USA. July 18, 2012
Motivation
• Python is great for rapid development
  and high-level thinking-in-code
• It is slow for interior loops because lack
  of type information leads to a lot of
  indirection and “extra” code.
Motivation
• NumPy users have a lot of type
  information --- but only currently have
  one-size fits all pre-compiled, vectorized
  loops.
• Many new features envisioned will need
  the ability for high-level expressions to
  be compiled to machine code.
Goals
 • Most developers should not have to write
   anything but Python -- or other even higher-
   level Domain Specific Language (DSL).
 • Create faster code using array-expressions from
   NumPy users -- Fortran is the initial target
 • Take advantage of multi-core and GPUs for a
   subset of Python.
Why Not PyPy?
• PyPy does not work with CPython
• PyPy is a (meta) “tracing” JIT. Machine code is
  generated on the fly so there is no “build step” -- but
  we want to support a “build step” when justified
• PyPy tries to speed up everything -- we want to
  optimize more specifically on numeric codes
  (including complex numbers)
               More to the story...
Why not Cython?

• Cython is great for what it does, but...
• Cython creates extension modules which cannot be
  “unloaded” dynamically
• Cython requires a full C-compiler
• Cython doesn’t do type inference -- you have to
  declare types on everything
• Cython is another syntax to learn
What’s the real motivation...
• “Computed columns” for data-types
• Always been bothered by how to write a fast-version
  of “vectorize”
• and... I wanted to play with LLVM!
More Ranting
• The world needs more array-oriented compilers --
  Python has needed one for a decade at least.
• Array-oriented computing needs more light in CS
  curricula
• Most domain experts can write what they want at a
  high-level. Commonly this is then “translated” to a
  lower-level and then the compiler gets a hold of it.
  This is sub-optimal.
• Projects discussed are doing this, but still niche.
  Copperhead, Theano, etc.
More Ranting
• Today’s vector machines (and vector co-processors,
  or GPUS) were made for array-oriented computing.
• The software stack has just not caught up ---
  unfortunate because APL came out in 1963.
• There is a reason Fortran remains popular.
Array-Oriented Computing
• Loosely defined as “Organize data-together” and
 operate on it together (or in cache-size chunks) with
 array-level operations (e.g. NumPy)
              Object                           Attr1   Attr2   Attr3
              Attr1    Object
    Object                           Object1
              Attr2    Attr1
    Attr1
              Attr3    Attr2         Object2
    Attr2
                       Attr3
    Attr3                            Object3

              Object                 Object4
     Object   Attr1
                       Object        Object5
      Attr1   Attr2
                        Attr1
      Attr2   Attr3                  Object6
                        Attr2
      Attr3             Attr3
Goal:

        Numba should be the world’s best
           array-oriented compiler.
NumPy + Mamba = Numba
 Python Function                         Machine Code


                       LLVM-PY

                   LLVM Library
       ISPC   OpenCL    OpenMP    CUDA      CLANG

    Intel     AMD        Nvidia     Apple       ARM
Ufuncs


                Generalized
                 UFuncs
                                                          Python
                                                         Function
                 Window
                 Kernel
                  Funcs

                 Function-
                                                                    Uses of Numba




                   based
                 Indexing


                 Memory
                  Filters
                                                 Numba




NumPy Runtime
                I/O Filters



                Reduction
                 Filters


                Computed
                Columns
                              function pointer
Uses of Numba in SciPy

     optimize                   integrate


     special                       ode



     writing more of SciPy at high-level
Numba --- a deeper look

   Numba is a Python to LLVM translator. It
   translates Python to LLVM IR (the LLVM
   machinery is then used to create machine
  code from there). Numba is NumPy aware
    --- it understands NumPy’s type system,
      methods, C-API, and data-structures
Numba -- written in Python
 • Numba itself is pure Python -- it uses (an
   updated) LLVM-py to interact with the LLVM
   C++ library to build a representation of the
   code in LLVM assembler.
 • LLVM then creates machine code (or a
   “bitcode” module which can be persisted or
   sent to another machine)
 • Machine-code is equivalent to a C-level
   function-pointer (e.g. a ctypes function)
Example
Examples
Numba
Numba
Demo
Status and Future
• Current master branch mostly due to Jon Riehl
  (Resilient Science) sponsored by Continuum
  Analytics, Inc. --- interprets bytecode directly
• New devel branch working with AST directly and
  making rapid progress
  - Mark Florrison (minivect)
  - Siu Kwan Lam (pymothoa)
Software Stack Future?
         Plateaus of Code re-use + DSLs
   SQL                                R
            TDPL                                Matlab


                    Python


             OBJC                C
  FORTRAN                                 C++



                     LLVM
Join Us!



      http://numba.github.com/numba

More Related Content

PDF
Intro to Machine Learning for GPUs
PDF
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
PPTX
Salp swarm algorithm
PDF
Getting started with pandas
PPTX
Searching Techniques and Analysis
PDF
PyTorch Introduction
PDF
Pycon2013 : Application of Python in Robotics
PDF
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...
Intro to Machine Learning for GPUs
PyTorch Python Tutorial | Deep Learning Using PyTorch | Image Classifier Usin...
Salp swarm algorithm
Getting started with pandas
Searching Techniques and Analysis
PyTorch Introduction
Pycon2013 : Application of Python in Robotics
TensorFlow Tutorial | Deep Learning Using TensorFlow | TensorFlow Tutorial Py...

What's hot (20)

PPTX
Array ADT(Abstract Data Type)|Data Structure
PPT
Linear Search & Binary Search
PDF
TensorFlow and Keras: An Overview
PDF
[系列活動] 手把手的深度學習實務
PDF
Introduction to Deep Learning, Keras, and TensorFlow
PDF
C++ Standard Template Library
PPTX
Pytorch
PPTX
Splay tree
PDF
Introduction to TensorFlow 2.0
PPTX
Unit 1 abstract data types
PPTX
Python for data science
PPTX
Introduction to Keras
PPT
how to calclute time complexity of algortihm
PDF
Machine Learning and Model-Based Optimization for Heterogeneous Catalyst Desi...
PPTX
Introduction to numpy
PPTX
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
PDF
Intro to GemStone/S
PPTX
Multi-Task Learning in Deep Neural Networks.pptx
PPTX
Practical Swarm Optimization (PSO)
PPT
Asymptotic Notation and Complexity
Array ADT(Abstract Data Type)|Data Structure
Linear Search & Binary Search
TensorFlow and Keras: An Overview
[系列活動] 手把手的深度學習實務
Introduction to Deep Learning, Keras, and TensorFlow
C++ Standard Template Library
Pytorch
Splay tree
Introduction to TensorFlow 2.0
Unit 1 abstract data types
Python for data science
Introduction to Keras
how to calclute time complexity of algortihm
Machine Learning and Model-Based Optimization for Heterogeneous Catalyst Desi...
Introduction to numpy
TensorFlow Tutorial | Deep Learning With TensorFlow | TensorFlow Tutorial For...
Intro to GemStone/S
Multi-Task Learning in Deep Neural Networks.pptx
Practical Swarm Optimization (PSO)
Asymptotic Notation and Complexity
Ad

Viewers also liked (11)

PPTX
ニューラル機械翻訳の動向@IBIS2017
PDF
GPU Computing With Apache Spark And Python
PDF
The State of High-Performance Computing in the Open-Source R Ecosystem
PDF
Buzzwords Numba Presentation
PDF
Numba: Flexible analytics written in Python with machine-code speeds and avo...
PDF
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
PDF
Numba: Array-oriented Python Compiler for NumPy
PDF
米国のペネトレーションテスト事情(ssmjp)
PDF
[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...
PDF
チームで取り組む!アクセシビリティコーディング&デザイン
PDF
4つの戦犯から考えるサービスづくりの失敗
ニューラル機械翻訳の動向@IBIS2017
GPU Computing With Apache Spark And Python
The State of High-Performance Computing in the Open-Source R Ecosystem
Buzzwords Numba Presentation
Numba: Flexible analytics written in Python with machine-code speeds and avo...
Accelerate Your Python* Code through Profiling, Tuning, and Compilation Part ...
Numba: Array-oriented Python Compiler for NumPy
米国のペネトレーションテスト事情(ssmjp)
[Microsoft Tech Summit 2017] マイクロサービスだけじゃない! コンテナー オーケストレーターとしての「Azure Servic...
チームで取り組む!アクセシビリティコーディング&デザイン
4つの戦犯から考えるサービスづくりの失敗
Ad

Similar to Numba (20)

PDF
The Joy of SciPy
KEY
Numba lightning
PDF
PyCon Estonia 2019
PDF
Array computing and the evolution of SciPy, NumPy, and PyData
PDF
Travis Oliphant "Python for Speed, Scale, and Science"
PDF
PyData Boston 2013
PPTX
Scaling Python to CPUs and GPUs
PDF
Migrating from matlab to python
PDF
London level39
PDF
Scale up and Scale Out Anaconda and PyData
PDF
Standardizing arrays -- Microsoft Presentation
PDF
Numba Overview
PDF
Python for Computer Vision - Revision
PDF
Blaze: a large-scale, array-oriented infrastructure for Python
PDF
SunPy: Python for solar physics
PPTX
Python for ML.pptx
PPTX
Role of python in hpc
PDF
On the necessity and inapplicability of python
PDF
On the Necessity and Inapplicability of Python
PDF
Python for Science and Engineering: a presentation to A*STAR and the Singapor...
The Joy of SciPy
Numba lightning
PyCon Estonia 2019
Array computing and the evolution of SciPy, NumPy, and PyData
Travis Oliphant "Python for Speed, Scale, and Science"
PyData Boston 2013
Scaling Python to CPUs and GPUs
Migrating from matlab to python
London level39
Scale up and Scale Out Anaconda and PyData
Standardizing arrays -- Microsoft Presentation
Numba Overview
Python for Computer Vision - Revision
Blaze: a large-scale, array-oriented infrastructure for Python
SunPy: Python for solar physics
Python for ML.pptx
Role of python in hpc
On the necessity and inapplicability of python
On the Necessity and Inapplicability of Python
Python for Science and Engineering: a presentation to A*STAR and the Singapor...

More from Travis Oliphant (12)

PDF
SciPy Latin America 2019
PDF
Keynote at Converge 2019
PDF
PyData Barcelona Keynote
PPTX
Python for Data Science with Anaconda
PDF
Fast and Scalable Python
PDF
Scaling PyData Up and Out
PDF
Python as the Zen of Data Science
PDF
Anaconda and PyData Solutions
PDF
Continuum Analytics and Python
PDF
Bids talk 9.18
PDF
Effectively using Open Source with conda
KEY
PyData Introduction
SciPy Latin America 2019
Keynote at Converge 2019
PyData Barcelona Keynote
Python for Data Science with Anaconda
Fast and Scalable Python
Scaling PyData Up and Out
Python as the Zen of Data Science
Anaconda and PyData Solutions
Continuum Analytics and Python
Bids talk 9.18
Effectively using Open Source with conda
PyData Introduction

Recently uploaded (20)

PDF
Smarter Business Operations Powered by IoT Remote Monitoring
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
PDF
Top Generative AI Tools for Patent Drafting in 2025.pdf
PDF
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
PDF
DevOps & Developer Experience Summer BBQ
PDF
Dell Pro 14 Plus: Be better prepared for what’s coming
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PDF
SparkLabs Primer on Artificial Intelligence 2025
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx
Smarter Business Operations Powered by IoT Remote Monitoring
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
ChatGPT's Deck on The Enduring Legacy of Fax Machines
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
Top Generative AI Tools for Patent Drafting in 2025.pdf
Test Bank, Solutions for Java How to Program, An Objects-Natural Approach, 12...
CroxyProxy Instagram Access id login.pptx
Revolutionize Operations with Intelligent IoT Monitoring and Control
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
NewMind AI Weekly Chronicles - July'25 - Week IV
DevOps & Developer Experience Summer BBQ
Dell Pro 14 Plus: Be better prepared for what’s coming
Reimagining Insurance: Connected Data for Confident Decisions.pdf
SparkLabs Primer on Artificial Intelligence 2025
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
GamePlan Trading System Review: Professional Trader's Honest Take
ABU RAUP TUGAS TIK kelas 8 hjhgjhgg.pptx

Numba

  • 1. Numba NumPy-aware dynamic Python compiler Travis E. Oliphant SciPy 2012. Austin, TX, USA. July 18, 2012
  • 2. Motivation • Python is great for rapid development and high-level thinking-in-code • It is slow for interior loops because lack of type information leads to a lot of indirection and “extra” code.
  • 3. Motivation • NumPy users have a lot of type information --- but only currently have one-size fits all pre-compiled, vectorized loops. • Many new features envisioned will need the ability for high-level expressions to be compiled to machine code.
  • 4. Goals • Most developers should not have to write anything but Python -- or other even higher- level Domain Specific Language (DSL). • Create faster code using array-expressions from NumPy users -- Fortran is the initial target • Take advantage of multi-core and GPUs for a subset of Python.
  • 5. Why Not PyPy? • PyPy does not work with CPython • PyPy is a (meta) “tracing” JIT. Machine code is generated on the fly so there is no “build step” -- but we want to support a “build step” when justified • PyPy tries to speed up everything -- we want to optimize more specifically on numeric codes (including complex numbers) More to the story...
  • 6. Why not Cython? • Cython is great for what it does, but... • Cython creates extension modules which cannot be “unloaded” dynamically • Cython requires a full C-compiler • Cython doesn’t do type inference -- you have to declare types on everything • Cython is another syntax to learn
  • 7. What’s the real motivation... • “Computed columns” for data-types • Always been bothered by how to write a fast-version of “vectorize” • and... I wanted to play with LLVM!
  • 8. More Ranting • The world needs more array-oriented compilers -- Python has needed one for a decade at least. • Array-oriented computing needs more light in CS curricula • Most domain experts can write what they want at a high-level. Commonly this is then “translated” to a lower-level and then the compiler gets a hold of it. This is sub-optimal. • Projects discussed are doing this, but still niche. Copperhead, Theano, etc.
  • 9. More Ranting • Today’s vector machines (and vector co-processors, or GPUS) were made for array-oriented computing. • The software stack has just not caught up --- unfortunate because APL came out in 1963. • There is a reason Fortran remains popular.
  • 10. Array-Oriented Computing • Loosely defined as “Organize data-together” and operate on it together (or in cache-size chunks) with array-level operations (e.g. NumPy) Object Attr1 Attr2 Attr3 Attr1 Object Object Object1 Attr2 Attr1 Attr1 Attr3 Attr2 Object2 Attr2 Attr3 Attr3 Object3 Object Object4 Object Attr1 Object Object5 Attr1 Attr2 Attr1 Attr2 Attr3 Object6 Attr2 Attr3 Attr3
  • 11. Goal: Numba should be the world’s best array-oriented compiler.
  • 12. NumPy + Mamba = Numba Python Function Machine Code LLVM-PY LLVM Library ISPC OpenCL OpenMP CUDA CLANG Intel AMD Nvidia Apple ARM
  • 13. Ufuncs Generalized UFuncs Python Function Window Kernel Funcs Function- Uses of Numba based Indexing Memory Filters Numba NumPy Runtime I/O Filters Reduction Filters Computed Columns function pointer
  • 14. Uses of Numba in SciPy optimize integrate special ode writing more of SciPy at high-level
  • 15. Numba --- a deeper look Numba is a Python to LLVM translator. It translates Python to LLVM IR (the LLVM machinery is then used to create machine code from there). Numba is NumPy aware --- it understands NumPy’s type system, methods, C-API, and data-structures
  • 16. Numba -- written in Python • Numba itself is pure Python -- it uses (an updated) LLVM-py to interact with the LLVM C++ library to build a representation of the code in LLVM assembler. • LLVM then creates machine code (or a “bitcode” module which can be persisted or sent to another machine) • Machine-code is equivalent to a C-level function-pointer (e.g. a ctypes function)
  • 21. Demo
  • 22. Status and Future • Current master branch mostly due to Jon Riehl (Resilient Science) sponsored by Continuum Analytics, Inc. --- interprets bytecode directly • New devel branch working with AST directly and making rapid progress - Mark Florrison (minivect) - Siu Kwan Lam (pymothoa)
  • 23. Software Stack Future? Plateaus of Code re-use + DSLs SQL R TDPL Matlab Python OBJC C FORTRAN C++ LLVM
  • 24. Join Us! http://numba.github.com/numba

Editor's Notes