# Send PyTorch to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "pytorch",
    "name": "PyTorch",
    "source": "tencent",
    "type": "skill",
    "category": "AI 智能",
    "sourceUrl": "https://clawhub.ai/ivangdavila/pytorch",
    "canonicalUrl": "https://clawhub.ai/ivangdavila/pytorch",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/pytorch",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=pytorch",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "SKILL.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "pytorch",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-05-03T06:30:07.247Z",
      "expiresAt": "2026-05-10T06:30:07.247Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=pytorch",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=pytorch",
        "contentDisposition": "attachment; filename=\"pytorch-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "pytorch"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/pytorch"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/pytorch",
    "downloadUrl": "https://openagent3.xyz/downloads/pytorch",
    "agentUrl": "https://openagent3.xyz/skills/pytorch/agent",
    "manifestUrl": "https://openagent3.xyz/skills/pytorch/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/pytorch/agent.md"
  }
}
```
## Documentation

### Train vs Eval Mode

model.train() enables dropout, BatchNorm updates — default after init
model.eval() disables dropout, uses running stats — MUST call for inference
Mode is sticky — train/eval persists until explicitly changed
model.eval() doesn't disable gradients — still need torch.no_grad()

### Gradient Control

torch.no_grad() for inference — reduces memory, speeds up computation
loss.backward() accumulates gradients — call optimizer.zero_grad() before backward
zero_grad() placement matters — before forward pass, not after backward
.detach() to stop gradient flow — prevents memory leak in logging

### Device Management

Model AND data must be on same device — model.to(device) and tensor.to(device)
.cuda() vs .to('cuda') — both work, .to(device) more flexible
CUDA tensors can't convert to numpy directly — .cpu().numpy() required
torch.device('cuda' if torch.cuda.is_available() else 'cpu') — portable code

### DataLoader

num_workers > 0 uses multiprocessing — Windows needs if __name__ == '__main__':
pin_memory=True with CUDA — faster transfer to GPU
Workers don't share state — random seeds differ per worker, set in worker_init_fn
Large num_workers can cause memory issues — start with 2-4, increase if CPU-bound

### Saving and Loading

torch.save(model.state_dict(), path) — recommended, saves only weights
Loading: create model first, then model.load_state_dict(torch.load(path))
map_location for cross-device — torch.load(path, map_location='cpu') if saved on GPU
Saving whole model pickles code path — breaks if code changes

### In-place Operations

In-place ops end with _ — tensor.add_(1) vs tensor.add(1)
In-place on leaf variable breaks autograd — error about modified leaf
In-place on intermediate can corrupt gradient — avoid in computation graph
tensor.data bypasses autograd — legacy, prefer .detach() for safety

### Memory Management

Accumulated tensors leak memory — .detach() logged metrics
torch.cuda.empty_cache() releases cached memory — but doesn't fix leaks
Delete references and call gc.collect() — before empty_cache if needed
with torch.no_grad(): prevents graph storage — crucial for validation loop

### Common Mistakes

BatchNorm with batch_size=1 fails in train mode — use eval mode or track_running_stats=False
Loss function reduction default is 'mean' — may want 'sum' for gradient accumulation
cross_entropy expects logits — not softmax output
.item() to get Python scalar — .numpy() or [0] deprecated/error
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: ivangdavila
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-05-03T06:30:07.247Z
- Expires at: 2026-05-10T06:30:07.247Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/pytorch)
- [Send to Agent page](https://openagent3.xyz/skills/pytorch/agent)
- [JSON manifest](https://openagent3.xyz/skills/pytorch/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/pytorch/agent.md)
- [Download page](https://openagent3.xyz/downloads/pytorch)