Skip to content

Commit 5806435

Browse files
committed
Merge remote-tracking branch 'upstream/master' into gigachat-model
2 parents 6e13df8 + 89d604f commit 5806435

File tree

28 files changed

+1879
-117
lines changed

28 files changed

+1879
-117
lines changed

.devops/nix/package.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# Increases the runtime closure size by ~700M
3232
useMpi ? false,
3333
useRocm ? config.rocmSupport,
34+
rocmGpuTargets ? builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets,
3435
enableCurl ? true,
3536
useVulkan ? false,
3637
llamaVersion ? "0.0.0", # Arbitrary version, substituted by the flake
@@ -188,7 +189,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
188189
]
189190
++ optionals useRocm [
190191
(cmakeFeature "CMAKE_HIP_COMPILER" "${rocmPackages.llvm.clang}/bin/clang")
191-
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" (builtins.concatStringsSep ";" rocmPackages.clr.gpuTargets))
192+
(cmakeFeature "CMAKE_HIP_ARCHITECTURES" rocmGpuTargets)
192193
]
193194
++ optionals useMetalKit [
194195
(lib.cmakeFeature "CMAKE_C_FLAGS" "-D__ARM_FEATURE_DOTPROD=1")

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ BUILD_TARGETS = \
2222
llama-infill \
2323
llama-llava-cli \
2424
llama-minicpmv-cli\
25+
llama-qwen2vl-cli\
2526
llama-lookahead \
2627
llama-lookup \
2728
llama-lookup-create \
@@ -1404,6 +1405,14 @@ llama-minicpmv-cli: examples/llava/minicpmv-cli.cpp \
14041405
$(OBJ_ALL)
14051406
$(CXX) $(CXXFLAGS) $< $(filter-out %.h $<,$^) -o $@ $(LDFLAGS) -Wno-cast-qual
14061407

1408+
llama-qwen2vl-cli: examples/llava/qwen2vl-cli.cpp \
1409+
examples/llava/llava.cpp \
1410+
examples/llava/llava.h \
1411+
examples/llava/clip.cpp \
1412+
examples/llava/clip.h \
1413+
$(OBJ_ALL)
1414+
$(CXX) $(CXXFLAGS) $< $(filter-out %.h $<,$^) -o $@ $(LDFLAGS) -Wno-cast-qual
1415+
14071416
ifeq ($(UNAME_S),Darwin)
14081417
swift: examples/batched.swift
14091418
(cd examples/batched.swift; make build)

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Instructions for adding support for new models: [HOWTO-add-model.md](docs/develo
111111
- [x] [Mini CPM](https://huggingface.co/models?search=MiniCPM)
112112
- [x] [Moondream](https://huggingface.co/vikhyatk/moondream2)
113113
- [x] [Bunny](https://github.com/BAAI-DCAI/Bunny)
114+
- [x] [Qwen2-VL](https://huggingface.co/collections/Qwen/qwen2-vl-66cee7455501d7126940800d)
114115

115116
</details>
116117

convert_hf_to_gguf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,6 +2004,29 @@ def set_gguf_parameters(self):
20042004
self.gguf_writer.add_rope_scaling_orig_ctx_len(self.hparams["rope_scaling"]["original_max_position_embeddings"])
20052005

20062006

2007+
@Model.register("Qwen2VLForConditionalGeneration")
2008+
class Qwen2VLModel(Model):
2009+
model_arch = gguf.MODEL_ARCH.QWEN2VL
2010+
2011+
def set_gguf_parameters(self):
2012+
super().set_gguf_parameters()
2013+
mrope_section = self.hparams["rope_scaling"]["mrope_section"]
2014+
mrope_section += [0] * max(0, 4 - len(mrope_section))
2015+
self.gguf_writer.add_rope_dimension_sections(mrope_section)
2016+
2017+
def set_vocab(self):
2018+
try:
2019+
self._set_vocab_sentencepiece()
2020+
except FileNotFoundError:
2021+
self._set_vocab_gpt2()
2022+
2023+
def get_tensors(self) -> Iterator[tuple[str, Tensor]]:
2024+
for name, data in super().get_tensors():
2025+
if name.startswith("visual."):
2026+
continue
2027+
yield name, data
2028+
2029+
20072030
@Model.register("Qwen2MoeForCausalLM")
20082031
class Qwen2MoeModel(Model):
20092032
model_arch = gguf.MODEL_ARCH.QWEN2MOE

examples/llava/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,10 @@ set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME llama-minicpmv-cli)
4343
install(TARGETS ${TARGET} RUNTIME)
4444
target_link_libraries(${TARGET} PRIVATE common llava ${CMAKE_THREAD_LIBS_INIT})
4545
target_compile_features(${TARGET} PRIVATE cxx_std_17)
46+
47+
set(TARGET llama-qwen2vl-cli)
48+
add_executable(${TARGET} qwen2vl-cli.cpp)
49+
set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME llama-qwen2vl-cli)
50+
install(TARGETS ${TARGET} RUNTIME)
51+
target_link_libraries(${TARGET} PRIVATE common llava ${CMAKE_THREAD_LIBS_INIT})
52+
target_compile_features(${TARGET} PRIVATE cxx_std_17)

0 commit comments

Comments
 (0)