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 MilkyWay008/Hermes-OTG --skill flash-attentiongit clone --depth 1 https://github.com/MilkyWay008/Hermes-OTGWrote 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/milkyway008/hermes-otg/flash-attention)<a href="https://agentmods.dev/skills/milkyway008/hermes-otg/flash-attention"><img src="https://agentmods.dev/badge/skills/milkyway008/hermes-otg/flash-attention/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/milkyway008/hermes-otg/flash-attention"><img src="https://agentmods.dev/badge/skills/milkyway008/hermes-otg/flash-attention.svg" alt="Reviewed on agentmods" width="80" height="20"></a>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.00017 | $0.03060 |
| Opus 5.5 | $0.00007 | $0.01224 |
| Sonnet 5.5 | $0.00003 | $0.00612 |
| Haiku 4.5 | $0.00002 | $0.00306 |
Grade A, and why
optimizing-attention-flash 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 2mo 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.
This is a copy
95% identical to flash-attention — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.
How it starts
The opening of the file, as written. The whole thing — 375 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Flash Attention - Fast Memory-Efficient Attention
Quick start
Flash Attention provides 2-4x speedup and 10-20x memory reduction for transformer attention through IO-aware tiling and recomputation.
PyTorch native (easiest, PyTorch 2.2+):
import torch
import torch.nn.functional as F
q = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16) # [batch, heads, seq, dim]
k = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16)
v = torch.randn(2, 8, 512, 64, device='cuda', dtype=torch.float16)
# Automatically uses Flash Attention if available
out = F.scaled_dot_product_attention(q, k, v)
flash-attn library (more features):
pip install flash-attn --no-build-isolation
from flash_attn import flash_attn_func
# q, k, v: [batch, seqlen, nheads, headdim]
out = flash_attn_func(q, k, v, dropout_p=0.0, causal=True)
Common workflows
Workflow 1: Enable in existing PyTorch model
Copy this checklist:
Flash Attention Integration:
- [ ] Step 1: Check PyTorch version (≥2.2)
- [ ] Step 2: Enable Flash Attention backend
- [ ] Step 3: Verify speedup with profiling
- [ ] Step 4: Test accuracy matches baseline
Step 1: Check PyTorch version
python -c "import torch; print(torch.__version__)"
# Should be ≥2.2.0
If <2.2, upgrade:
pip install --upgrade torch
Step 2: Enable Flash Attention backend
Replace standard attention:
# Before (standard attention)
attn_weights = torch.softmax(q @ k.transpose(-2, -1) / math.sqrt(d_k), dim=-1)
out = attn_weights @ v
# After (Flash Attention)
import torch.nn.functional as F
out = F.scaled_dot_product_attention(q, k, v, attn_mask=mask)
Force Flash Attention backend (torch.backends.cuda.sdp_kernel is deprecated; use
torch.nn.attention.sdpa_kernel with SDPBackend):
from torch.nn.attention import SDPBackend, sdpa_kernel
with sdpa_kernel(SDPBackend.FLASH_ATTENTION):
out = F.scaled_dot_product_attention(q, k, v)
What ships with it
2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
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.
- 2mo ago First seen · 375 lines · 17 tokens per session scan A d7f39d60f8bd
optimizing-attention-flash is a skill published in the GitHub repository MilkyWay008/Hermes-OTG (25 stars, last pushed 3mo ago), licensed MIT. It adds 17 tokens to every session and 3,060 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 95% identical to flash-attention, differing in 2 lines, and is treated as a copy.
optimizing-attention-flash compared with skills from other repositories
| Mod | Type | Stars | Last push | Licence | Scan | Tokens | Works with |
|---|---|---|---|---|---|---|---|
| optimizing-attention-flashMilkyWay008/Hermes-OTG | Skill | 25 | 3mo ago | MIT | A | 17 | Claude Code, Codex |
| lijigang-skillmomozi1996/awesome-ai-persona-skills | Skill | 1.2k | 2mo ago | MIT | A | 169 | Claude Code, Codex |
| hf-model-card-researchAtlasOmnia/donna-starter | Skill | 140 | 1mo ago | MIT | A | 35 | Claude Code, Codex |
| baoyu-skillmomozi1996/awesome-ai-persona-skills | Skill | 1.2k | 2mo ago | MIT | A | 153 | Claude Code, Codex |
| llm-prompt-injectionuphiago/recon-skills | Skill | 1.4k | 23d ago | MIT | C | 36 | Claude Code, Codex |
| vhir-ingestAppliedIR/sift-mcp | Skill | 24 | 10d ago | MIT | A | 61 | Claude Code, Codex |
| text-similarityjavded-itres/Holix | Skill | 20 | 26d ago | MIT | A | 30 | Claude Code |