/tcgd:tcgd-investigatefrom tcgd
Investigates PyTorch CUDA Graph tensor mismatches, replay drift, NaNs, gradients, allocator growth, pool behavior, and eager-versus-graph differences using torch-cudagraph-debug.
Ships in tcgd. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Own one tensor or memory investigation from reproduction through a saved,
evidence-backed report. Start with the public torch_cudagraph_debug API and
escalate only when the remaining question cannot be answered by the package.
Establish these values from the request or discover them from the environment:
If the user does not provide an output root, create
/tmp/tcgd-investigation-YYYYMMDD-HHMMSS. Do not reuse an existing directory.
Do not stop for values that can be discovered from the workload, repository, or
runtime.
Read the workflow map before choosing APIs. Use the report template for the final deliverable.
Turn the request into one explicit comparison or timeline before editing the workload.
Name points by semantic lifecycle boundary, such as before_forward and
after_forward, rather than generic names such as start and final. For
baseline-versus-candidate work, measure equivalent boundaries in both runs.
Start with the smallest measurement that answers the question:
Use this artifact layout:
<investigation-root>/
├── metadata.json
├── runs/
│ ├── <baseline>/
│ │ ├── command.txt
│ │ ├── stdout.log
│ │ ├── stderr.log
│ │ └── bundles/
│ └── <candidate>/
│ ├── command.txt
│ ├── stdout.log
│ ├── stderr.log
│ └── bundles/
└── REPORT.md
Record at least:
Do not copy old bundles into a fresh evidence root. Existing bundles may be
analyzed only when the user explicitly asks for offline analysis; record the
mode as existing-artifact analysis in metadata.json.
Check for a local CUDA device and for suitable active allocations exposed by the current environment. If a GPU resource-management skill is available, use it and follow its allocation, reuse, and release policy. Request a new resource only when no suitable active resource exists.
Keep baseline and candidate on equivalent hardware and software. Treat instrumentation as a possible observer effect, especially for timing, memory, or race-sensitive failures. When practical, run a paired no-tool/tool check on the same node with all other inputs fixed. If that check is unnecessary or too expensive, state that the observer effect was not measured; do not silently assume it is absent.
TensorProbe and RecordAction for local inspection.(name, invocation_index); do not use capture order as cross-run identity.watch_grad() when the question concerns activation or parameter
gradients.TensorRecorder(execution="eager") and
TensorRecorder(execution="cuda_graph") for persisted eager-versus-graph
work.TensorRunGroup and compare_run_groups() when rank-local tensor bundles
must be compared without collapsing rank identity.MemoryProbe.snapshot() for direct state endpoints and
MemoryRecorder.record_point() for named, persisted boundaries._record_memory_history() before the allocations of
interest. Do not make the package own this global setting.Keep instrumentation focused on the tensors and lifecycle phases needed for the question. Preserve the package's unedited text or CLI output in the run logs.
Predeclare the variant order. One matched baseline/candidate pair is sufficient
for a deterministic correctness question. For noisy timing or memory questions,
use repeated counterbalanced AB/BA (or randomized) order after equivalent
warm-up so drift and cache state are not confounded with the candidate. Record
the order and repetition number for every run. Keep code revision, model inputs,
seeds, precision, device count, and launch settings fixed except for the
intended variant.
For each run:
Do not substitute a later successful run for a failed run. Preserve both and explain the difference.
Use public comparison, timeline, lifetime, run-group, and report APIs or the
tcgd-tensor and tcgd-memory CLIs before writing custom parsers.
Copy the exact public output into the Tool Evidence section of REPORT.md or
link to the saved log containing it.
Only after public analysis leaves a concrete unresolved question may you use:
torch.cuda.memory._snapshot() or another raw PyTorch API;Before each escalation, state the missing fact and why the public result cannot
provide it. Save supplemental commands and output separately. If raw evidence
reveals information the package should expose, record it under Tool Gaps
rather than presenting it as an existing package capability.
Complete REPORT.md with these evidence classes kept separate:
Every conclusion must identify the measured points or observations that support it. Include absolute values before deltas, distinguish allocator reservation from active use, and distinguish correlation from a demonstrated cause.
Before finishing, verify that all paths in the report are absolute, commands are reproducible, required artifacts exist, and no claimed output came from an unrecorded manual transformation. State whether an instrumentation observer effect was measured and whether the number/order of runs supports the requested claim.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
cuda-graphs, gpu-debugging, pytorch-debug, tensor-debug, memory-debug
npx claudepluginhub buptzyb/torch-cudagraph-debug --plugin tcgdOther plugins' skills for the same job