Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add mindspore-ai/akg --skill triton-cuda-memorygit clone --depth 1 https://github.com/mindspore-ai/akgWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/mindspore-ai/akg/triton-cuda-memory)<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-cuda-memory"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-memory/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/mindspore-ai/akg/triton-cuda-memory"><img src="https://agentmods.dev/badge/skills/mindspore-ai/akg/triton-cuda-memory.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00066 | $0.02085 |
| Opus 5 | $0.00033 | $0.01043 |
| Sonnet 5 | $0.00013 | $0.00417 |
| Haiku 4.5 | $0.00007 | $0.00209 |
Grade A, and why
triton-cuda-memory scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 245 lines — stays where its author put it; the contents beside it link to each section on GitHub.
内存访问优化
内存访问是 GPU 性能的关键瓶颈。本文档提供 Triton CUDA 的内存访问优化策略。
1. GPU 内存层次
内存带宽和延迟
| 内存类型 | 带宽 (A100) | 延迟 | 容量 |
|---|---|---|---|
| 寄存器 | ~19 TB/s | 1 cycle | 256 KB/SM |
| 共享内存 | ~19 TB/s | ~20 cycles | 164 KB/SM |
| L2 缓存 | ~5 TB/s | ~100 cycles | 40 MB |
| 全局内存 (HBM) | ~2 TB/s | ~400 cycles | 40/80 GB |
优化原则
- 减少全局内存访问: 利用共享内存和寄存器
- 合并访问 (Coalesced Access): 同一 warp 内线程访问连续地址
- 提高 L2 缓存命中率: 通过 Grouped Ordering 等技术
2. 合并访问 (Coalesced Access)
什么是合并访问?
当同一 warp 中的 32 个线程访问连续的内存地址时,GPU 可以将这些请求合并为一次或少量内存事务,大幅提高带宽利用率。
# 正确:合并访问(连续地址)
@triton.jit
def coalesced_kernel(input_ptr, output_ptr, n, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE) # 连续偏移
mask = offsets < n
data = tl.load(input_ptr + offsets, mask=mask)
tl.store(output_ptr + offsets, data, mask=mask)
# 错误:非合并访问(跳跃地址)
@triton.jit
def strided_kernel(input_ptr, output_ptr, n, stride, BLOCK_SIZE: tl.constexpr):
pid = tl.program_id(0)
offsets = pid * BLOCK_SIZE + tl.arange(0, BLOCK_SIZE)
# 每个线程跳跃 stride 个元素,导致非合并访问
strided_offsets = offsets * stride
mask = strided_offsets < n
data = tl.load(input_ptr + strided_offsets, mask=mask)
3. 块大小选择策略
调优原则
- 平衡并行度与资源占用,避免过大或过小
- BLOCK_SIZE 常用值:128, 256, 512, 1024
- 过小:并行度不足,无法充分利用 warp
- 过大:寄存器/共享内存溢出,occupancy 下降
推荐设置
- Element-wise 算子:BLOCK_SIZE = 1024 或 512
- Reduce 算子:BLOCK_SIZE = triton.next_power_of_2(n_cols)
- MatMul 算子:BLOCK_M = 128, BLOCK_N = 128, BLOCK_K = 32-64
4. 2D 数据内存访问优化
优先使用 tl.make_block_ptr
对于 2D 数据(如矩阵),优先使用 tl.make_block_ptr 配合 boundary_check,可自动优化内存合并。
@triton.jit
def matmul_kernel(
A_ptr, B_ptr, C_ptr,
M, N, K,
stride_am, stride_ak,
stride_bk, stride_bn,
stride_cm, stride_cn,
BLOCK_M: tl.constexpr,
BLOCK_N: tl.constexpr,
BLOCK_K: tl.constexpr,
):
pid_m = tl.program_id(0)
pid_n = tl.program_id(1)
# 创建 2D Block Pointer
A_block_ptr = tl.make_block_ptr(
base=A_ptr,
shape=(M, K),
strides=(stride_am, stride_ak),
offsets=(pid_m * BLOCK_M, 0),
block_shape=(BLOCK_M, BLOCK_K),
order=(1, 0), # Row-major
)
# 使用 boundary_check 自动处理边界
a = tl.load(A_block_ptr, boundary_check=(0, 1))
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 9d ago First seen · 245 lines · 66 tokens per session scan A 5f84e9e00afc
triton-cuda-memory is a skill published in the GitHub repository mindspore-ai/akg (259 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 66 tokens to every session and 2,085 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other skills, from other repositories
hatch3r-ai-feature
Eval-driven development workflow for shipping AI features — write eval before prompt, measure, iterate, ship with caching + cost telemetry + model fallback + hallucination SLI.
AI Integration Specialist
Integrate AI tools and APIs into business workflows and applications.
triton-cuda-reduce
A guide to writing CUDA GPU code that combines many values into results such as sums, averages, maximums, and minimums. It also covers softmax, layer normalization, and log-softmax.
triton-cuda-attention
An implementation guide for attention operations in Triton on CUDA, with a complete Flash Attention example and changes for causal, grouped-query, multi-query, and rotary-position variants.
AI Integration Specialist
Integrate AI tools and APIs into business workflows and applications.
agent-platform-rag-engine-management
Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…