Skip to content

Commit ad3d7db

Browse files
committed
Add sponsor project: Numba and llvmlite in the browser
1 parent 145fcf2 commit ad3d7db

4 files changed

Lines changed: 108 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
2+
import GetAQuotePage from '@site/src/components/fundable/GetAQuotePage';
3+
4+
export default function FundablePage() {
5+
const { siteConfig } = useDocusaurusContext();
6+
return (
7+
<GetAQuotePage/>
8+
);
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
2+
import LargeProjectCardPage from '@site/src/components/fundable/LargeProjectCardPage';
3+
4+
export default function FundablePage() {
5+
const { siteConfig } = useDocusaurusContext();
6+
return (
7+
<LargeProjectCardPage/>
8+
);
9+
}

src/pages/sponsor/_projectsDetails.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Decimal32InArrowCppMD from "@site/src/pages/sponsor/descriptions/Decimal3
1010
import Float16InArrowCppMD from "@site/src/pages/sponsor/descriptions/Float16InArrowCpp.md"
1111
import RunEndEncodedInArrowCppMD from "@site/src/pages/sponsor/descriptions/RunEndEncodedInArrowCpp.md"
1212
import ParquetNullOptimizationsMD from "@site/src/pages/sponsor/descriptions/ParquetNullOptimizations.md"
13+
import NumbaInWasmMD from "@site/src/pages/sponsor/descriptions/NumbaInWasm.md"
1314

1415
export const fundableProjectsDetails = {
1516
jupyterEcosystem: [
@@ -50,6 +51,18 @@ export const fundableProjectsDetails = {
5051
currentFundingPercentage: 0,
5152
repoLink: "https://github.com/geojupyter/jupytergis"
5253
},
54+
{
55+
category: "Jupyter Ecosystem",
56+
title: "Numba and llvmlite in the browser",
57+
pageName: "NumbaInWasm",
58+
shortDescription: "Numba, the standard JIT compiler for numerical Python, cannot run in Pyodide or emscripten-forge today. Its llvmlite backend relies on MCJIT, which WebAssembly does not allow. We have working demos of llvmlite and Numba scalar @jit in the browser. This proof-of-concept effort will resolve the remaining issues to make Numba work generally and initiate upstreaming of the patches.",
59+
description: NumbaInWasmMD,
60+
price: "TBD",
61+
maxNbOfFunders: 1,
62+
currentNbOfFunders: 0,
63+
currentFundingPercentage: 0,
64+
repoLink: "https://github.com/numba/llvmlite"
65+
},
5366
],
5467
packageManagement: [
5568
{
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#### Overview
2+
3+
[Numba](https://numba.pydata.org/) is the standard
4+
just-in-time (JIT) compiler for numerical Python, widely used
5+
across the scientific stack to accelerate compute-heavy code.
6+
[Pyodide](https://pyodide.org/) brings CPython to the browser
7+
through WebAssembly and powers JupyterLite, while
8+
[emscripten-forge](https://github.com/emscripten-forge)
9+
provides a conda-based package distribution for the same
10+
target. Today, Numba cannot run in either environment.
11+
12+
We propose to make Numba and its JIT backend,
13+
[llvmlite](https://github.com/numba/llvmlite),
14+
browser-compatible using WebAssembly, and thus enabling
15+
Pyodide and emscripten-forge users to JIT-compile numerical
16+
code just like they do on a native CPython interpreter.
17+
18+
#### Why Numba in the Browser Matters
19+
20+
In a native CPython environment, many paths exist to make
21+
numerical Python fast: Numba's JIT compilation,
22+
multiprocessing, native C extensions, or offloading to a GPU.
23+
In the browser, multithreading/processing and GPU access are
24+
mostly unavailable, and shipping pre-compiled native
25+
extensions for everything is impractical. In addition, the
26+
overhead of the Python interpreter is larger in the browser
27+
and many existing libraries use Numba, sometimes as hard
28+
requirements. JIT compilation is therefore an interesting
29+
route to improved performance in a fully client-side,
30+
browser-based Python environment.
31+
32+
#### Current Progress
33+
34+
We have already patched llvmlite and demonstrated that it runs
35+
in the browser including compilation and execution of the WASM
36+
code it generates. A live demo is available at
37+
https://notebook.link/@anutosh491/llvmlite.
38+
39+
We also have a working demo of Numba's `@jit` decorator
40+
operating on scalar functions in the browser. However, several
41+
issues have been identified that must be overcome to make
42+
Numba work generally (e.g. with arrays). These likely include
43+
WebAssembly's lack of writable-and-executable memory pages
44+
(which rules out MCJIT), unsupported atomic instructions
45+
without shared memory, variadic C calls that cannot be lowered
46+
to WASM, and linkage incompatibilities in the LLVM WASM PIC
47+
backend. But these seem surmountable based on our experience.
48+
49+
#### Why QuantStack
50+
51+
QuantStack is uniquely positioned to deliver this work. We
52+
have shipped several JIT and WebAssembly projects in the
53+
scientific Python ecosystem, including
54+
[xeus-cpp](https://github.com/jupyter-xeus/xeus-cpp), a C++
55+
interpreter running in the browser via Clang and LLVM compiled
56+
to WebAssembly. Our team also includes Numba core developers,
57+
giving us a direct upstream relationship.
58+
59+
#### Proposed Work
60+
61+
The goal of this project is to deliver:
62+
63+
- upstream llvmlite compatibility with browser environments,
64+
based on our existing patches.
65+
- build a proof of concept for general Numba use in the browser to
66+
- demonstrate, ideally all of Numba, or at least a large part of it, in the browser
67+
- demonstrate the ability to run libraries that depend on it (such as pytensor/pymc) in the browser
68+
- gather the changes required to upstream
69+
- upstream the required changes to Numba
70+
71+
Note that this is a proof of concept effort, we will advance
72+
incrementally, deliver sub-parts, and adjust the plan based
73+
on new learnings.
74+
75+
##### Are you interested in this project? Either entirely or
76+
partially, contact us for more information on how to help us
77+
fund it.

0 commit comments

Comments
 (0)