vit-pytorch
Routes vit-pytorch Vision Transformer model construction, variable-resolution and video inputs, pretraining wrappers, attention introspection, and package troubleshooting.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- vit-pytorch
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Routes vit-pytorch Vision Transformer model construction, variable-resolution and video inputs, pretraining wrappers, attention introspection, and package troubleshooting.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md3.3 KB
- 参考文档references/repo-provenance.md1.4 KB
- 参考文档references/repo-routing-metadata.json502 B
- 参考文档references/troubleshooting.md3.7 KB
- 脚本scripts/check_vit_pytorch_install.py4.9 KB
03 SKILL.md 正文
vit-pytorch
Use this repo skill when a task names vit-pytorch, vit_pytorch, lucidrains' Vision Transformer package, or a model/workflow implemented by that package: ViT, SimpleViT, NaViT, ViViT, CCT, CrossViT, MAE, Dino, Recorder, Extractor, and related image/video transformer variants.
Quick setup and import check
Install the public package in the user's Python environment:
pip install vit-pytorch
Then run a minimal import/forward check:
import torch
from vit_pytorch import ViT
model = ViT(image_size=32, patch_size=8, num_classes=7,
dim=32, depth=1, heads=2, dim_head=16, mlp_dim=64)
logits = model(torch.randn(2, 3, 32, 32))
assert logits.shape == (2, 7)
For a broader package health check, run the bundled helper after installing the package:
python scripts/check_vit_pytorch_install.py --run-smoke
The package exposes Python modules only; no console CLI entry points were found in this snapshot.
Route by user intent
- Fixed-size 2D image classifier or architecture choice: read sub-skills/image-architectures/SKILL.md. Use it for plain
ViT/SimpleViT, CCT, CrossViT, PiT, LeViT, CvT, MaxViT, XCiT, JetViT, ViT-5, and image-only variants such as patch dropout or patch merger. - Variable-resolution images, NaViT grouping, 1D/3D/N-D tensors, or video: read sub-skills/variable-shapes-video/SKILL.md. Use it for
NaViT, nested tensor variants,vit_3d,simple_vit_3d,cct_3d,ViViT, 1D models, N-D models, and video wrappers. - Loss wrappers, pretraining, distillation, adaptation, or fine-tuning: read sub-skills/pretraining-and-adaptation/SKILL.md. Use it for
DistillWrapper, MAE, SimMIM, MPP, MP3, DINO, EsViT, Learnable Memory ViT, LeJEPA, VAT, VAAT, WWT, and decorrelation auxiliary loss. - Attention maps, embeddings, hooks, efficient/custom transformer injection, or performance wrappers: read sub-skills/introspection-and-customization/SKILL.md. Use it for
Recorder,Extractor,efficient.ViT,parallel_vit, andsimple_flash_attn_vit.
Operating rules
- Identify the user's tensor layout before choosing a route: image
(batch, channels, height, width), NaViT image lists(channels, height, width), video(batch, channels, frames, height, width), 1D(batch, channels, seq_len), or N-D(batch, channels, *input_shape). - Start with tiny random tensors and small constructor dimensions before copying README-scale examples. Most helper scripts use
dim=32,depth=1, and CPU-safe tensors to validate shape and wrapper wiring. - Treat optional dependencies as workflow-specific.
torch,torchvision, andeinopsare base dependencies;torchaudiois needed for VAAT, while Accelerate, W&B, Kaggle data, external transformer packages, or checkpoints belong only to explicit full-training or research-idea requests. - Do not run dataset downloads, notebooks, long training loops, or checkpoint loaders as default smoke checks. Use the bundled helpers first, then ask for data/runtime approval if the user requests full training.
- If a workflow fails, read references/troubleshooting.md and the nearest sub-skill troubleshooting reference before changing packages or model families.
- If working against a live checkout rather than an installed release, read references/repo-provenance.md to decide whether this skill should be refreshed.
Shared references and scripts
- references/api-reference.md — top-level package facts, important exports, verified signatures, and optional dependency notes.
- references/troubleshooting.md — cross-cutting install/import, backend, optional dependency, and version-fragile wrapper guidance.
- references/repo-provenance.md — source snapshot and refresh baseline.
- references/repo-routing-metadata.json — structured routing metadata for managed repo-skill import.
- scripts/check_vit_pytorch_install.py — package import, metadata, optional module, and minimal forward smoke checks.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).