variable-shapes-video
Routes vit-pytorch variable-resolution NaViT batches, nested tensor variants, 1D/3D/N-D tensors, and video transformer workflows.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- variable-shapes-video
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Routes vit-pytorch variable-resolution NaViT batches, nested tensor variants, 1D/3D/N-D tensors, and video transformer workflows.
- disable-model-invocation
- true
02 资源文件 3
- 参考文档references/troubleshooting.md12.5 KB
- 参考文档references/workflows.md15.1 KB
- 脚本scripts/smoke_variable_shapes_video.py13.5 KB
03 SKILL.md 正文
Variable Shapes and Video
Use this sub-skill when a user needs vit-pytorch guidance for variable spatial sizes, non-image tensor ranks, or video inputs. Route prompts here when they mention NaViT, na_vit_nested_tensor, na_vit_nested_tensor_3d, vit_3d, simple_vit_3d, cct_3d, vivit, vivit_with_moss, vit_1d, simple_vit_1d, vit_nd, vit_nd_pope, vit_nd_rotary, accept_video_wrapper, variable-resolution grouping, max token budgets, frame patching, or N-D patch grids.
Route by user intent
- Variable-resolution images in one forward: use
vit_pytorch.na_vit.NaViT. Read workflows before choosing manualList[List[Tensor]]grouping orgroup_images=Trueauto grouping withgroup_max_seq_len. - Nested tensor NaViT: use
vit_pytorch.na_vit_nested_tensor.NaViTfor a flat list of image tensors, orvit_pytorch.na_vit_nested_tensor_3d.NaViTfor a flat list of(channels, frames, height, width)volumes, only after checking PyTorch nested/jagged support. Read nested tensor caveats and troubleshooting. - 3D and video classifiers: use
vit_pytorch.vit_3d.ViT,vit_pytorch.simple_vit_3d.SimpleViT,vit_pytorch.cct_3d.CCT,vit_pytorch.vivit.ViViT, orvit_pytorch.vivit_with_moss.ViViTfor inputs shaped(batch, channels, frames, height, width). Read video layouts before settingframes,frame_patch_size, andimage_patch_size. - Video wrapper around an image model: use
vit_pytorch.accept_video_wrapper.AcceptVideoWrapperwhen the user already has an image backbone and wants to run it per frame, optionally restoring time as an output dimension, adding time positional embeddings, or applying MOSS over patch-token outputs. - 1D or N-D tensors: use
vit_pytorch.vit_1d.ViT,vit_pytorch.simple_vit_1d.SimpleViT,vit_pytorch.vit_nd.ViTND,vit_pytorch.vit_nd_pope.ViTND, orvit_pytorch.vit_nd_rotary.ViTND. Read 1D and N-D routing for input layouts, tuple length rules, and patch-grid outputs.
Boundaries
This sub-skill owns variable-resolution image grouping, max sequence length packing, patch and grid position handling, video frame/spatial patch shapes, N-D patching, and nested-tensor caveats.
Route elsewhere instead of duplicating guidance:
- Pure image-only architecture selection, standard square/non-square image classifier choice, and image architecture comparisons belong to the image-architecture route unless the prompt asks about variable sizes or non-image ranks.
- Loss-based pretraining, distillation, masked modeling, DINO/EsViT, MAE/SimMIM/MPP, or adaptation wrappers belong to the pretraining/adaptation route.
- Attention inspection-only wrappers such as
RecorderandExtractorbelong to the introspection/customization route unless they are only incidental to a variable-shape or video workflow.
Operating rules for future agents
-
Normalize the tensor layout before constructing a model. NaViT images are unbatched
(channels, height, width)tensors in Python lists; video/3D models consume(batch, channels, frames, height, width); 1D models consume(batch, channels, seq_len); N-D models consume(batch, channels, *input_shape). -
Check divisibility before running. Height and width must be divisible by
patch_sizeorimage_patch_size;framesmust be divisible byframe_patch_size; each N-D dimension must be divisible by its corresponding patch dimension. See troubleshooting. -
For NaViT, compute token counts before grouping. A standard NaViT image contributes
(height // patch_size) * (width // patch_size)tokens before optional token dropout.group_images=Truegreedily preserves input order and starts a new group when adding the next image would exceedgroup_max_seq_len; it cannot rescue one image whose token count is already too large. -
Separate temporal and spatial patch sizes.
frame_patch_sizepatches along the frame axis;image_patch_sizepatches height and width. Do not swap them, and do not use(batch, frames, channels, height, width)with these modules. -
Treat nested tensor paths as version-sensitive. Prefer standard
na_vit.NaViTfor broadly portable examples. Use nested tensor variants only after a small runtime probe confirms the installed PyTorch supports the required nested/jagged operations. -
Use the bundled smoke helper for confidence. After installing
vit-pytorch, run:python sub-skills/variable-shapes-video/scripts/smoke_variable_shapes_video.pyThe helper imports the installed package, uses tiny CPU tensors, and does not read repository source files.
References
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).