Skip to content

Commit c23ec73

Browse files
committed
Reorder PyHPC profiling notebooks
1 parent 07bf3cb commit c23ec73

24 files changed

Lines changed: 84 additions & 84 deletions

‎docs/cscs.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ CSCS_EDF="${CSCS_EDF}" \
183183
The driver runs:
184184

185185
- package smoke tests through the normal tutorial entrypoint
186-
- the full notebook ladder, including `03__mpi4py`
186+
- the full notebook ladder, including `06__mpi4py`
187187
- direct `nsys` and `ncu` command-line smoke checks
188188

189-
The PyHPC image builds `mpi4py` against MPICH. Notebook 03 runs local ranks with
189+
The PyHPC image builds `mpi4py` against MPICH. Notebook 06 runs local ranks with
190190
`mpirun.mpich -launcher fork`, avoiding nested use of the host `srun` launcher.
191191

192192
For debugging, the individual commands are below.
@@ -214,7 +214,7 @@ Run the profiling notebooks:
214214
```bash
215215
srun -A "${CSCS_ACCOUNT}" -p normal -t 01:00:00 -N1 -n1 \
216216
--environment="${CSCS_EDF}" \
217-
env ACH_RUN_TESTS=1 ACH_TEST_ARGS="10 or 11 or 12" \
217+
env ACH_RUN_TESTS=1 ACH_TEST_ARGS="03 or 04 or 05" \
218218
/accelerated-computing-hub/brev/entrypoint.bash base
219219
```
220220

‎tutorials/pyhpc/.gitignore‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Artifacts generated when the tutorial is run.
22
#
3-
# SWE ladder (notebooks 04-09):
3+
# SWE ladder (notebooks 07-12):
44
notebooks/build/
55
notebooks/CMakeLists.txt
66
notebooks/swe_step.cpython-*.so
77
notebooks/timings.json
88

9-
# Kernel / asynchrony notebooks (10-12): %%writefile scripts, Nsight
9+
# Kernel / asynchrony notebooks (03-05): %%writefile scripts, Nsight
1010
# profiler reports, the downloaded text corpus, and rendered plots.
1111
# Patterns are applied at the notebooks/ root and under solutions/, since
1212
# executing the solution notebooks (e.g. in CI) writes the same artifacts there.

‎tutorials/pyhpc/README.md‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Brev Launchables of this tutorial should use:
1717

1818
## Notebooks
1919

20-
Each exercise notebook that has a paired solution carries `# TODO:` cells with `...` placeholders; the solution fills them in. The intro/reference notebook (04), the synthesis notebook (09), and the mpi4py walkthrough (03) are complete as written and have no separate solution.
20+
Each exercise notebook that has a paired solution carries `# TODO:` cells with `...` placeholders; the solution fills them in. The intro/reference notebook (07), the synthesis notebook (12), and the mpi4py walkthrough (06) are complete as written and have no separate solution.
2121

2222
### Fundamentals
2323

@@ -27,32 +27,32 @@ Each exercise notebook that has a paired solution carries `# TODO:` cells with `
2727
| 01 | CuPy | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/01__cupy.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/01__cupy__SOLUTION.ipynb) |
2828
| 02 | Power Iteration - CuPy - Memory Spaces | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/02__power_iteration__cupy__memory_spaces.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/02__power_iteration__cupy__memory_spaces__SOLUTION.ipynb) |
2929

30-
### Distributed
30+
### Kernels
3131

3232
| # | Notebook | Link | Solution |
3333
|---|----------|------|----------|
34-
| 03 | mpi4py | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/03__mpi4py.ipynb) | |
35-
36-
### Programming models and interoperability
34+
| 03 | Power Iteration - CuPy - Asynchrony | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/03__power_iteration__cupy__asynchrony.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/03__power_iteration__cupy__asynchrony__SOLUTION.ipynb) |
35+
| 04 | Copy - Kernel Authoring | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/04__copy__kernel_authoring.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/04__copy__kernel_authoring__SOLUTION.ipynb) |
36+
| 05 | Book Histogram - Kernel Authoring | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/05__book_histogram__kernel_authoring.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/05__book_histogram__kernel_authoring__SOLUTION.ipynb) |
3737

38-
Notebooks 04-09 are the Shallow Water Equations "ladder": an intro plus NumPy baseline, four solvers that each re-implement the same timestep with a different tool, and a synthesis that reads the measured timings and compares them. The synthesis notebook collects the per-tool rows from `timings.json` (written by notebooks 04 to 08) and closes with a matched-precision GPU comparison of the JAX and CppJIT device paths.
38+
### Distributed
3939

4040
| # | Notebook | Link | Solution |
4141
|---|----------|------|----------|
42-
| 04 | SWE - Intro | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/04__swe__intro.ipynb) | |
43-
| 05 | SWE - JAX | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/05__swe__jax.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/05__swe__jax__SOLUTION.ipynb) |
44-
| 06 | SWE - PyOMP | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/06__swe__pyomp.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/06__swe__pyomp__SOLUTION.ipynb) |
45-
| 07 | SWE - nanobind | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/07__swe__nanobind.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/07__swe__nanobind__SOLUTION.ipynb) |
46-
| 08 | SWE - CppJIT - Thrust | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/08__swe__cppjit__thrust.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/08__swe__cppjit__thrust__SOLUTION.ipynb) |
47-
| 09 | SWE - Synthesis | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/09__swe__synthesis.ipynb) | |
42+
| 06 | mpi4py | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/06__mpi4py.ipynb) | |
4843

49-
### Kernels
44+
### Programming models and interoperability
45+
46+
Notebooks 07-12 are the Shallow Water Equations "ladder": an intro plus NumPy baseline, four solvers that each re-implement the same timestep with a different tool, and a synthesis that reads the measured timings and compares them. The synthesis notebook collects the per-tool rows from `timings.json` (written by notebooks 07 to 11) and closes with a matched-precision GPU comparison of the JAX and CppJIT device paths.
5047

5148
| # | Notebook | Link | Solution |
5249
|---|----------|------|----------|
53-
| 10 | Power Iteration - CuPy - Asynchrony | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/10__power_iteration__cupy__asynchrony.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/10__power_iteration__cupy__asynchrony__SOLUTION.ipynb) |
54-
| 11 | Copy - Kernel Authoring | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/11__copy__kernel_authoring.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/11__copy__kernel_authoring__SOLUTION.ipynb) |
55-
| 12 | Book Histogram - Kernel Authoring | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/12__book_histogram__kernel_authoring.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/12__book_histogram__kernel_authoring__SOLUTION.ipynb) |
50+
| 07 | SWE - Intro | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/07__swe__intro.ipynb) | |
51+
| 08 | SWE - JAX | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/08__swe__jax.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/08__swe__jax__SOLUTION.ipynb) |
52+
| 09 | SWE - PyOMP | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/09__swe__pyomp.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/09__swe__pyomp__SOLUTION.ipynb) |
53+
| 10 | SWE - nanobind | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/10__swe__nanobind.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/10__swe__nanobind__SOLUTION.ipynb) |
54+
| 11 | SWE - CppJIT - Thrust | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/11__swe__cppjit__thrust.ipynb) | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/solutions/11__swe__cppjit__thrust__SOLUTION.ipynb) |
55+
| 12 | SWE - Synthesis | [![](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/NVIDIA/accelerated-computing-hub/blob/main/tutorials/pyhpc/notebooks/12__swe__synthesis.ipynb) | |
5656

5757
### Python/C++ interoperability
5858

@@ -64,7 +64,7 @@ A standalone comparison of several ways to call C and C++ from Python (ctypes, c
6464

6565
## The Shallow Water Equations problem
6666

67-
A 1D shallow-water bump pulse: a small mound of water at rest splits into two outgoing wave packets. Two conserved fields (`h`, `hu`) advance under a forward-Euler step. This PDE is small enough to read in full while exhibiting nonlinearity, and a fixed number of steps from the initial condition gives a result we can compare across tools. The full specification is in [`04__swe__intro.ipynb`](./notebooks/04__swe__intro.ipynb).
67+
A 1D shallow-water bump pulse: a small mound of water at rest splits into two outgoing wave packets. Two conserved fields (`h`, `hu`) advance under a forward-Euler step. This PDE is small enough to read in full while exhibiting nonlinearity, and a fixed number of steps from the initial condition gives a result we can compare across tools. The full specification is in [`07__swe__intro.ipynb`](./notebooks/07__swe__intro.ipynb).
6868

6969
## Running
7070

@@ -76,8 +76,8 @@ Locally, with an NVIDIA GPU and a CUDA-13-capable driver:
7676
docker compose -f tutorials/pyhpc/brev/docker-compose.yml up
7777
```
7878

79-
Then open JupyterLab on port 8888. The notebooks are self-contained and can be run in any order, with one exception: the Shallow Water Equations ladder writes `timings.json` as you run notebooks 04 to 08, so run those before the synthesis notebook (09).
79+
Then open JupyterLab on port 8888. The notebooks are self-contained and can be run in any order, with one exception: the Shallow Water Equations ladder writes `timings.json` as you run notebooks 07 to 11, so run those before the synthesis notebook (12).
8080

8181
## CppJIT toolchain
8282

83-
Notebook 08 uses CppJIT to automatically bind our Python runtime with CUDA C++, using the clang-repl C++ interpreter and [CppInterOp](https://github.com/compiler-research/CppInterOp). This is currently source built in the [Docker image](./brev/dockerfile) and not a standard `pip install`, so this will only run in the tutorial image. [CppJIT](https://github.com/compiler-research/CppJIT) is the successor to the [cppyy](https://cppyy.readthedocs.io/) automatic bindings tool, and no official CppJIT release is published on PyPI yet (beta release planned for end of summer 2026).
83+
Notebook 11 uses CppJIT to automatically bind our Python runtime with CUDA C++, using the clang-repl C++ interpreter and [CppInterOp](https://github.com/compiler-research/CppInterOp). This is currently source built in the [Docker image](./brev/dockerfile) and not a standard `pip install`, so this will only run in the tutorial image. [CppJIT](https://github.com/compiler-research/CppJIT) is the successor to the [cppyy](https://cppyy.readthedocs.io/) automatic bindings tool, and no official CppJIT release is published on PyPI yet (beta release planned for end of summer 2026).

‎tutorials/pyhpc/brev/requirements.txt‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ jupyter-dark-detect == 0.1.0
1212
nbformat == 5.10.4
1313
nbconvert == 7.17.1
1414

15-
# Programming models and interop (notebooks 04-09: the SWE ladder)
15+
# Programming models and interop (notebooks 07-12: the SWE ladder)
1616
jax[cuda13] == 0.10.0
1717
pyomp == 0.5.1
1818
nanobind == 2.12.0
1919
pybind11 == 3.0.4
2020

21-
# CuPy and CUDA kernels (notebooks 00-02, 10-12: ported accelerated-python exercises)
21+
# CuPy and CUDA kernels (notebooks 00-05: ported accelerated-python exercises)
2222
cupy-cuda13x == 13.6.0
2323
numba-cuda[cu13] == 0.28.2
2424
cuda-cccl[test-cu13] == 0.4.5
2525

26-
# NVIDIA developer tools (notebooks 10-12: Nsight Systems / Nsight Compute profiling)
26+
# NVIDIA developer tools (notebooks 03-05: Nsight Systems / Nsight Compute profiling)
2727
nvtx == 0.2.14
2828
nsightful[notebook] @ git+https://github.com/brycelelbach/nsightful.git@454dfa5124ebea193f64302058b327f2034ccd8e
2929

30-
# Distributed computing (notebook 03: mpi4py)
30+
# Distributed computing (notebook 06: mpi4py)
3131
mpi4py == 4.1.1
3232

3333
# Python/C++ Interop (notebook 13)

tutorials/pyhpc/notebooks/10__power_iteration__cupy__asynchrony.ipynb renamed to tutorials/pyhpc/notebooks/03__power_iteration__cupy__asynchrony.ipynb

File renamed without changes.

tutorials/pyhpc/notebooks/11__copy__kernel_authoring.ipynb renamed to tutorials/pyhpc/notebooks/04__copy__kernel_authoring.ipynb

File renamed without changes.

tutorials/pyhpc/notebooks/12__book_histogram__kernel_authoring.ipynb renamed to tutorials/pyhpc/notebooks/05__book_histogram__kernel_authoring.ipynb

File renamed without changes.
File renamed without changes.

tutorials/pyhpc/notebooks/04__swe__intro.ipynb renamed to tutorials/pyhpc/notebooks/07__swe__intro.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,12 @@
440440
"\n",
441441
"| NB | Tool | Programming-model hook |\n",
442442
"|---|---|---|\n",
443-
"| 05 | **JAX** | JIT compilation + whole-loop fusion offloaded to device |\n",
444-
"| 06 | **PyOMP** | OpenMP parallelisation model in Python |\n",
445-
"| 07 | **nanobind** | Handwritten Python bindings for compiled C++ kernels |\n",
446-
"| 08 | **CppJIT** | JIT compiled C++ with automatic bindings |\n",
443+
"| 08 | **JAX** | JIT compilation + whole-loop fusion offloaded to device |\n",
444+
"| 09 | **PyOMP** | OpenMP parallelisation model in Python |\n",
445+
"| 10 | **nanobind** | Handwritten Python bindings for compiled C++ kernels |\n",
446+
"| 11 | **CppJIT** | JIT compiled C++ with automatic bindings |\n",
447447
"\n",
448-
"We end with `09__swe__synthesis.ipynb`: a decision matrix and the achieved-throughput plot across the different notebooks in `timings.json`."
448+
"We end with `12__swe__synthesis.ipynb`: a decision matrix and the achieved-throughput plot across the different notebooks in `timings.json`."
449449
]
450450
},
451451
{
@@ -455,7 +455,7 @@
455455
"source": [
456456
"### <a id=\"sec10\"></a>10. How to read these notebooks\n",
457457
"\n",
458-
"Each numbered exercise (05-08) comes as two files:\n",
458+
"Each numbered exercise (08-11) comes as two files:\n",
459459
"\n",
460460
"- `NN__topic__subtopic.ipynb`: the primary notebook we run live during the tutorial, with `# TODO:` cells whose body is a `...` placeholder.\n",
461461
"- `solutions/NN__topic__subtopic__SOLUTION.ipynb`: notebooks complete with solution, for self-paced review.\n",
@@ -465,7 +465,7 @@
465465
"- A **Quick Docs** sub-block precedes each TODO cell, listing the key APIs you need.\n",
466466
"- Optional **`# BONUS TASK:`** cells explore deeper solutions if you have time.\n",
467467
"\n",
468-
"With the NumPy baseline in hand, let's continue with JAX: `05__swe__jax.ipynb`"
468+
"With the NumPy baseline in hand, let's continue with JAX: `08__swe__jax.ipynb`"
469469
]
470470
}
471471
],

tutorials/pyhpc/notebooks/05__swe__jax.ipynb renamed to tutorials/pyhpc/notebooks/08__swe__jax.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"source": [
8686
"### <a id=\"sec2\"></a>2. The step as a pure function\n",
8787
"\n",
88-
"Let's look at the same operation shape as notebook 04, expressed in JAX:\n",
88+
"Let's look at the same operation shape as notebook 07, expressed in JAX:\n",
8989
"\n",
9090
"- **Read** — `h[:-1]`, `h[1:]` for interface states, same as NumPy-style slicing.\n",
9191
"- **Compute** — Rusanov formula unchanged: `F_h = 0.5*(huL+huR) - 0.5*a*(hR-hL)`.\n",

0 commit comments

Comments
 (0)