Skip to content

Commit d7da1eb

Browse files
authored
invert KCPP_BAKE_SD_VOCAB logic, move define to sdtype_adapter.cpp (LostRuins#1803)
Using KCPP_BAKE_SD_VOCAB to turn off the change to not embed the vocabulary files makes testing new upstream merges harder, because we then need to set that macro on the sd.cpp original build. So, revert the tests, making the define turn the change on. Also, since model.cpp is always built by Koboldcpp as part of the sdtype_adapter.cpp, it's enough to set the macro on that file.
1 parent 5b6ed8b commit d7da1eb

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ main: tools/main/main.cpp common/arg.cpp build-info.h ggml.o ggml-cpu.o ggml-ops
763763
mainvk: tools/main/main.cpp common/arg.cpp build-info.h ggml_v4_vulkan.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_vulkan.o llava.o ggml-backend_vulkan.o ggml-backend-reg_vulkan.o ggml-vulkan.o ggml-vulkan-shaders.o ggml-repack.o $(OBJS_FULL) $(OBJS) lib/vulkan-1.lib
764764
$(CXX) $(CXXFLAGS) -DGGML_USE_VULKAN -DSD_USE_VULKAN $(filter-out %.h,$^) -o $@ $(LDFLAGS)
765765
sdmain: otherarch/sdcpp/util.cpp otherarch/sdcpp/main.cpp otherarch/sdcpp/stable-diffusion.cpp otherarch/sdcpp/upscaler.cpp otherarch/sdcpp/model.cpp otherarch/sdcpp/tokenize_util.cpp otherarch/sdcpp/thirdparty/zip.c build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o ggml-backend_default.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)
766-
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -DKCPP_BAKE_SD_VOCAB -o $@ $(LDFLAGS)
766+
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
767767
whispermain: otherarch/whispercpp/main.cpp otherarch/whispercpp/whisper.cpp build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o ggml-backend_default.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)
768768
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
769769
ttsmain: tools/tts/tts.cpp common/arg.cpp build-info.h ggml.o ggml-cpu.o ggml-ops.o ggml-vec.o ggml-binops.o ggml-unops.o llama.o console.o llavaclip_default.o llava.o ggml-backend_default.o ggml-backend-reg_default.o ggml-repack.o $(OBJS_FULL) $(OBJS)

otherarch/sdcpp/model.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "model.h"
1818
#include "stable-diffusion.h"
1919
#include "util.h"
20-
#ifdef KCPP_BAKE_SD_VOCAB
20+
#ifndef KCPP_BAKE_SD_VOCAB
2121
#include "vocab.hpp"
2222
#include "vocab_qwen.hpp"
2323
#include "vocab_umt5.hpp"
@@ -2056,7 +2056,7 @@ void ModelLoader::set_wtype_override(ggml_type wtype, std::string prefix) {
20562056
}
20572057

20582058
std::string ModelLoader::load_merges() {
2059-
#ifdef KCPP_BAKE_SD_VOCAB
2059+
#ifndef KCPP_BAKE_SD_VOCAB
20602060
std::string merges_utf8_str(reinterpret_cast<const char*>(merges_utf8_c_str), sizeof(merges_utf8_c_str));
20612061
return merges_utf8_str;
20622062
#else
@@ -2065,7 +2065,7 @@ std::string ModelLoader::load_merges() {
20652065
}
20662066

20672067
std::string ModelLoader::load_qwen2_merges() {
2068-
#ifdef KCPP_BAKE_SD_VOCAB
2068+
#ifndef KCPP_BAKE_SD_VOCAB
20692069
std::string merges_utf8_str(reinterpret_cast<const char*>(qwen2_merges_utf8_c_str), sizeof(qwen2_merges_utf8_c_str));
20702070
return merges_utf8_str;
20712071
#else
@@ -2074,7 +2074,7 @@ std::string ModelLoader::load_qwen2_merges() {
20742074
}
20752075

20762076
std::string ModelLoader::load_t5_tokenizer_json() {
2077-
#ifdef KCPP_BAKE_SD_VOCAB
2077+
#ifndef KCPP_BAKE_SD_VOCAB
20782078
std::string json_str(reinterpret_cast<const char*>(t5_tokenizer_json_str), sizeof(t5_tokenizer_json_str));
20792079
return json_str;
20802080
#else
@@ -2083,7 +2083,7 @@ std::string ModelLoader::load_t5_tokenizer_json() {
20832083
}
20842084

20852085
std::string ModelLoader::load_umt5_tokenizer_json() {
2086-
#ifdef KCPP_BAKE_SD_VOCAB
2086+
#ifndef KCPP_BAKE_SD_VOCAB
20872087
std::string json_str(reinterpret_cast<const char*>(umt5_tokenizer_json_str), sizeof(umt5_tokenizer_json_str));
20882088
return json_str;
20892089
#else
@@ -2681,4 +2681,4 @@ bool convert(const char* input_path, const char* vae_path, const char* output_pa
26812681
}
26822682
bool success = model_loader.save_to_gguf_file(output_path, (ggml_type)output_type, tensor_type_rules);
26832683
return success;
2684-
}
2684+
}

otherarch/sdcpp/sdtype_adapter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <algorithm>
1414
#include <filesystem>
1515

16+
#define KCPP_BAKE_SD_VOCAB
17+
1618
#include "model_adapter.h"
1719

1820
std::string sd_load_merges();

0 commit comments

Comments
 (0)