LLaVA-OneVision-2: Skill for OpenCode

.opencode/skills/cu-lengths-attention-flow/SKILL.md

cu-lengths-attention-flow is a skill for OpenCode from EvolvingLMMs-Lab/LLaVA-OneVision-2. It costs 35 tokens per session (3,510 once invoked), scanned A, original, Apache-2.0.

A bilingual guide to how sequence lengths and patch positions control which data can attend to which other data in a LLaVA-OneVision2 model. LLaVA-OneVision2 is a model that processes both images and text.

In plain words
What is it for?
It helps debug packed versus unpacked attention, keep samples isolated, and understand how attention settings are built during training and fine-tuning.
Why use it?
It clarifies the different attention rules used by the image-processing and language-processing parts of the model, especially for packed batches containing multiple samples.

Skill for OpenCode

Written for OpenCode: installed under .opencode/. Also seen: mentions OpenCode.

This is EvolvingLMMs-Lab/LLaVA-OneVision-2's own configuration. It tells OpenCode how to work on LLaVA-OneVision-2 itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything LLaVA-OneVision-2 configures →

About the project

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.

EvolvingLMMs-Lab/LLaVA-OneVision-2 · 1,200 stars · on GitHub · evolvinglmms-lab.github.io

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/EvolvingLMMs-Lab/LLaVA-OneVision-2/main/.opencode/skills/cu-lengths-attention-flow/SKILL.md
Clone the repo
git clone --depth 1 https://github.com/EvolvingLMMs-Lab/LLaVA-OneVision-2

Made for: OpenCode.

Wrote 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.

agentmods badge for cu-lengths-attention-flow

README.md
[![agentmods](https://agentmods.dev/badge/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow/github.svg)](https://agentmods.dev/skills/evolvinglmms-lab/llava-onevision-2/cu-lengths-attention-flow)
Your own site
<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.

agentmods 80×15 button for cu-lengths-attention-flow

Your own site · 80×15
<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>
Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,510 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 10d ago against content hash b8d43c8fae67, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

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.

.opencode/skills/cu-lengths-attention-flow/SKILL.md · 278 lines

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_lengthspatch_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_positions grouping 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           │
└─────────────────────────────────────────────────┘

Read the full file on GitHub · 278 lines

Changes

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.

  1. 10d ago First seen · 278 lines · 35 tokens per session scan A b8d43c8fae67

Subscribe to this mod's changes

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.

Related

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…

Blaizzy/mlx-vlm · 83 tokens

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.

Blaizzy/mlx-vlm · 67 tokens

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…

Blaizzy/mlx-vlm · 99 tokens

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.

Blaizzy/mlx-vlm · 80 tokens

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.

Blaizzy/mlx-vlm · 60 tokens

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.

VectifyAI/OpenKB · 46 tokens