[PR #345] HIP: build and enable the vision encoder on AMD GPUs #478

Open
opened 2026-10-29 21:25:53 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/345
Author: @Ehco
Created: 10/21/2026
Status: 🔄 Open

Base: main ← Head: hip-vision-encoder


📝 Commits (1)

  • c75f890 HIP: build and enable the vision encoder on AMD GPUs

📊 Changes

2 files changed (+27 additions, -11 deletions)

View changed files

📝 maya.py (+18 -11)
📝 tools/vision/CMakeLists.txt (+9 -0)

📄 Description

What

The HIP port was text-only: maya-vision built CUDA-only, and setup returned early on HIP ("HIP port: text only; vision is not enabled"). maya-vision is llama.cpp's mtmd at the pinned commit, though, and its ggml has had a HIP backend for years - so the CUDA build wires up the same way there, and the engine side needs nothing (it reads the embeddings from files, and its VLEND / VRECLAIM lending already covers the on-demand encoder).

Changes

  1. tools/vision/CMakeLists.txt: a STRATA_VISION_HIP option that turns GGML_HIP on (with AMDGPU_TARGETS / CMAKE_HIP_ARCHITECTURES from the targets), mutually exclusive with STRATA_VISION_CUDA (which stays what sets GGML_CUDA).
  2. maya.py, compile_vision(): a HIP branch that passes the target flags instead of nvcc's, and -DCMAKE_EXE_LINKER_FLAGS=-no-pie (Ubuntu's PIE default breaks the final link: ggml-hip's objects are position-dependent while the executable defaults to PIE - BFD answers "relocation R_X86_64_32 ... can not be used when making a PIE object").
  3. maya.py, vision_step(): no more HIP early-return - HIP setups download the mmproj and vocab and build like CUDA setups do. VSTAMP records the backend beside the archs, so a rebuild after switching backends triggers.

Tested

Ubuntu 24.04, ROCm 7.2.2, RDNA4 (gfx1201, 32 GB):

  • the build completes (the pinned llama.cpp compiles its HIP flash-attention instances clean for gfx1201)
  • on GPU: --measure reports a 2.9 GB footprint (weights + work buffers at the 2048 px warm-up), and a test picture encodes with the right result
  • live in the full stack (GLM-5.3-Flash Maya-M-Derisked, 512k context, first GPU 94% held by the engine): the server measures the encoder once, credits it 2.99 GB at 4096 image tokens, the engine lends 4.08 GB of expert-cache tail while pictures encode (VLEND / VRECLAIM), and a real image through /v1/chat/completions came back correct - 391 image tokens in the prompt, 164 tok/s prefill, 16 tok/s decode on this box
  • the CPU paths (no --gpu, and the automatic fallback when the card cannot lend) encode correctly too

One caveat found on the way (not addressed here): --no-flash-attn on the GPU wants roughly 28 GB of graph buffers at the 2048 px warm-up - the no-FA attention - which a card shared with the engine cannot give; ggml's allocator does not check the failed reserve, so the process segfaults. With flash attention (the default) the encoder is 2.9 GB and works. A guard at that allocation site might be worth its own issue.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/345 **Author:** [@Ehco](https://github.com/Ehco) **Created:** 10/21/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `hip-vision-encoder` --- ### 📝 Commits (1) - [`c75f890`](https://github.com/mw00/project-maya/commit/c75f890174c9c0566c68a7b17ec8d069d306f298) HIP: build and enable the vision encoder on AMD GPUs ### 📊 Changes **2 files changed** (+27 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `maya.py` (+18 -11) 📝 `tools/vision/CMakeLists.txt` (+9 -0) </details> ### 📄 Description ## What The HIP port was text-only: `maya-vision` built CUDA-only, and setup returned early on HIP ("HIP port: text only; vision is not enabled"). `maya-vision` is llama.cpp's mtmd at the pinned commit, though, and its ggml has had a HIP backend for years - so the CUDA build wires up the same way there, and the engine side needs nothing (it reads the embeddings from files, and its VLEND / VRECLAIM lending already covers the on-demand encoder). ## Changes 1. `tools/vision/CMakeLists.txt`: a `STRATA_VISION_HIP` option that turns `GGML_HIP` on (with `AMDGPU_TARGETS` / `CMAKE_HIP_ARCHITECTURES` from the targets), mutually exclusive with `STRATA_VISION_CUDA` (which stays what sets `GGML_CUDA`). 2. `maya.py`, `compile_vision()`: a HIP branch that passes the target flags instead of nvcc's, and `-DCMAKE_EXE_LINKER_FLAGS=-no-pie` (Ubuntu's PIE default breaks the final link: ggml-hip's objects are position-dependent while the executable defaults to PIE - BFD answers "relocation R_X86_64_32 ... can not be used when making a PIE object"). 3. `maya.py`, `vision_step()`: no more HIP early-return - HIP setups download the mmproj and vocab and build like CUDA setups do. `VSTAMP` records the backend beside the archs, so a rebuild after switching backends triggers. ## Tested Ubuntu 24.04, ROCm 7.2.2, RDNA4 (gfx1201, 32 GB): - the build completes (the pinned llama.cpp compiles its HIP flash-attention instances clean for gfx1201) - on GPU: `--measure` reports a 2.9 GB footprint (weights + work buffers at the 2048 px warm-up), and a test picture encodes with the right result - live in the full stack (GLM-5.3-Flash Maya-M-Derisked, 512k context, first GPU 94% held by the engine): the server measures the encoder once, credits it 2.99 GB at 4096 image tokens, the engine lends 4.08 GB of expert-cache tail while pictures encode (VLEND / VRECLAIM), and a real image through `/v1/chat/completions` came back correct - 391 image tokens in the prompt, 164 tok/s prefill, 16 tok/s decode on this box - the CPU paths (no `--gpu`, and the automatic fallback when the card cannot lend) encode correctly too One caveat found on the way (not addressed here): `--no-flash-attn` on the GPU wants roughly 28 GB of graph buffers at the 2048 px warm-up - the no-FA attention - which a card shared with the engine cannot give; ggml's allocator does not check the failed reserve, so the process segfaults. With flash attention (the default) the encoder is 2.9 GB and works. A guard at that allocation site might be worth its own issue. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#478
No description provided.