-
Notifications
You must be signed in to change notification settings - Fork 33
[Doc] Fix graph doc issues #762
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
3d3327d
address doc CI issues
hughperkins dde771b
[CI] Fold reading-order (no-forward-reference) check into doc-quality
hughperkins aafcc41
[Doc] Document reading-order rule in doc-quality check description
hughperkins 899600e
[CI] Simplify doc-quality RULE 3: drop reworked cap and double-flag note
hughperkins 5f7aeb0
Merge remote-tracking branch 'origin/hp/doc-quality-with-ordering' in…
hughperkins 57f07bd
fix doc ci failures
hughperkins 715d454
Merge branch 'main' into hp/fixup-graph-doc
hughperkins cc8ea8a
doc tewaks for ci
hughperkins 2fc9569
Merge remote-tracking branch 'origin/main' into hp/fixup-graph-doc
hughperkins ee7754c
Apply suggestion from @graphite-app[bot]
hughperkins 1af37b9
Merge branch 'main' into hp/fixup-graph-doc
hughperkins 04f2f0e
address doc CI
hughperkins a1d925b
address doc ci issues
hughperkins 04f1f09
address some comments
hughperkins 1e2e53b
Add Advanced section to graph doc explaining kernel launch latency
hughperkins e323513
Trim python-side latency bullet in graph doc Advanced section
hughperkins e78e40e
Trim c++-side latency bullet in graph doc Advanced section
hughperkins deb8969
Trim gpu/driver-side latency bullet in graph doc Advanced section
hughperkins b6f9732
Use 'launch' instead of undefined 'replay' in graph doc Advanced section
hughperkins 1801688
Add latency hiding section to graph doc Advanced section
hughperkins b192ca8
Reword 'This is why' to 'So' in graph doc latency hiding section
hughperkins b58a08b
Clarify subject in graph doc latency hiding section ('It' -> 'Kernel …
hughperkins 80eb935
Soften claim in graph doc latency hiding section ('directly increases…
hughperkins d634672
Soften unsupported-hardware claim in graph doc graph_do_while section
hughperkins c14a85e
Remove closing summary paragraph from graph doc graph_do_while section
hughperkins cfde9ce
Soften graph_do_while subsection heading in graph doc ('helps' -> 'ca…
hughperkins a0007e8
Unwrap Advanced section paragraphs in graph doc to fix line-wrapping …
hughperkins d128eae
Fix qd.type.NDArray typo to qd.types.NDArray in graph doc
hughperkins 6642def
Replace non-ASCII em-dashes with ASCII hyphens in graph doc
hughperkins 2590b48
Replace deleted em-dash with ASCII hyphen in graph doc caveats
hughperkins e579de6
Merge branch 'main' into hp/fixup-graph-doc
hughperkins 171422b
add links that doc check was compalining missing
hughperkins 5179cce
reference cuda conditional graph nodes
hughperkins 877ea9f
Merge branch 'main' into hp/fixup-graph-doc
hughperkins 523a999
remove fix-it syntax
hughperkins 4d6717f
for real-world use-cases
hughperkins a6613d4
Why using graph_do_while is relevant even without hardware support
hughperkins 1d9f65e
Move general kernel-launch/latency material into new performance.md
hughperkins 8865124
Separate non-launch-latency tools in performance.md
hughperkins 38c8ad1
Clarify graphs do not remove per-call Python overhead in performance.md
hughperkins ddb03e6
Fix contradictory intro claim in performance.md
hughperkins d950487
Merge branch 'main' into hp/fixup-graph-doc
hughperkins cb8bca0
Reject qd.stream_parallel() inside graph=True kernels
hughperkins 2482be3
Link qd.ad.Tape/autodiff in streams.md limitations
hughperkins b25cfef
Merge branch 'main' into hp/fixup-graph-doc
hughperkins 6251c9f
Link graph=True/graphs to graph.md in streams.md limitations
hughperkins ee16ecf
Reword graph return-value restriction to drop confusing "struct"
hughperkins 008566a
Cross-reference launch-latency docs between performance.md and parall…
hughperkins 122102d
Link qd.static to its doc at first use in parallelization.md
hughperkins File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -70,6 +70,7 @@ algorithms | |
| :maxdepth: 1 | ||
| :titlesonly: | ||
|
|
||
| performance | ||
| fastcache | ||
| graph | ||
| streams | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Performance | ||
|
|
||
| This page covers the execution model that the other performance guides build on: what happens when you launch a GPU kernel, where the time goes, and when reducing that time actually speeds up your program. The other pages in this section - graphs, streams, fastcache, and performance dispatch - are performance tools built on this execution model. | ||
|
|
||
| ## What a GPU kernel launch is | ||
|
|
||
| When you call a `@qd.kernel` from Python, the numerical work does not run inline in the calling thread. Instead Quadrants *launches* the work onto the GPU: it hands a compiled kernel plus its arguments to the GPU driver, the driver enqueues it onto a stream (an ordered queue of GPU work), and the launch call returns to the host before the GPU has finished - usually before it has even started. Host and GPU run asynchronously. | ||
|
|
||
| Each top-level `for`-loop in a kernel is a separate *offloaded task*, and each offloaded task becomes one GPU kernel. So a kernel with three top-level for-loops launches three GPU kernels every time you call it. Every launch carries a fixed overhead that is independent of how much data the kernel processes - that per-launch overhead is what we call *kernel launch latency*. When a kernel crunches a lot of data the overhead is negligible; when it does little work, or when you relaunch small kernels many times in a loop, launch latency can dominate the total runtime. | ||
|
|
||
| ## Where kernel launch latency comes from | ||
|
|
||
| It helps to split the latency of a single launch into three parts: | ||
|
|
||
| - **Python side.** Everything that happens in the Python interpreter before control reaches Quadrants' C++ runtime. This is the most expensive of the three per call, and it is paid once per *Python* call - so a Python `while`/`for` loop that calls a kernel N times pays it N times. | ||
| - **C++ side.** Work inside the Quadrants runtime (C++) once control has crossed the boundary. Cheaper than the Python side, but non-zero, and paid per offloaded task. | ||
| - **GPU / driver side.** The GPU driver's own cost to place the kernel on a stream, plus the fixed scheduling latency on the GPU itself before the kernel begins running on the hardware. | ||
|
|
||
| ## Latency hiding | ||
|
|
||
| Because host and GPU run asynchronously, kernel launches overlap with kernel execution: the host can be issuing the next launch while earlier kernels are still running on the GPU. As long as the host issues launches at least as fast as the GPU drains them, the queue never empties, the GPU stays busy, and the launch latency is fully *hidden* behind execution. | ||
|
|
||
| So reducing launch latency does not always improve overall throughput. When each kernel runs long enough that its execution time exceeds the launch overhead, the GPU is the bottleneck and shaving launch latency changes nothing - the launches were already hidden behind execution. | ||
|
|
||
| Kernel launch latency matters when kernels are relatively small. Then the GPU can finish a kernel before the host has issued the next one, so the GPU sits idle waiting for the next launch and the launch latency is *exposed* on the critical path. In that regime, cutting launch latency can directly increase throughput. | ||
|
|
||
| ## Reducing launch latency | ||
|
|
||
| [Graphs](graph.md) are the main tool for reducing launch latency. On backends with hardware graph support, the kernel's whole sequence of GPU tasks is issued as a single graph launch rather than one launch per task, collapsing the per-task C++ and GPU/driver launch overhead. The per-call Python overhead is still paid on every call; to cut that too, move the loop itself into the graph with `graph_do_while` so that many iterations become a single call. | ||
|
|
||
| Independently of graphs, you can also shrink the launch latency itself by reducing the number and complexity of kernel parameters - field arguments are cheaper than ndarray arguments, and global fields incur no parameter-related launch latency. See [Parallelization](parallelization.md#does-gpu-kernel-launch-latency-matter) for these launch-tuning guidelines. | ||
|
|
||
| ## Other performance tools | ||
|
|
||
| The rest of this section covers tools that improve performance in other ways, not by reducing launch latency: | ||
|
|
||
| - [Streams](streams.md) let independent top-level for-loops run concurrently instead of serializing on the default stream. | ||
| - [Fastcache](fastcache.md) reduces the time to load cached kernels when a new Python process starts. | ||
| - [Performance dispatch](perf_dispatch.md) benchmarks multiple implementations of an operation at runtime and picks the fastest. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.