Add Warp tutorial notebooks#185
Conversation
|
👋 Thank you for your contribution! This pull request is from a forked repository so GitHub Actions will not be able to run CI. A maintainer will review your changes shortly and manually trigger the CI. @maintainers Please review this PR when you have a chance and follow the instructions in the CONTRIBUTING.md file to trigger the CI. |
|
@jnbntz @tscudiero can you please add one of the people from your team and @shi-eric as the reviewers for this PR? |
0482240 to
92834aa
Compare
|
ok to test |
|
/ok to test 92834aa Just to confirm, are you adding the images with Git LFS? That's required to keep the repo size from getting very large. This looks nice at a glance - can you add the docker compose definitions for this tutorial? You should be able to take the config for the accelerated Python tutorial as a starting point. |
92834aa to
98687ca
Compare
|
/ok to test 92834aa |
@brycelelbach, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
|
/ok to test 98687ca |
|
@nv-snidhan can you please sign your commits? |
❌ Git Signature Check FailedFound 10 unsigned commit(s): Unsigned commits
How to fix:
|
98687ca to
fa6854e
Compare
Yes, we are using Git LFS for images
Done
Done |
1d65fe5 to
f2ff889
Compare
…ook. Signed-off-by: snidhan <snidhan@nvidia.com>
The notebook previously opened with a particle simulation before introducing kernels and arrays, which made the chapter feel more like a reference pass than a guided introduction. It also aliased Warp float64 as double and included a large scalar type table in the array section. Reframe the overview around the core programming model, add the galaxy teaser, remove the redundant particle walkthrough, and start the kernel section with a Celsius-to-Fahrenheit elementwise example. The deeper topics are now grouped after the core model, and explicit double precision examples use wp.float64 directly. Signed-off-by: snidhan <snidhan@nvidia.com>
The Warp notebooks no longer fit the Accelerated Python User Guide chapter layout. Keeping them under that path also forced chapter-based file names and image directories that are awkward for future tutorial notebooks. Move the Warp notebooks into tutorials/warp with numbered notebook names and notebook-specific image directories. Add a tutorial README with local and Colab links, and remove the old Chapter 12 entries from the Accelerated Python notebook index. Signed-off-by: snidhan <snidhan@nvidia.com>
The Warp tutorial area previously contained only the introductory and Ising notebooks. The Navier-Stokes classroom materials lived outside this repository, so the tutorial README could not point readers to the next solver-focused lessons. Add the Navier-Stokes and differentiable Navier-Stokes notebooks under tutorials/warp, along with their helper modules and image assets. Update local asset imports and documentation links so the notebooks work from their new home, and track copied binary assets through Git LFS. Signed-off-by: snidhan <snidhan@nvidia.com>
The Warp notebook directory had helper modules mixed directly with the notebooks. That made the tutorial area harder to scan and left little room for more notebook-specific support code. Move the helpers into importable subpackages under notebooks/helpers, split by notebook family. Update notebook imports and prose references to the new package paths while preserving the existing helper implementations. Signed-off-by: snidhan <snidhan@nvidia.com>
The intro notebook still showed CUDA-version-specific conda selector examples for Warp. Those examples age quickly and can make the setup section look stale even when the generic package install is enough. Replace the conda examples with the current generic conda-forge install form and keep PyPI as the primary installation path. Also simplify the nightly package wording while preserving the warning that nightlies are less tested than release packages. Signed-off-by: snidhan <snidhan@nvidia.com>
The Navier-Stokes Warp notebooks still carried course-specific header markup from the original GTC material, and they did not include the copyright block used by the other tutorial notebooks. They now start with the 2026 NVIDIA copyright and license header and use plain markdown titles that match the intro notebook style. Signed-off-by: snidhan <snidhan@nvidia.com>
Recent Warp notebook edits were split across several small cleanup commits. Keeping them separate made the branch history noisy without adding useful review boundaries. Combine the documentation wording, setup-cell consistency, and notebook polish into one commit while preserving the final notebook contents exactly. Earlier commits that add and organize the tutorials remain separate. Signed-off-by: snidhan <snidhan@nvidia.com>
Signed-off-by: snidhan <snidhan@nvidia.com>
Signed-off-by: snidhan <snidhan@nvidia.com>
aacdde6 to
4bf5c75
Compare
|
This affects the numerical validation, not just the plot. With the default test parameters, the numerical and analytical results have a correlation of approximately Please preserve the kernel's axis convention here with |
|
Running cd tutorials/warp/notebooks/helpers/differentiable_navier_stokes
python logo_solver.pyThe command raises: The default target is first resolved relative to the current directory. The fallback then joins the same relative target beneath the script directory, but the bundled image is located beneath Could the bundled default be constructed relative to the notebooks directory instead? notebooks_dir = Path(__file__).resolve().parents[2]
default_target = (
notebooks_dir
/ "images"
/ "differentiable-navier-stokes"
/ "gtc_logo.png"
)This would make the default invocation independent of the working directory while allowing user-provided relative |
|
The constructor documents self.use_cuda_graph = use_cuda_graph and wp.get_device().is_cudaOn a CUDA device, passing Could device_is_cuda = wp.get_device().is_cuda
self.use_cuda_graph = (
device_is_cuda
if use_cuda_graph is None
else use_cuda_graph and device_is_cuda
)If automatic detection is not intended, the alternative would be to remove |
4bf5c75 to
25567bb
Compare
|
|
/ok to test 25567bb |
robobryce
left a comment
There was a problem hiding this comment.
I focused this review on consistency with ACH's documented tutorial contract, then exercised the notebooks on a B200 with warp-lang 1.14.0.
The main consistency items should be addressed before merge:
-
Please align the new tutorial with
docs/brev_launchable_architecture.md:- Rename the notebooks to the documented
NN__descriptive_name.ipynbform and update the README, Compose URL, and cross-links. Notebook 04 should also drop01./03.from displayed link text, since ACH explicitly keeps sequence numbers out of notebook bodies. - Notebook 03 is an exercise notebook with four TODO cells, but it has no executable
__SOLUTIONcounterpart. - Add the standard
tutorials/warp/brev/test.bashplus a meaningful notebook/helper smoke test. The tutorial is auto-discovered and its image build is green, but the standard test path currently has no Warp test entrypoint, so none of this content is exercised.
- Rename the notebooks to the documented
-
Commits
92e00c2andffa658dare missingSigned-off-bytrailers.CONTRIBUTING.mdrequires both DCO sign-off and a cryptographic signature on every commit; the green signature check only covers the latter.
There are also several runtime/content issues to fix:
- Notebook 01 has seven uncaught expected-error cells, so normal automated execution cannot finish it. Please catch/assert the expected exceptions or render invalid examples as non-executable snippets. In particular, the device-access example sets the process-global
wp.config.launch_array_access_modetoCHECKEDand never restores the default, so subsequent launches and the fusion benchmark run under altered global state. - The in-place transpose lesson in notebook 03 is nondeterministic. On B200/Warp 1.14 its validator printed
PASSED: all 65536 elements match expected transpose, immediately before prose claiming the result is incorrect. The kernel is genuinely racy, but a value comparison can pass by accident; explain that explicitly and do not rely on a failed plot. More broadly, the diffusion/advection validators compute and discardmax_error, FFT error is never checked, and transpose failures only print. The solution test should enforce tolerances. - Both notebook 04 snapshot loops mix states across optimizer steps:
train_step()updates the optimized input before returning, while the saved trajectory/loss still corresponds to the pre-update input. Capture the input before the update, or re-run the forward pass after it, so each GIF frame depicts one consistent state. - Keep notebook-local media paths relative. Anonymous Colab testing confirmed that relative raster and SVG paths resolve against the exact source commit. The new hardcoded
NVIDIA/.../mainURLs are broken in the PR/forks until assets exist upstream and make old tags/event branches display media from a different revision; relative paths also match the sibling tutorials.
Lower-priority consistency follow-ups:
- Notebook 04 calls itself a differentiable continuation of notebook 03, but silently changes Forward Euler/512²/
DT=0.0005to hidden SSP-RK3 helpers with different grid sizes andDT=0.001. Please introduce and justify those changes, or isolate autodiff changes on the solver that was just taught. - In notebook 02, the Python baseline and checkerboard run both write
images/ising-model/256x256_2.269.gif, so the latter overwrites the former. Use method-specific names under anoutputs/directory, as notebook 04 does. - Leave a relocation link in the old Accelerated Python index rather than deleting the Chapter 12 rows without a pointer.
What passed: canonical notebook formatting, Git LFS checks, Compose parsing, helper imports/compilation, notebook 02, both notebook 04 optimizations, and notebook 03 end-to-end after applying its documented answers. The Warp image build also completed successfully.
Add the per-tutorial brev/ config (dockerfile, docker-compose.yml, requirements.txt) so the Warp tutorial builds and serves on Brev, matching the self-registering pattern the other tutorials use. Link the compose file from the root README table and add a Brev/Colab deploy section to the tutorial README. Trim the dependency set to what the notebooks and helpers actually import: warp-lang, numpy, scipy, matplotlib, ipympl, Pillow, plus the Jupyter stack. Drop RAPIDS, cupy, cuda-python, and MPI versus accelerated-python; none are used here. Omit the nsys/ncu profiling services since the notebooks embed pre-captured Nsight images rather than running profilers live. Do not install PyTorch. Notebook 04 references the Warp <-> PyTorch autograd bridge only in prose; no notebook or helper imports torch in executable code. Verified notebook 04 runs error-free without it. This keeps the shipped image about 5 GB smaller (9.85 GB vs 14.7 GB). Signed-off-by: snidhan <snidhan@nvidia.com>
Colab's markdown math renderer does not support the calligraphic
\mathcal font, so every equation using \mathcal{F} or \mathcal{L}
displayed as raw LaTeX text. Replace \mathcal{F} -> \mathbf{F} and
\mathcal{L} -> \mathbf{L} (\mathbf renders in Colab and keeps the
operator's visual weight). Also single-line the two display-math
blocks whose opening $$ sat alone on a line, and drop \! / \bigl in
the optimal-perturbation objective, for broader renderer
compatibility. No change to the mathematics.
Set OPTIMIZER_STEPS to 100 in Example 1 to match Example 2.
Signed-off-by: snidhan <snidhan@nvidia.com>
Make the GPU check in 02_ising_model raise RuntimeError when no CUDA device is present, matching notebooks 01, 03, and 04. The old code only printed a warning and continued, so a CPU-only Colab runtime would crash mid-kernel instead of failing fast with a clear message. Point the three SVG diagrams in 01_intro_to_warp at absolute raw.githubusercontent.com/.../main/ URLs instead of relative paths. That notebook has no Colab clone cell, so the relative paths did not resolve on Colab; SVGs are not LFS-tracked, so the raw host (not the media LFS host) is correct. Signed-off-by: snidhan <snidhan@nvidia.com>
25567bb to
8f6d3e3
Compare
I renamed all four notebooks, updated the README, Colab URLs, Compose launch path, and notebook cross-links, and removed sequence numbers from notebook 04's displayed link text. A repository check confirms that no old filename remains.
Notebook 03 is a self-contained guided tutorial with four inline collapsible solutions, not a separate exercise and answer pair. Creating a
I added
I rewrote those commits as
The error cells intentionally expose Warp's native diagnostics, so catching them or converting them to snippets would weaken the lesson. I retained those intentional errors and restored
The prose now states that the racy in-place kernel may pass or fail and asks learners to rerun it. The fixed out-of-place transpose raises on any mismatch; the other validators remain instructional diagnostics rather than a generalized test suite.
Both loops now copy the optimized input on snapshot iterations before
I converted notebook 01's three ordinary-Git SVG references to relative
Notebook 04 is a conceptual continuation, not a line-for-line differentiation of notebook 03. Its SSP-RK3,
The three animation cells now use method-specific
The repository has no internal links to this legacy index, and other relocated tutorial folders do not leave relocation notes. The canonical root index already links the Warp tutorial; a note here would not repair bookmarks or Colab URLs that target the deleted notebook paths, so I have not added one. |
Summary
This PR moves the Warp material out of the Accelerated Python guide into a dedicated
tutorials/warptutorial and expands it from two chapter notebooks into a four-notebook sequence.Changes
tutorials/warp/notebooks/01_intro_to_warp.ipynbandtutorials/warp/notebooks/02_ising_model.ipynb, remove the old Accelerated Python README entries, and addtutorials/warp/README.mdwith notebook descriptions and Colab links.wp.arraydata movement,wp.launch,wp.vec3particle state, fused versus non-fused kernel structure, and result visualization.wp.Tape(), usingwarp.optim, and interoperability with PyTorch.