LLaVA-OneVision-2 is an openly released multimodal AI model and training framework that processes images, long-form video, and spatial information. Researchers use it to train, evaluate, and reproduce vision-language models with the project’s released data, encoders, checkpoints, and training records. The catalogue skills support work with this model and its training resources.
Borrowing it
Nothing to install: this file belongs to EvolvingLMMs-Lab/LLaVA-OneVision-2. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/EvolvingLMMs-Lab/LLaVA-OneVision-2/main/.opencode/skills/cu-lengths-attention-flow/SKILL.mdgit clone --depth 1 https://github.com/EvolvingLMMs-Lab/LLaVA-OneVision-2Wrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow)<a href="https://agentmods.dev/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow"><img src="https://agentmods.dev/badge/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow"><img src="https://agentmods.dev/badge/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00035 | $0.03510 |
| Opus 5 | $0.00017 | $0.01755 |
| Sonnet 5 | $0.00007 | $0.00702 |
| Haiku 4.5 | $0.00003 | $0.00351 |
Grade A, and why
cu-lengths-attention-flow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 278 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Purpose / 用途
Use this skill when reasoning about attention boundaries in the LLaVA-OneVision2 forward pass — specifically how cu_lengths and patch_positions control attention at different stages of the model.
在分析 LLaVA-OneVision2 前向传播中的 attention 边界时使用这个 skill——具体来说,cu_lengths 和 patch_positions 如何在模型的不同阶段控制 attention。
This skill is specifically for:
- Understanding the difference between ViT-level and LLM-level attention control
- Debugging packed vs non-packed attention behavior
- Reasoning about cross-sample isolation in packed sequences
- Understanding why
patch_positionsgrouping does NOT carry into the LLM
这个 skill 专门用于:
- 理解 ViT 层和 LLM 层 attention 控制的区别
- 调试 packed 和 non-packed 的 attention 行为
- 分析 packed 序列中跨样本隔离机制
- 理解为什么
patch_positions的分组不会延续到 LLM 中
Key Files / 关键文件
| File | Role |
|---|---|
aiak_training_llm/train/pretrain/pretrain_llava_onevision2.py |
Forward function — decides packed vs non-packed path based on cu_lengths shape |
aiak_training_llm/train/sft/utils.py |
_get_packed_sequence_params() — builds PackedSeqParams from attention_mask for SFT |
aiak_training_llm/data/multimodal/task_encoder.py |
batch() — sets cu_lengths to [[0]] (dummy) for non-packed, or stacks real cu_lengths for packed |
aiak_training_llm/data/multimodal/task_encoder.py |
pack_selected_samples() — constructs cu_lengths = [0, len_1, len_1+len_2, ...] for offline packed data |
aiak_training_llm/models/llava_onevision2/onevision_encoder_model.py |
ViT encoder — uses patch_positions for local/shared attention |
aiak_training_llm/data/multimodal/qwen2vl_task_encoder.py |
process_sft_qa() — generates patch_positions from image_grid_thw |
Core Concept: Two Independent Attention Control Mechanisms / 核心概念:两套独立的 Attention 控制机制
Overview Diagram / 概览图
┌─────────────────────────────────────────────────┐
│ ViT Encoder │
│ │
│ Control: patch_positions (temporal dimension) │
│ Effect: Local/shared attention │
│ e.g. 4 images share one attention │
│ window via same temporal index │
│ │
│ Output: visual embeddings │
└──────────────────┬──────────────────────────────┘
│ (embeddings replace image
│ placeholder tokens)
▼
┌─────────────────────────────────────────────────┐
│ LLM Decoder │
│ │
│ Control: cu_lengths (cumulative sub-seq lens) │
│ Effect: Determines attention domain │
│ │
│ NON-PACKED: cu_lengths == [[0]] │
│ → full causal attention │
│ → ALL tokens see ALL previous tokens │
│ → patch_positions grouping is GONE │
│ │
│ PACKED: cu_lengths = [0, a, a+b, ...] │
│ → block-diagonal causal attention │
│ → sub-sequences isolated from each other │
│ → within each sub-seq: full causal │
└─────────────────────────────────────────────────┘
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 10d ago First seen · 278 lines · 35 tokens per session scan A b8d43c8fae67
cu-lengths-attention-flow is a skill published in the GitHub repository EvolvingLMMs-Lab/LLaVA-OneVision-2 (1,200 stars, last pushed today), licensed Apache-2.0. It adds 35 tokens to every session and 3,510 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
add-new-model
Use this skill when the user wants to add or port a new model architecture to MLX-VLM — mapping a Hugging Face modeltype to a new file under mlxvlm/models, writing the ModelConfig, matching layer/weight names, reusing a similar existing model, adding a test class, and validating the port. Covers vision-language…
cli-inference
Use this skill when the user wants to run or debug MLX-VLM inference from the command line, including uv run mlxvlm.generate, image/audio/video inputs, local model paths, Hugging Face model IDs, deterministic repro commands, and CLI errors around processors, prompts, model loading, or missing weights.
convert-quantize
Use this skill when the user wants to convert a Hugging Face model to MLX or quantize/dequantize one with mlxvlm.convert, including bits and group size, quant modes (affine, mxfp4, nvfp4, mxfp8), RTN vs AWQ, mixed-bit recipes, dtype casts, calibration (text or multimodal), local vs Hub paths, revisions, uploading to…
server-inference
Use this skill when the user wants to run or debug MLX-VLM server inference, including uv run mlxvlm.server, /v1/models, /v1/chat/completions, /v1/responses, streaming, OpenAI-compatible clients, health checks, metrics, model unload/reload, adapters, trust-remote-code, and server request/response failures.
hf-cache-models
Use this skill when the user wants to list, inspect, or report MLX-VLM model candidates available in the local Hugging Face cache directory, including the server's opt-in hf-cache discovery mode, cache-dir overrides, JSON output, or issue-ready cached model lists.
transformer-attention
Use when reasoning about Transformer self-attention, multi-head attention, positional encoding, masked decoder attention, or why attention replaced recurrence/convolutions in sequence models; not for generic NLP or unrelated attention topics.