Skip to content

zaya: ZAYA1-VL (vision LoRA on image tokens, bidirectional image attention, converter) - #18

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/zaya1-vl
Sep 26, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/zaya1-vl

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Adds Zyphra ZAYA1-VL-8B: the ZAYA1 language model plus a Qwen2.5-VL vision tower, with two additions of Zyphra's.

Vision-only LoRA on image tokens

  • Rank 8 on CCA's q, k, both value projections and o_proj; rank 32 on every expert's fc1 and fc2.
  • mtmd decodes each image as its own ubatch of embeddings, and llama.cpp reuses graphs only between ubatches of the same kind. So an embedding ubatch applies the LoRA to every token, and text ubatches keep the existing graph unchanged.
  • Image ubatches run the experts explicitly, with the same top-1 choice and weight as build_moe_ffn, because the fc1 LoRA sits before the SwiGLU.

Bidirectional attention within an image

  • A new mmproj key, clip.vision.decode_non_causal, makes mtmd decode image chunks non-causally, for any vision projector.

Converter

  • Reads ZAYA1-VL's checkpoint layout: layers.{i}.attn and layers.{i}.mlp sublayers, the legacy tensor names, and rotary_base/rope_pct.
  • Stacks the per-expert LoRA and writes both ranks.
  • Fills the vision config's missing Qwen2.5-VL defaults (depth, heads, window pattern).
  • Writes the mmproj; temporal patch size is 1, so the second patch conv is zeros.
  • Embeds a chat template that takes llama.cpp's random media markers and puts images in front of the user turn, as Zyphra's does.

Checked on Strix Halo (F16 text model, F16 mmproj)

  • Reference: Zyphra's own code (their transformers branch zaya1-vl, FP32, CPU), teacher-forced on llama.cpp's greedy answers to three image questions (101 tokens). The prompts match exactly: 208 tokens, the image at the same position.
    • image decode made causal (the flag set false), against Zyphra's eager path: top-1 100/101
    • bidirectional (the default), against Zyphra's eager path with the image block made bidirectional: 100/101
    • Zyphra's flash-attention path makes the prefix bidirectional through two tokens past the image; llama.cpp decodes the image chunk bidirectionally and the tokens around it causally.
  • Answers: "HELLO 42" read exactly from a synthetic image, which also has a red square and a blue circle. On a real photo, the model recognizes the 1969 New York Times moon-landing front page.
  • No regressions:
    • ZAYA1-8B F16 still matches transformers FP32 at 95/96 teacher-forced positions.
    • Wikitext perplexity with one sequence per batch is unchanged (32.5834).
    • test-llama-archs -a zaya passes on Vulkan and CPU, including save/reload.
  • Decode: 38–51 tok/s for F16 on Vulkan0 on a quiet box.

Note: a non-causal decode needs the whole image in one ubatch, so run with -ub at least the image's token count; -b 4096 -ub 4096 covers Qwen2.5-VL's 4,096-token cap.

🤖 Generated with Claude Code

…ntion, converter)

Zyphra ZAYA1-VL-8B is the ZAYA1 language model with a Qwen2.5-VL vision tower
and two additions:

- vision-only LoRA, used on image tokens: rank 8 on CCA's q, k, both value
  projections and o_proj; rank 32 on every expert's fc1 and fc2. mtmd decodes
  an image as its own ubatch of embeddings, and graphs are only reused between
  ubatches of the same kind, so a ubatch of embeddings takes the LoRA for every
  token. The experts' LoRA needs the hidden state between fc1 and the SwiGLU,
  so image ubatches run the experts explicitly (same top-1 choice and weight
  as build_moe_ffn); o_proj's LoRA reads the attention output before wo.
- bidirectional attention within an image: the mmproj key
  clip.vision.decode_non_causal makes mtmd decode image chunks non-causally,
  for any vision projector (Gemma 3/4 decide it by projector type).

The converter reads ZAYA1-VL's checkpoint (layers.{i}.attn / layers.{i}.mlp,
the legacy Megatron-style tensors, rotary_base, rope_pct), stacks the
experts' LoRA, writes the ranks, fills the vision config's Qwen2.5-VL
defaults, and writes the mmproj (temporal patch 1: the second patch conv is
zeros). Its chat template takes llama.cpp's media markers (<__media_<id>__>,
random per server) as well as Zyphra's list form, and puts images in front of
the user turn as Zyphra's does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong
bong-water-water-bong merged commit f30cc43 into 1bit/hrx-vulkan-patched Sep 26, 2026
10 of 27 checks passed

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked on strixhalo from a fresh build of f191edd (HRX + Vulkan). ZAYA1-8B text output is unchanged:

  • Q4_K_M wikitext perplexity (-c 512): Vulkan0 with one sequence per batch is 21.5731 and with four (-b 2048) 21.6213. HRX0 is 21.5518. All three are identical to the numbers before this PR.
  • F16 against transformers FP32, teacher-forced top-1: 95/96, the same as before.
  • test-llama-archs -a zaya: OK on Vulkan and CPU, including save/reload.
  • Converter: pyflakes is clean. The text-only path is gated on vision_config.
  • The pending checks are the self-hosted-runner jobs, which never start on this fork. Every hosted build passes.

@bong-water-water-bong
bong-water-water-bong deleted the 1bit/zaya1-vl branch October 12, 2026 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant