Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

- feat(example): support server video inputs and Gemma text tool calls by @abetlen in #2291
- feat: update llama.cpp to ggml-org/llama.cpp@3e7bd4f39
- feat: update llama.cpp to ggml-org/llama.cpp@f05cf4676
- fix(example): support multi-step Responses tool streaming by @abetlen in #2288
- fix(ci): Repair Linux accelerator wheels for manylinux publishing

Expand Down
56 changes: 55 additions & 1 deletion llama_cpp/mtmd_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
mtmd_input_chunks_p = NewType("mtmd_input_chunks_p", int)
mtmd_input_chunks_p_ctypes = c_void_p

mtmd_batch_p = NewType("mtmd_batch_p", int)
mtmd_batch_p_ctypes = c_void_p

# Enums
MTMD_INPUT_CHUNK_TYPE_TEXT = 0
MTMD_INPUT_CHUNK_TYPE_IMAGE = 1
Expand All @@ -102,6 +105,7 @@ class mtmd_context_params(Structure):
image_max_tokens: int
cb_eval: llama_cpp.ggml_backend_sched_eval_callback
cb_eval_user_data: c_void_p
batch_max_tokens: int

_fields_ = [
("use_gpu", c_bool),
Expand All @@ -115,6 +119,7 @@ class mtmd_context_params(Structure):
("image_max_tokens", c_int),
("cb_eval", llama_cpp.ggml_backend_sched_eval_callback),
("cb_eval_user_data", c_void_p),
("batch_max_tokens", c_int),
]


Expand Down Expand Up @@ -596,7 +601,7 @@ def mtmd_image_tokens_get_decoder_pos(
c_int,
)
def mtmd_encode(ctx: mtmd_context_p, image_tokens: mtmd_image_tokens_p, /) -> int:
"""Run an MTMD encode pass for image tokens."""
"""Run a deprecated MTMD encode pass for image tokens."""
...


Expand All @@ -618,6 +623,55 @@ def mtmd_get_output_embd(ctx: mtmd_context_p, /) -> Optional[CtypesArray[c_float
...


# MTMD_API mtmd_batch * mtmd_batch_init(mtmd_context * ctx);
@ctypes_function("mtmd_batch_init", [mtmd_context_p_ctypes], mtmd_batch_p_ctypes)
def mtmd_batch_init(ctx: mtmd_context_p, /) -> Optional[mtmd_batch_p]:
"""Initialize an MTMD media chunk batch for a context."""
...


# MTMD_API void mtmd_batch_free(mtmd_batch * batch);
@ctypes_function("mtmd_batch_free", [mtmd_batch_p_ctypes], None)
def mtmd_batch_free(batch: mtmd_batch_p, /): ...


# MTMD_API int32_t mtmd_batch_add_chunk(mtmd_batch * batch, const mtmd_input_chunk * chunk);
@ctypes_function(
"mtmd_batch_add_chunk",
[mtmd_batch_p_ctypes, mtmd_input_chunk_p_ctypes],
c_int,
)
def mtmd_batch_add_chunk(
batch: mtmd_batch_p,
chunk: mtmd_input_chunk_p,
/,
) -> int:
"""Add a media chunk to an MTMD batch."""
...


# MTMD_API int32_t mtmd_batch_encode(mtmd_batch * batch);
@ctypes_function("mtmd_batch_encode", [mtmd_batch_p_ctypes], c_int)
def mtmd_batch_encode(batch: mtmd_batch_p, /) -> int:
"""Run an MTMD encode pass for all chunks in a batch."""
...


# MTMD_API float * mtmd_batch_get_output_embd(mtmd_batch * batch, const mtmd_input_chunk * chunk);
@ctypes_function(
"mtmd_batch_get_output_embd",
[mtmd_batch_p_ctypes, mtmd_input_chunk_p_ctypes],
POINTER(c_float),
)
def mtmd_batch_get_output_embd(
batch: mtmd_batch_p,
chunk: mtmd_input_chunk_p,
/,
) -> Optional[CtypesArray[c_float]]:
"""Get output embeddings for a chunk from the last batch encode pass."""
...


# MTMD_API struct mtmd_caps mtmd_get_cap_from_file(const char * mmproj_fname);
@ctypes_function("mtmd_get_cap_from_file", [c_char_p], mtmd_caps)
def mtmd_get_cap_from_file(mmproj_fname: bytes, /) -> mtmd_caps:
Expand Down
2 changes: 1 addition & 1 deletion vendor/llama.cpp
Submodule llama.cpp updated 60 files
+8 −7 .github/workflows/release.yml
+0 −7 .github/workflows/ui-build-self-hosted.yml
+1 −12 .github/workflows/ui-build.yml
+6 −0 .github/workflows/ui-publish.yml
+7 −0 common/arg.cpp
+1 −0 common/common.h
+29 −6 common/fit.cpp
+10 −4 common/fit.h
+2 −2 common/jinja/runtime.cpp
+26 −7 common/jinja/value.cpp
+31 −31 docs/ops.md
+7,157 −4,196 docs/ops/Vulkan.csv
+107 −56 ggml/src/ggml-vulkan/ggml-vulkan.cpp
+0 −21 ggml/src/ggml-vulkan/vulkan-shaders/abs.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/ceil.comp
+3 −3 ggml/src/ggml-vulkan/vulkan-shaders/diag.comp
+0 −27 ggml/src/ggml-vulkan/vulkan-shaders/elu.comp
+0 −20 ggml/src/ggml-vulkan/vulkan-shaders/exp.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/floor.comp
+0 −25 ggml/src/ggml-vulkan/vulkan-shaders/gelu.comp
+0 −39 ggml/src/ggml-vulkan/vulkan-shaders/gelu_erf.comp
+0 −23 ggml/src/ggml-vulkan/vulkan-shaders/gelu_quick.comp
+21 −19 ggml/src/ggml-vulkan/vulkan-shaders/generic_unary_head.glsl
+23 −4 ggml/src/ggml-vulkan/vulkan-shaders/glu_head.glsl
+14 −18 ggml/src/ggml-vulkan/vulkan-shaders/glu_main.glsl
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/hardsigmoid.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/hardswish.comp
+0 −20 ggml/src/ggml-vulkan/vulkan-shaders/neg.comp
+0 −21 ggml/src/ggml-vulkan/vulkan-shaders/relu.comp
+3 −3 ggml/src/ggml-vulkan/vulkan-shaders/repeat_back.comp
+3 −3 ggml/src/ggml-vulkan/vulkan-shaders/roll.comp
+0 −29 ggml/src/ggml-vulkan/vulkan-shaders/round.comp
+0 −21 ggml/src/ggml-vulkan/vulkan-shaders/sgn.comp
+0 −20 ggml/src/ggml-vulkan/vulkan-shaders/sigmoid.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/silu.comp
+0 −23 ggml/src/ggml-vulkan/vulkan-shaders/softplus.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/step.comp
+0 −20 ggml/src/ggml-vulkan/vulkan-shaders/tanh.comp
+3 −3 ggml/src/ggml-vulkan/vulkan-shaders/tri.comp
+0 −22 ggml/src/ggml-vulkan/vulkan-shaders/trunc.comp
+144 −0 ggml/src/ggml-vulkan/vulkan-shaders/unary.comp
+44 −42 ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp
+0 −35 ggml/src/ggml-vulkan/vulkan-shaders/xielu.comp
+85 −197 scripts/ui-assets.cmake
+24 −0 tests/test-jinja.cpp
+4 −0 tools/mtmd/clip-graph.h
+54 −23 tools/mtmd/clip.cpp
+5 −3 tools/mtmd/clip.h
+11 −9 tools/mtmd/models/gemma4v.cpp
+1 −0 tools/mtmd/models/models.h
+8 −5 tools/mtmd/mtmd-helper.h
+289 −59 tools/mtmd/mtmd.cpp
+36 −4 tools/mtmd/mtmd.h
+11 −3 tools/server/server-common.cpp
+4 −0 tools/server/server-common.h
+109 −19 tools/server/server-context.cpp
+58 −201 tools/server/server-http.cpp
+3 −1 tools/ui/CMakeLists.txt
+172 −28 tools/ui/embed.cpp
+1 −2 tools/ui/scripts/vite-plugin-build-info.ts
Loading