Document Warp extension points#1494
Conversation
Native snippets had outgrown their historical home in the differentiability docs. That made the general C++/CUDA escape hatch difficult for power users to discover outside autodiff use cases. Add an Extending Warp user guide page for native snippets, custom allocators, and custom loggers. Keep differentiability focused on adjoint and replay behavior, add cross-links from related pages, and expand the generated API docs for wp.func_native with safer examples. Signed-off-by: Eric Shi <ershi@nvidia.com>
📝 WalkthroughWalkthroughAdds a new "Extending Warp" user guide describing native functions, custom CUDA allocators, and custom loggers; expands the ChangesExtension Points Guide and Cross-References
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
docs/user_guide/differentiability.rst (1)
675-676: ⚡ Quick winUse explicit keyword arguments for
wp.func_nativesnippets to avoid API-order ambiguity.Given the text says “provide
adj_snippet,” the decorator call is safer/clearer as keyword args (snippet=...,adj_snippet=...) instead of positional arguments.Suggested doc tweak
- `@wp.func_native`(snippet, adj_snippet) + `@wp.func_native`(snippet=snippet, adj_snippet=adj_snippet) def axpy(🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/user_guide/differentiability.rst` around lines 675 - 676, The decorator call for axpy uses positional args which can be ambiguous; change the `@wp.func_native` usage to pass explicit keyword arguments (e.g., snippet=... and adj_snippet=...) so the decorator invocation is unambiguous—update the `@wp.func_native`(...) line above the axpy definition to use snippet= and adj_snippet= named parameters.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@docs/user_guide/differentiability.rst`:
- Around line 675-676: The decorator call for axpy uses positional args which
can be ambiguous; change the `@wp.func_native` usage to pass explicit keyword
arguments (e.g., snippet=... and adj_snippet=...) so the decorator invocation is
unambiguous—update the `@wp.func_native`(...) line above the axpy definition to
use snippet= and adj_snippet= named parameters.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Enterprise
Run ID: 24bc03c1-c570-4231-a7c4-733be99601cd
📒 Files selected for processing (8)
docs/deep_dive/allocators.rstdocs/deep_dive/codegen.rstdocs/index.rstdocs/user_guide/basics.rstdocs/user_guide/debugging.rstdocs/user_guide/differentiability.rstdocs/user_guide/extending_warp.rstwarp/_src/context.py
Greptile SummaryThis PR adds a new "Extending Warp" guide that consolidates previously scattered documentation on
Confidence Score: 5/5Documentation-only change with no runtime code modifications beyond an expanded docstring; safe to merge. All changes are documentation restructuring and a docstring expansion. No logic, APIs, or runtime behaviour is modified. All cross-references point to files that exist in the repo, and the inline code examples in the new page are self-contained and mathematically verified. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[basics.rst] -->|cross-ref: native C++/CUDA| E[extending_warp.rst]
B[differentiability.rst] -->|cross-ref: general func_native syntax| E
C[debugging.rst] -->|cross-ref: wp.Logger / set_logger| E
D[codegen.rst] -->|cross-ref: func_native API| E
F[allocators.rst] -->|cross-ref: Allocator protocol| E
E -->|cross-ref: autodiff details| B
E -->|cross-ref: log levels / debug tools| C
E -->|cross-ref: PyTorch & RMM examples| F
H[context.py] -->|See Also| E
I[index.rst] -->|toctree entry| E
Reviews (4): Last reviewed commit: "Clarify extension and allocator docs" | Re-trigger Greptile |
Review bots noted that two native snippet examples were less clear than they should be. The differentiability example used positional decorator arguments even though the surrounding prose names adj_snippet, and the shared-memory example launched with arr and out without defining them in the same block. Use keyword arguments for adj_snippet examples and make the shared-memory launch snippet define its inputs before launch. This keeps the docs easier to copy and less dependent on decorator argument order. Signed-off-by: Eric Shi <ershi@nvidia.com>
Several extension docs used imprecise terminology around diagnostics, custom allocator scope, and native snippets. The allocator docs also introduced RMM without expanding the acronym, and the native function section only showed CUDA launches despite pure C++ snippets working on CPU kernels. Update the docs to distinguish environment diagnostics from internal logging, spell out RAPIDS Memory Manager, describe allocator routing as current support, and add a CUDA inline PTX example using vabsdiff4 for packed-byte SAD. This keeps the examples practical while documenting the boundary between CPU-compatible C++ snippets and CUDA-only native code. Signed-off-by: Eric Shi <ershi@nvidia.com>
bea13a6 to
398c868
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/deep_dive/allocators.rst`:
- Around line 406-407: The section underline for the heading "RAPIDS Memory
Manager (RMM) Integration" is one character short; update the underline (the row
of ~ characters immediately below that heading in docs/deep_dive/allocators.rst)
so it is at least as long as the heading text (add one more ~ to make it 40
characters) so the reStructuredText title underline matches or exceeds the
heading length.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Enterprise
Run ID: 6579d5fe-1527-4e54-b1bd-da2362eeb29c
📒 Files selected for processing (4)
docs/deep_dive/allocators.rstdocs/user_guide/debugging.rstdocs/user_guide/extending_warp.rstwarp/_src/context.py
✅ Files skipped from review due to trivial changes (3)
- warp/_src/context.py
- docs/user_guide/debugging.rst
- docs/user_guide/extending_warp.rst
| RAPIDS Memory Manager (RMM) Integration | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
There was a problem hiding this comment.
Fix the section underline length.
The underline is 39 characters but the heading "RAPIDS Memory Manager (RMM) Integration" is 40 characters. In reStructuredText, the underline must be at least as long as the heading text.
📝 Proposed fix
RAPIDS Memory Manager (RMM) Integration
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| RAPIDS Memory Manager (RMM) Integration | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
| RAPIDS Memory Manager (RMM) Integration | |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/deep_dive/allocators.rst` around lines 406 - 407, The section underline
for the heading "RAPIDS Memory Manager (RMM) Integration" is one character
short; update the underline (the row of ~ characters immediately below that
heading in docs/deep_dive/allocators.rst) so it is at least as long as the
heading text (add one more ~ to make it 40 characters) so the reStructuredText
title underline matches or exceeds the heading length.
Description
Add a new
Extending Warpuser guide page that makes public extension points easier to discover. The page now covers native C++/CUDA snippets viawp.func_native, custom allocators, custom loggers, and related extension points.The existing differentiability page now keeps only autodiff-specific native snippet guidance and links to the new page for general syntax. Related pages in Basics, Codegen, Allocators, and Debugging now cross-link to the new hub. The generated API docs for
wp.func_nativealso get a fuller docstring with safer examples.Checklist
Test plan
uvx pre-commit run --files docs/index.rst docs/user_guide/extending_warp.rst docs/user_guide/basics.rst docs/user_guide/differentiability.rst docs/deep_dive/allocators.rst docs/user_guide/debugging.rst docs/deep_dive/codegen.rst warp/_src/context.pyWARP_CACHE_ROOT=/tmp/warp-cache-warp-worktree-2-docs WARP_CACHE_PATH=/tmp/warp-cache-warp-worktree-2-docs uv run --extra docs build_docs.py 2>&1 | tee /tmp/build_docs.logrg -n "WARNING|undefined label|unknown document|Title underline too short|Inline emphasis" /tmp/build_docs.logNew feature / enhancement
This is a documentation discoverability enhancement for existing Warp extension APIs.
Summary by CodeRabbit