Agent skill
hpc-python
Python HPC patterns — threading/multiprocessing/async, CUDA streams, latency hiding, PyTorch DDP. Use when writing performance-sensitive Python code, distributed training, or parallel data processing.
Install this agent skill to your Project
npx add-skill https://github.com/JoaquinCampo/Skills/tree/main/hpc-python
SKILL.md
HPC Python
Python parallelism, PyTorch DDP, and CPU/GPU latency hiding patterns.
Extension Files
| File | Content |
|---|---|
parallel-python.md |
Threading vs multiprocessing vs asyncio decision tree, GIL rules, CUDA+fork safety |
latency-hiding.md |
CUDA streams, double buffering, compute/comm overlap, CUDAGraphs, async checkpoint |
pytorch-ddp.md |
DDP internals, gradient buckets, common bugs, mixed precision, DistributedSampler |
preload-caching.md |
Three-level caching: L1 file (disk/memmap/shm), L2 function (lru_cache/dedup/index), L3 variable (buffer/GPU cache/warmup/KV cache) |
torch-compile.md |
torch.compile modes, graph break diagnosis/fixes, reading generated Triton as starting point for hand-tuning |
benchmarking.md |
Correct GPU timing (CUDA events, torch.utils.benchmark.Timer), warmup, common pitfalls, what to measure |
dataloader.md |
DataLoader params (num_workers/pin_memory/prefetch_factor), dataset patterns, data formats, collation, worker issues |
Quick Decision Tree
What is the bottleneck?
├─ I/O bound → threading (ThreadPoolExecutor) or asyncio
├─ CPU bound → multiprocessing (mp.Pool, fork BEFORE CUDA!)
├─ GPU bound → batch inputs, don't parallelize
├─ Mixed CPU→GPU → pipeline + CUDA streams (see latency-hiding.md)
└─ DDP communication → tune bucket_cap_mb, use model.no_sync()
Critical Rules
- mp.Pool BEFORE CUDA: Create multiprocessing pool before any
torch.cudacall (fork+CUDA = deadlock) - Never
.item()in loops: Accumulate on GPU, transfer final result only pin_memory=True: Required fornon_blocking=Truetransfers to actually be async- DDP
no_sync(): Use during gradient accumulation steps to avoid redundant AllReduce find_unused_parameters=True: Only when needed — it's expensive
Review Checklist (Python)
□ No .cpu()/.item()/.numpy() in hot loops?
□ DataLoader: num_workers > 0, pin_memory=True?
□ mp.Pool created before CUDA init?
□ Threading used only for I/O, not CPU-bound work?
□ DDP gradient accumulation uses no_sync()?
□ CUDA streams used for transfer/compute overlap?
□ Pre-allocated buffers reused (not created per iteration)?
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
sparse-retrieval-eval
Evaluate sparse retrieval models on standard IR benchmarks (BEIR, MIRACL, mMARCO). Covers all IR metrics (nDCG@k, Recall@k, MAP, MRR), dataset loading, sparse corpus encoding to CSR matrices, IDF-weighted retrieval, caching, and result interpretation. Triggers on: evaluate retrieval, BEIR benchmark, nDCG, recall@k, sparse retrieval evaluation, MIRACL evaluation, information retrieval metrics, IR evaluation, search quality metrics.
wandb-plot
Download and generate plots from Weights & Biases runs. Use when you need to: - List projects you have access to - List runs in a W&B project - Inspect available metrics for a run - Download existing plot images from a run - Generate line plots from metric history (loss, accuracy, etc.)
go
Go engineering best practices and idioms. This skill should be used when writing, reviewing, or refactoring Go code. Triggers on any .go file work, Go module operations, go test, go build, go run, go vet, go generate, or when the user mentions Go, golang, goroutines, channels, context, Go interfaces, Go error handling, Go testing, or Go concurrency. ALWAYS use this skill when Go code is involved, even for simple functions.
fastapi
FastAPI best practices and conventions. Use when working with FastAPI APIs and Pydantic models for them. Keeps FastAPI code clean and up to date with the latest features and patterns, updated with new versions. Write new code or refactor and update old code.
kvpress
kvpress (NVIDIA) KV-cache compression for HuggingFace LLMs. Use when: kvpress imports, compression_ratio, press(model) context managers, StreamingLLMPress, SnapKVPress, ExpectedAttentionPress, TOVAPress, KnormPress, KV-cache eviction, token pruning during generation, or attention sink methods.
plantuml
Create, edit, and render PlantUML diagrams. Triggers on: architecture diagrams, flowcharts, sequence diagrams, data models, state machines, visual documentation.
Didn't find tool you were looking for?