ZMC2019 commited on
Commit
3938b28
·
verified ·
1 Parent(s): 56fccf8

agent/: cite and fetch NVIDIA's official docs (not redistributable)

Browse files

Adds agent/ref/official-docs.md and agent/tools/fetch_nvidia_docs.sh.

NVIDIA's CUDA/PTX documentation is copyrighted and cannot be redistributed here: the CUDA EULA distributes only the runtime libraries enumerated in its Attachment A, which contains no documentation, and separately forbids making the SDK subject to a licence requiring it be redistributable at no charge. So this ships an index, a citation, and a fetcher -- each user downloads their own copy direct from NVIDIA under NVIDIA's terms.

The fetcher matches docs to the toolkit: docs.nvidia.com serves the newest CUDA, but CUDA 12.8 ships PTX ISA 8.7 rather than the 9.3 now published. Verified live: 8/8 documents fetch, 6 with PDFs.

agent/README.md CHANGED
@@ -43,6 +43,7 @@ faster", "implement a fused attention kernel", or "solve this KBench task".
43
  | `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, `cuda::pipeline`, cooperative groups, clusters/DSMEM, host-side TMA descriptors, build and debug flags |
44
  | `ref/triton.md` | the Triton 3.6 API surface, launch knobs, idioms, and where it caps out |
45
  | `ref/cute-cutlass.md` | CuTe layout algebra, swizzles, atoms, and where CUTLASS lives in the image |
 
46
 
47
  **These are verified, not recalled.** Every instruction and API was compiled with the container's own
48
  `nvcc` on `sm_90a` / CUDA 12.8: 39/41 PTX instructions assemble (the two that do not are recorded —
@@ -70,6 +71,12 @@ in `ref/triton.md`.
70
  - **`check_toolchain.py`** — re-derives every table in `ref/` by compiling on the machine you are
71
  actually on. The docs were verified on sm_90a / CUDA 12.8; on a different GPU or toolkit some rows
72
  change, and this tool wins over the docs.
 
 
 
 
 
 
73
  - **`ledger.md`** — one row per variant. The column that matters records whether an abandoned variant
74
  was *slower* or merely *broken*; dropping a good optimization over a fixable bug is the most common
75
  way to leave 2x on the table.
 
43
  | `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, `cuda::pipeline`, cooperative groups, clusters/DSMEM, host-side TMA descriptors, build and debug flags |
44
  | `ref/triton.md` | the Triton 3.6 API surface, launch knobs, idioms, and where it caps out |
45
  | `ref/cute-cutlass.md` | CuTe layout algebra, swizzles, atoms, and where CUTLASS lives in the image |
46
+ | `ref/official-docs.md` | index of NVIDIA's own guides — which answers which question, version matching, and the licence position |
47
 
48
  **These are verified, not recalled.** Every instruction and API was compiled with the container's own
49
  `nvcc` on `sm_90a` / CUDA 12.8: 39/41 PTX instructions assemble (the two that do not are recorded —
 
71
  - **`check_toolchain.py`** — re-derives every table in `ref/` by compiling on the machine you are
72
  actually on. The docs were verified on sm_90a / CUDA 12.8; on a different GPU or toolkit some rows
73
  change, and this tool wins over the docs.
74
+ - **`fetch_nvidia_docs.sh`** — downloads NVIDIA's official CUDA/PTX guides for offline use. They are
75
+ **not bundled here**: NVIDIA's documentation is copyrighted and the CUDA EULA distributes only the
76
+ runtime libraries listed in its Attachment A, which does not include documentation. You fetch your own
77
+ copy under NVIDIA's terms. It auto-matches your CUDA version — the live docs always serve the newest
78
+ CUDA, and CUDA 12.8 wants PTX ISA 8.7, not the 9.3 currently published. Run it in a Dockerfile
79
+ `RUN` step to have the guides available inside an offline container.
80
  - **`ledger.md`** — one row per variant. The column that matters records whether an abandoned variant
81
  was *slower* or merely *broken*; dropping a good optimization over a fixable bug is the most common
82
  way to leave 2x on the table.
agent/SKILL.md CHANGED
@@ -20,6 +20,7 @@ as you hit the corresponding phase. Tools are in `tools/`.
20
  | `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, pipelines, cooperative groups, clusters, TMA descriptors, build flags |
21
  | `ref/triton.md` | Triton 3.6 API surface, launch knobs, idioms, and the traps |
22
  | `ref/cute-cutlass.md` | CuTe layout algebra and where CUTLASS lives in the image |
 
23
 
24
  Every instruction and API in `ref/` was verified by compiling it on the container toolchain (sm_90a,
25
  CUDA 12.8) — but **you may not be on that machine**. Run `python3 tools/check_toolchain.py` to
 
20
  | `ref/cuda-cpp.md` | CUDA C++: opt-in shared memory, pipelines, cooperative groups, clusters, TMA descriptors, build flags |
21
  | `ref/triton.md` | Triton 3.6 API surface, launch knobs, idioms, and the traps |
22
  | `ref/cute-cutlass.md` | CuTe layout algebra and where CUTLASS lives in the image |
23
+ | `ref/official-docs.md` | NVIDIA's own guides: which one answers which question, and how to fetch them |
24
 
25
  Every instruction and API in `ref/` was verified by compiling it on the container toolchain (sm_90a,
26
  CUDA 12.8) — but **you may not be on that machine**. Run `python3 tools/check_toolchain.py` to
agent/ref/official-docs.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NVIDIA official documentation — index and citation
2
+
3
+ The authoritative sources. This file **links and cites**; it does not reproduce them.
4
+
5
+ ## Licence — why the documents are not in this repo
6
+
7
+ > © NVIDIA Corporation. All rights reserved.
8
+ > CUDA EULA: <https://docs.nvidia.com/cuda/eula/>
9
+
10
+ NVIDIA's documentation is copyrighted and **not redistributable**. The CUDA EULA distributes only the
11
+ files enumerated in its **Attachment A** — runtime libraries such as `libcudart.so`, `cufft.dll` — and
12
+ documentation does not appear there. §1.2.5 separately prohibits using the SDK in a way that would make
13
+ it subject to a licence requiring it be "redistributable at no charge", which is what publishing it in
14
+ an open dataset would do. The documents are also no longer shipped inside the toolkit: `$CUDA_HOME/DOCS`
15
+ says so and points at docs.nvidia.com.
16
+
17
+ So: **fetch your own copy**, direct from NVIDIA, under their terms.
18
+
19
+ ```bash
20
+ tools/fetch_nvidia_docs.sh /opt/nvidia-docs # auto-matches your CUDA version
21
+ tools/fetch_nvidia_docs.sh /opt/nvidia-docs 12.8.0 # or pin it
22
+ ```
23
+
24
+ For an offline container, run it at **image build time** — task images have network during `docker
25
+ build` and none at run time:
26
+
27
+ ```dockerfile
28
+ RUN bash fetch_nvidia_docs.sh /opt/nvidia-docs 12.8.0
29
+ ```
30
+
31
+ ## Match the version to your toolkit
32
+
33
+ `docs.nvidia.com/cuda/` always serves the **newest** CUDA. An instruction documented there may not
34
+ assemble on an older `ptxas`. Archived versions live at
35
+ `https://docs.nvidia.com/cuda/archive/<version>/…`.
36
+
37
+ | your toolkit | PTX ISA version |
38
+ |---|---|
39
+ | CUDA 12.8 (the KBench containers) | **8.7** |
40
+ | current live docs at time of writing | 9.3 |
41
+
42
+ Reading 9.3 while compiling with 12.8 is a real way to lose an hour to *"Instruction not supported on
43
+ target"*.
44
+
45
+ ## Which document answers which question
46
+
47
+ | question | document |
48
+ |---|---|
49
+ | What does this CUDA C++ construct mean? Memory model, `__syncthreads`, streams, unified memory, clusters, TMA | **CUDA C++ Programming Guide** — <https://docs.nvidia.com/cuda/cuda-c-programming-guide/> |
50
+ | Is my access pattern coalesced? How should I think about occupancy vs latency hiding? | **CUDA C++ Best Practices Guide** — <https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/> |
51
+ | Exact syntax/semantics of a PTX instruction, its modifiers and which `.target` it needs | **PTX ISA** — <https://docs.nvidia.com/cuda/parallel-thread-execution/> |
52
+ | How do I write inline PTX, and what do the operand constraints mean? | **Inline PTX Assembly** — <https://docs.nvidia.com/cuda/inline-ptx-assembly/> |
53
+ | What is different about Hopper — clusters, TMA, wgmma, DSMEM? | **Hopper Tuning Guide** — <https://docs.nvidia.com/cuda/hopper-tuning-guide/> |
54
+ | Exact signature/semantics of a runtime call | **CUDA Runtime API** — <https://docs.nvidia.com/cuda/cuda-runtime-api/> |
55
+ | What does this `ncu` metric mean? Which section reports it? | **Nsight Compute Profiling Guide** — <https://docs.nvidia.com/nsight-compute/ProfilingGuide/> |
56
+ | `ncu` command-line flags, `--replay-mode`, filtering kernels | **Nsight Compute CLI** — <https://docs.nvidia.com/nsight-compute/NsightComputeCli/> |
57
+
58
+ Blackwell instead of Hopper: swap in the **Blackwell Tuning Guide**
59
+ (<https://docs.nvidia.com/cuda/blackwell-tuning-guide/>).
60
+
61
+ ## How to use them alongside `ref/`
62
+
63
+ The other files in `ref/` are **verified summaries** — every instruction in them was compiled on the
64
+ container toolchain, so they tell you what actually works *here*. The official documents are the
65
+ **authority on semantics** — what an instruction means, every modifier it accepts, the precise memory
66
+ ordering it guarantees.
67
+
68
+ Practical division:
69
+
70
+ - *"Does this assemble on my target, and what does it cost me?"* → `ref/ptx.md`, `ref/cuda-cpp.md`, or
71
+ run `tools/check_toolchain.py`.
72
+ - *"What exactly does `.multicast::cluster` do to the mbarrier transaction count?"* → PTX ISA.
73
+
74
+ When the two disagree about availability, believe the compiler. When they disagree about meaning,
75
+ believe NVIDIA.
76
+
77
+ ## Other upstream references
78
+
79
+ Not NVIDIA, separately licensed, all publicly readable — cite, do not vendor:
80
+
81
+ | project | licence | where |
82
+ |---|---|---|
83
+ | CUTLASS / CuTe | BSD-3-Clause | <https://github.com/NVIDIA/cutlass> |
84
+ | Triton | MIT | <https://github.com/triton-lang/triton> |
85
+ | FlashAttention | BSD-3-Clause | <https://github.com/Dao-AILab/flash-attention> |
86
+ | FlashInfer | Apache-2.0 | <https://github.com/flashinfer-ai/flashinfer> |
87
+ | Liger-Kernel | Apache-2.0 | <https://github.com/linkedin/Liger-Kernel> |
88
+
89
+ `references.md` says what to learn from each.
agent/tools/fetch_nvidia_docs.sh ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Fetch NVIDIA's official CUDA/PTX documentation into a local directory, for offline use.
3
+ #
4
+ # ./fetch_nvidia_docs.sh [dest] # default: ./nvidia-docs
5
+ #
6
+ # WHY A FETCHER AND NOT BUNDLED FILES
7
+ # NVIDIA's documentation is copyrighted and is NOT redistributable. The CUDA EULA distributes only the
8
+ # files listed in its Attachment A -- runtime libraries such as libcudart.so -- and documentation is not
9
+ # among them. So this repo cannot ship the guides; you download your own copy, direct from NVIDIA, under
10
+ # their terms. Linking and citing is fine; copying is not.
11
+ #
12
+ # OFFLINE USE: task containers have network at IMAGE BUILD time and none at run time. Run this in a
13
+ # Dockerfile RUN step and the agent has the official docs available offline while it works:
14
+ #
15
+ # RUN bash fetch_nvidia_docs.sh /opt/nvidia-docs
16
+ #
17
+ # (c) NVIDIA Corporation. Terms: https://docs.nvidia.com/cuda/eula/
18
+ set -uo pipefail
19
+ DEST=${1:-./nvidia-docs}
20
+ VER=${2:-} # e.g. 12.8.0 -> fetch the archived docs matching your toolkit
21
+ mkdir -p "$DEST"
22
+
23
+ # Match the docs to the toolkit you compile with. docs.nvidia.com/cuda/ always serves the NEWEST CUDA,
24
+ # and instructions documented there may not assemble on an older ptxas. CUDA 12.8, for instance, ships
25
+ # PTX ISA 8.7 while the live page currently documents 9.3. Auto-detect unless told otherwise.
26
+ if [ -z "$VER" ] && command -v nvcc >/dev/null 2>&1; then
27
+ V=$(nvcc --version | grep -oE 'release [0-9]+\.[0-9]+' | head -1 | cut -d' ' -f2)
28
+ [ -n "$V" ] && VER="$V.0"
29
+ fi
30
+ if [ -n "$VER" ] && curl -sSL --fail --max-time 60 -o /dev/null \
31
+ "https://docs.nvidia.com/cuda/archive/$VER/cuda-c-programming-guide/index.html" 2>/dev/null; then
32
+ BASE=https://docs.nvidia.com/cuda/archive/$VER
33
+ BASE_NS=$BASE
34
+ echo "fetching docs for CUDA $VER (matched to this toolkit)"
35
+ else
36
+ [ -n "$VER" ] && echo "no archive for CUDA $VER; falling back to the current docs"
37
+ BASE=https://docs.nvidia.com/cuda
38
+ BASE_NS=https://docs.nvidia.com/cuda
39
+ fi
40
+ NSIGHT=https://docs.nvidia.com
41
+
42
+ # name|html index|pdf hint (optional)
43
+ # The hint is tried first; if it 404s we fall back to whatever PDF the page itself advertises. Both
44
+ # paths are needed: the PTX ISA pdf is version-stamped (ptx_isa_9.3.pdf) so it MUST be discovered,
45
+ # while the Programming Guide page advertises a link that 404s so it MUST be hinted.
46
+ DOCS="
47
+ cuda-c-programming-guide|$BASE/cuda-c-programming-guide/index.html|$BASE/pdf/CUDA_C_Programming_Guide.pdf
48
+ cuda-c-best-practices-guide|$BASE/cuda-c-best-practices-guide/index.html|$BASE/pdf/CUDA_C_Best_Practices_Guide.pdf
49
+ parallel-thread-execution|$BASE/parallel-thread-execution/index.html|
50
+ inline-ptx-assembly|$BASE/inline-ptx-assembly/index.html|$BASE/pdf/Inline_PTX_Assembly.pdf
51
+ hopper-tuning-guide|$BASE/hopper-tuning-guide/index.html|$BASE/pdf/Hopper_Tuning_Guide.pdf
52
+ cuda-runtime-api|$BASE/cuda-runtime-api/index.html|$BASE/pdf/CUDA_Runtime_API.pdf
53
+ nsight-compute-profiling-guide|$NSIGHT/nsight-compute/ProfilingGuide/index.html|
54
+ nsight-compute-cli|$NSIGHT/nsight-compute/NsightComputeCli/index.html|
55
+ "
56
+
57
+ ok=0; fail=0
58
+ for entry in $DOCS; do
59
+ name=${entry%%|*}; rest=${entry#*|}
60
+ url=${rest%%|*}; hint=${rest#*|}
61
+ [ "$hint" = "$url" ] && hint=""
62
+ dir=$(dirname "$url")
63
+ html="$DEST/$name.html"
64
+ if ! curl -sSL --fail --max-time 120 -o "$html" "$url" 2>/dev/null; then
65
+ echo " FAIL (html) $name"; fail=$((fail+1)); continue
66
+ fi
67
+ # candidate PDFs: the hint, then whatever the page advertises
68
+ rel=$(grep -oE '\.\./pdf/[A-Za-z0-9_.-]+\.pdf|/pdf/[A-Za-z0-9_.-]+\.pdf' "$html" | head -1)
69
+ disc=""
70
+ if [ -n "$rel" ]; then
71
+ case "$rel" in
72
+ # "../pdf/x.pdf" is relative to the page's directory, so go UP one level -- for
73
+ # .../cuda/parallel-thread-execution/index.html that resolves to .../cuda/pdf/x.pdf
74
+ ../*) disc="$(dirname "$dir")/${rel#../}" ;;
75
+ *) disc="https://docs.nvidia.com$rel" ;;
76
+ esac
77
+ fi
78
+ got=""
79
+ for pdf in "$hint" "$disc"; do
80
+ [ -z "$pdf" ] && continue
81
+ if curl -sSL --fail --max-time 300 -o "$DEST/$name.pdf" "$pdf" 2>/dev/null; then
82
+ got="$pdf"; break
83
+ fi
84
+ done
85
+ if [ -n "$got" ]; then
86
+ echo " ok $name (html + pdf $(du -h "$DEST/$name.pdf" | cut -f1))"
87
+ else
88
+ rm -f "$DEST/$name.pdf"
89
+ echo " ok $name (html only)"
90
+ fi
91
+ ok=$((ok+1))
92
+ done
93
+
94
+ cat > "$DEST/LICENSE-NOTICE.txt" <<'NOTE'
95
+ These documents were downloaded from https://docs.nvidia.com and are
96
+ Copyright (c) NVIDIA Corporation. All rights reserved.
97
+
98
+ They are NOT covered by the license of the repository that shipped this script,
99
+ and they are NOT redistributable. The CUDA EULA (https://docs.nvidia.com/cuda/eula/)
100
+ permits distribution only of the files enumerated in its Attachment A -- runtime
101
+ libraries such as libcudart.so -- and documentation is not among them.
102
+
103
+ You obtained this copy directly from NVIDIA, for your own use, under NVIDIA's terms.
104
+ Do not re-publish these files. If you need to share them, share this script instead.
105
+ NOTE
106
+
107
+ echo
108
+ echo "$ok fetched, $fail failed -> $DEST"
109
+ echo "Copyright (c) NVIDIA Corporation. Not redistributable; see $DEST/LICENSE-NOTICE.txt"