Kanana-2-V-Decide-3B Vision Tower
Powered by Kanana
Community extraction of the visual tower from Kakao's Kanana-2-V-Decide-3B, revision 12820d654ed9789a0f7f48daeee1703c3483c464.
The component holds 484,793,968 parameters in the original bfloat16: a 27-layer gated-attention ViT (hidden size 1152, 16 heads, patch size 16, temporal patch size 2) together with the merger that projects merged 2×2 patches into the 2560-dimensional language space.
The language model (354 tensors, about 6.36 GB) and similarity.log_temperature are not included. This repository is a visual feature extractor, not a decision model, and it cannot answer questions or score candidates on its own.
Provenance
| Item | Value |
|---|---|
| Source repository | kakaocorp/kanana-2-v-decide-3b-2611 |
| Source revision | 12820d654ed9789a0f7f48daeee1703c3483c464 |
| Source file | model.safetensors, 7,330,945,212 bytes |
| Source LFS SHA-256 | 528930fa261b31ed1f47eecbe7d08efd2e226207508124ae186e1a65dbbbda3b |
| Extracted scope | model.visual.* — 333 tensors, 969,587,936 bytes |
Output model.safetensors SHA-256 | 5a0f2176875aab8db6d33499ed7347b11a7df56c69cf18e480822fc2b1c0574f |
| Extraction method | HTTP range requests over one contiguous byte range; no full checkpoint download |
Only the requested byte ranges were transferred. Each assembled range was compared byte-for-byte with the cached source ranges before the output file was hashed. Tensor values, shapes and dtypes are unchanged: there was no training, quantization, dtype conversion or reordering of tensor data.
Original checkpoint tensor names (model.visual.*) are preserved. tensor_mapping.json records the source shard, dtype, shape and byte offsets of every tensor. component.py strips the model.visual. prefix and loads the result with strict=True.
The official configuration, model implementation, image processor and license are included unmodified from the pinned revision. component.py and component_config.json are the added convenience loader and scope description.
How this differs from the other Kanana vision encoders
| This component | Kanana-2 medium | Kanana-2 tiny | |
|---|---|---|---|
| Layers | 27 | 28 | 18 |
| Hidden size | 1152 | 768 | 512 |
| Attention heads | 16 | 32 | 16 |
| MLP intermediate | 4304 | 1792 | 768 |
| Attention pattern | full | sliding + full | sliding + full |
| Gating | sigmoid gate on attention output | elementwise | elementwise |
| Output width | 2560 | — | — |
These are different weights, not a re-publication of an existing encoder.
Gated attention matters for loading. Here qkv projects to 4 × hidden_size; the result splits into query, key, value and a per-head gate, and the attention output is multiplied by sigmoid(gate). Stock Qwen3-VL vision code expects 3 × hidden_size and will not load these weights. Use the included modeling_kanana_v_decide.py, which subclasses the Qwen3-VL vision modules and implements the gate.
Loading
The source configuration declares transformers_version: 5.5.3. The official implementation uses the Transformers 5.x attention interface (ALL_ATTENTION_FUNCTIONS.get_interface, is_flash_attention_requested), which is not present in 4.57.x. Install:
pip install "transformers==5.5.3" torch torchvision accelerate safetensors pillow einops
import sys, torch
from PIL import Image
from huggingface_hub import snapshot_download
root = snapshot_download('gatilin/kanana-2-v-decide-3b-vision-encoder')
sys.path.insert(0, root)
from component import load_model, load_processor
model = load_model(root) # sdpa attention, original bfloat16 weights
processor = load_processor(root)
image = Image.open('image.jpg').convert('RGB')
batch = processor(image) # official __call__(image) signature
pixel = batch['pixel_values'].to(torch.bfloat16)
grid = torch.tensor([batch['image_meta']['vision_grid_thw']], dtype=torch.long)
with torch.inference_mode():
output = model(pixel, grid)
features = output.pooler_output # [grid_t * grid_h * grid_w / 4, 2560]
patch_features = output.last_hidden_state # [grid_t * grid_h * grid_w, 1152], before the merger
The official processor returns {"pixel_values", "image_meta"} rather than the usual images=/return_tensors= batch interface; image_meta also carries hw_best_resolution, hw_orig_resolution and image_token_thw.
The vision model exposes two output levels. last_hidden_state is the 1152-dimensional per-patch sequence; pooler_output is the merger result in the 2560-dimensional language space, which is what the Kanana-2-V-Decide language model consumes. deepstack_features is empty because the source configuration sets deepstack_visual_indexes to [].
load_model(root, attn_implementation='eager') selects the explicit eager path, and load_model(root, dtype=torch.float32) runs the same weights in float32 — see the precision note below. The official image processor handles resizing, rescaling and normalization; preprocessor_config.json is the unchanged source configuration (min_pixels 65536, max_pixels 16777216, mean/std 0.5).
Validation
Measured on CPU with transformers==5.5.3 and torch==2.14.1 using three real COCO128 images (000000000009, 000000000030, 000000000034) passed through the official KananaVImageProcessor. Full results are in validation.json; the per-layer attention probe is in attention_path_probe.json.
| Check | Result |
|---|---|
| Strict load | 333/333 tensors, no missing or unexpected keys |
| Parameters | 484,793,968, all torch.bfloat16 |
| Input / output shapes | pixel [256, 1536], grid [1, 16, 16] → last_hidden_state [256, 1152], pooler_output [64, 2560] |
| Finiteness | all outputs finite on all three images |
| Determinism | repeated identical input, max absolute error exactly 0.0 |
| eager vs sdpa in float32 | max relative error 7.4e-5; merged output max absolute error ≤ 3.9e-4 |
Attention paths are equivalent; bfloat16 is the limiting factor. An initial bf16 comparison showed a max absolute difference of 3276 between eager and sdpa on last_hidden_state. Running both paths in float32 on the same weights reduces the gap to float32 rounding level at every one of the 27 layers, so neither path is defective. The cause is a single extreme activation channel (index 476, absmax ≈ 5000 against a median channel absmax ≈ 19): bf16 spacing at that magnitude is 32, and the error is amplified in the final block.
Against a float32 reference, bf16 sdpa loses 2.5–3.0% mean absolute error on pooler_output (cosine similarity ≥ 0.9993); bf16 eager loses 2.9–3.9%. sdpa is therefore the default. Use dtype=torch.float32 when numerical fidelity matters more than memory.
Limitations
- The merger output is designed for the Kanana-2-V-Decide language model. Without that language model there is no decision, scoring or captioning capability here.
- Validation is a component-level CPU test, not an evaluation of decision accuracy or downstream VLM quality.
bfloat16CPU execution is not bit-identical to float32 compute on the same weights: expect a few percent mean absolute drift on the merged features, concentrated in near-zero elements and one outlier channel. It is also not claimed to match the original GPU inference or training path.- No reference logits from the full upstream model were available. Correctness rests on strict key/shape loading, unmodified official source and internal numerical consistency, not on matching upstream outputs.
- COCO128 images used for validation may overlap the model's training data; they are not an independent generalization benchmark.
- Attention weights are not causal importance, and feature norms are not a model quality ranking.
License
The Kanana Open License Agreement from the source revision is included verbatim as LICENSE, together with the NOTICE text file required by Section 3.1(iv). Rights and restrictions in that agreement apply to these weights and the accompanying official code.
Use restrictions apply to downstream recipients. Under Section 2.2, use of these weights and of any derivative works must comply with applicable law and with Kakao's Guidelines for Responsible AI. Section 4.1 requires a separate commercial license from KAKAO for offering or reselling access through APIs or cloud services, for system-integration or on-premise deployment offerings, and for on-device distribution.
No official source file was modified. component.py, component_config.json, extraction.json, tensor_mapping.json, validation.json, attention_path_probe.json, source_files_verification.json and this README are added by the extractor; the configuration, modeling, image-processing and license files are byte-for-byte copies from the pinned revision, re-fetched and hashed to confirm it (source_files_verification.json).