mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-09 18:36:33 +00:00
chore: format code
This commit is contained in:
1 parent
40b1788476
commit
e0ed724e28
69 files changed
+711
-441
No files matched your search
@@ -234,11 +234,11 @@ json make_async_job_json(const AsyncJobManager& manager, const AsyncGenerationJo
|
||||
job.status == AsyncJobStatus::Cancelled) {
|
||||
result["result"] = nullptr;
|
||||
result["error"] = {
|
||||
{"code",
|
||||
{"code",
|
||||
job.error_code.empty()
|
||||
? (job.status == AsyncJobStatus::Cancelled ? "cancelled" : "generation_failed")
|
||||
: job.error_code},
|
||||
{"message", job.error_message},
|
||||
? (job.status == AsyncJobStatus::Cancelled ? "cancelled" : "generation_failed")
|
||||
: job.error_code},
|
||||
{"message", job.error_message},
|
||||
};
|
||||
} else {
|
||||
result["result"] = nullptr;
|
||||
|
||||
@@ -19,7 +19,7 @@ struct ModelSlot {
|
||||
const char* id;
|
||||
const char* label;
|
||||
std::vector<std::string> categories;
|
||||
std::string SDContextParams::*field;
|
||||
std::string SDContextParams::* field;
|
||||
};
|
||||
|
||||
static const ModelSlot k_model_slots[] = {
|
||||
|
||||
@@ -163,11 +163,11 @@ static bool build_openai_edit_request(const httplib::Request& req,
|
||||
int img_h = 0;
|
||||
int resolved_channel = 0;
|
||||
uint8_t* raw_pixels = load_image_from_memory(
|
||||
reinterpret_cast<const char*>(bytes.data()),
|
||||
static_cast<int>(bytes.size()),
|
||||
img_w, img_h, resolved_channel,
|
||||
0, 0,
|
||||
0);
|
||||
reinterpret_cast<const char*>(bytes.data()),
|
||||
static_cast<int>(bytes.size()),
|
||||
img_w, img_h, resolved_channel,
|
||||
0, 0,
|
||||
0);
|
||||
if (raw_pixels == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@@ -301,12 +301,12 @@ void register_openai_api_endpoints(httplib::Server& svr, ServerRuntime& rt) {
|
||||
: request.output_format == "webp"
|
||||
? EncodedImageFormat::WEBP
|
||||
: EncodedImageFormat::PNG,
|
||||
results[i].data,
|
||||
results[i].width,
|
||||
results[i].height,
|
||||
results[i].channel,
|
||||
params,
|
||||
request.output_compression);
|
||||
results[i].data,
|
||||
results[i].width,
|
||||
results[i].height,
|
||||
results[i].channel,
|
||||
params,
|
||||
request.output_compression);
|
||||
if (image_bytes.empty()) {
|
||||
LOG_ERROR("write image to mem failed");
|
||||
continue;
|
||||
@@ -371,12 +371,12 @@ void register_openai_api_endpoints(httplib::Server& svr, ServerRuntime& rt) {
|
||||
request.gen_params.seed + i / images_per_batch)
|
||||
: "";
|
||||
auto image_bytes = encode_image_to_vector(request.output_format == "jpeg" ? EncodedImageFormat::JPEG : EncodedImageFormat::PNG,
|
||||
results[i].data,
|
||||
results[i].width,
|
||||
results[i].height,
|
||||
results[i].channel,
|
||||
params,
|
||||
request.output_compression);
|
||||
results[i].data,
|
||||
results[i].width,
|
||||
results[i].height,
|
||||
results[i].channel,
|
||||
params,
|
||||
request.output_compression);
|
||||
json item;
|
||||
item["b64_json"] = base64_encode(image_bytes);
|
||||
out["data"].push_back(item);
|
||||
|
||||
@@ -543,7 +543,7 @@ static void preview_callback(int step, int frame_count, sd_image_t* frames, bool
|
||||
std::lock_guard<std::mutex> lock(g_preview.mutex);
|
||||
g_preview.b64 = std::move(b64);
|
||||
g_preview.step = static_cast<int>(std::min<int64_t>(step < 0 ? -static_cast<int64_t>(step) : step,
|
||||
std::max(0, info.total_steps)));
|
||||
std::max(0, info.total_steps)));
|
||||
g_preview.total = std::max(0, info.total_steps);
|
||||
g_preview.job_no = std::max(0, info.sample_pass - 1);
|
||||
}
|
||||
|
||||
@@ -381,8 +381,8 @@ static json make_capabilities_json(ServerRuntime& runtime) {
|
||||
json top_level_defaults = json::object();
|
||||
json top_level_output_formats = json::array();
|
||||
json top_level_features = {
|
||||
{"cancel_queued", true},
|
||||
{"cancel_generating", true},
|
||||
{"cancel_queued", true},
|
||||
{"cancel_generating", true},
|
||||
};
|
||||
std::string current_mode = "";
|
||||
if (supports_img) {
|
||||
@@ -410,14 +410,14 @@ static json make_capabilities_json(ServerRuntime& runtime) {
|
||||
result["defaults"] = top_level_defaults;
|
||||
result["defaults_by_mode"] = defaults_by_mode;
|
||||
result["limits"] = {
|
||||
{"min_width", 64},
|
||||
{"max_width", k_max_generation_dimension},
|
||||
{"min_height", 64},
|
||||
{"max_height", k_max_generation_dimension},
|
||||
{"max_batch_count", 8},
|
||||
{"max_queue_size", manager.max_pending_jobs},
|
||||
{"max_upscale_width", k_max_upscale_dimension},
|
||||
{"max_upscale_height", k_max_upscale_dimension},
|
||||
{"min_width", 64},
|
||||
{"max_width", k_max_generation_dimension},
|
||||
{"min_height", 64},
|
||||
{"max_height", k_max_generation_dimension},
|
||||
{"max_batch_count", 8},
|
||||
{"max_queue_size", manager.max_pending_jobs},
|
||||
{"max_upscale_width", k_max_upscale_dimension},
|
||||
{"max_upscale_height", k_max_upscale_dimension},
|
||||
};
|
||||
result["samplers"] = samplers;
|
||||
result["schedulers"] = schedulers;
|
||||
@@ -520,7 +520,7 @@ void register_sdcpp_api_endpoints(httplib::Server& svr, ServerRuntime& rt) {
|
||||
const bool valid = value.is_number_unsigned()
|
||||
? value.get<uint64_t>() <= static_cast<uint64_t>(std::numeric_limits<int>::max())
|
||||
: value.is_number_integer() && value.get<int64_t>() >= std::numeric_limits<int>::min() &&
|
||||
value.get<int64_t>() <= std::numeric_limits<int>::max();
|
||||
value.get<int64_t>() <= std::numeric_limits<int>::max();
|
||||
if (!valid) {
|
||||
res.status = 400;
|
||||
res.set_content(json({{"error", std::string(key) + " must be a 32-bit integer"}}).dump(), "application/json");
|
||||
@@ -631,12 +631,12 @@ void register_sdcpp_api_endpoints(httplib::Server& svr, ServerRuntime& rt) {
|
||||
auto image_bytes = encode_image_to_vector(format == "jpeg" ? EncodedImageFormat::JPEG
|
||||
: format == "webp" ? EncodedImageFormat::WEBP
|
||||
: EncodedImageFormat::PNG,
|
||||
result.data,
|
||||
result.width,
|
||||
result.height,
|
||||
result.channel,
|
||||
"",
|
||||
compression);
|
||||
result.data,
|
||||
result.width,
|
||||
result.height,
|
||||
result.channel,
|
||||
"",
|
||||
compression);
|
||||
if (image_bytes.empty()) {
|
||||
res.status = 500;
|
||||
res.set_content(R"({"error":"the result could not be encoded"})", "application/json");
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
# See https://llvm.org/LICENSE.txt for license information.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
################################################################################
|
||||
#
|
||||
# This script will install the llvm toolchain on the different
|
||||
# Debian and Ubuntu versions
|
||||
|
||||
# This script is stored on:
|
||||
# https://github.com/opencollab/llvm-jenkins.debian.net/blob/master/llvm.sh
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
info() { printf "[info] %s\n" "$*"; }
|
||||
warn() { printf "[warn] %s\n" "$*" >&2; }
|
||||
# error MESSAGE [EXIT_CODE] — default exit code is 1
|
||||
error() {
|
||||
local msg="$1"
|
||||
local code="${2:-1}"
|
||||
printf "[error] %s\n" "$msg" >&2
|
||||
exit "$code"
|
||||
}
|
||||
|
||||
usage() {
|
||||
set +x
|
||||
echo "Usage: $0 [llvm_major_version] [all] [OPTIONS]" 1>&2
|
||||
echo -e "all\t\t\tInstall all packages." 1>&2
|
||||
echo -e "-n=code_name\t\tSpecifies the distro codename, for example bionic" 1>&2
|
||||
echo -e "-h\t\t\tPrints this help." 1>&2
|
||||
echo -e "-m=repo_base_url\tSpecifies the base URL from which to download." 1>&2
|
||||
exit $#
|
||||
}
|
||||
|
||||
CURRENT_LLVM_STABLE=22
|
||||
BASE_URL="https://apt.llvm.org"
|
||||
|
||||
NEW_DEBIAN_DISTROS=("trixie" "forky" "unstable")
|
||||
# Set default values for commandline arguments
|
||||
# We default to the current stable branch of LLVM
|
||||
LLVM_VERSION=$CURRENT_LLVM_STABLE
|
||||
ALL=0
|
||||
DISTRO=$(lsb_release -is)
|
||||
VERSION_CODENAME=$(lsb_release -cs)
|
||||
VERSION=$(lsb_release -sr)
|
||||
UBUNTU_CODENAME=""
|
||||
CODENAME_FROM_ARGUMENTS=""
|
||||
# Obtain VERSION_CODENAME and UBUNTU_CODENAME (for Ubuntu and its derivatives)
|
||||
source /etc/os-release
|
||||
DISTRO=${DISTRO,,}
|
||||
|
||||
# Downloader abstraction: prefer wget, fall back to curl
|
||||
download_key() {
|
||||
local url="$1"
|
||||
if command -v wget &>/dev/null; then
|
||||
wget -qO- --retry-connrefused --waitretry=1 --tries=3 "$url"
|
||||
elif command -v curl &>/dev/null; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf --retry 3 "$url"
|
||||
else
|
||||
error "Neither wget nor curl found. Install one and retry." 4
|
||||
fi
|
||||
}
|
||||
|
||||
check_url() {
|
||||
local url="$1"
|
||||
if command -v wget &>/dev/null; then
|
||||
wget -q --method=HEAD --timeout=15 --tries=3 "$url" &>/dev/null
|
||||
elif command -v curl &>/dev/null; then
|
||||
curl --proto '=https' --tlsv1.2 -sSf --head --retry 2 "$url" >/dev/null 2>&1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if this is a new Debian distro
|
||||
is_new_debian=0
|
||||
if [[ "${DISTRO}" == "debian" ]]; then
|
||||
for new_distro in "${NEW_DEBIAN_DISTROS[@]}"; do
|
||||
if [[ "${VERSION_CODENAME}" == "${new_distro}" ]]; then
|
||||
is_new_debian=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Check for required tools
|
||||
needed_binaries=(lsb_release wget gpg)
|
||||
# add-apt-repository is not needed for newer Debian distros
|
||||
if [[ $is_new_debian -eq 0 ]]; then
|
||||
needed_binaries+=(add-apt-repository)
|
||||
fi
|
||||
|
||||
missing_binaries=()
|
||||
for binary in "${needed_binaries[@]}"; do
|
||||
if ! command -v "$binary" &>/dev/null; then
|
||||
if [[ "$binary" == "wget" ]] && command -v curl &>/dev/null; then
|
||||
continue
|
||||
fi
|
||||
missing_binaries+=("$binary")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#missing_binaries[@]} -gt 0 ]] ; then
|
||||
error "Missing required tools: ${missing_binaries[*]}
|
||||
(hint: apt install lsb-release wget software-properties-common gnupg)
|
||||
curl is also supported as an alternative to wget" 4
|
||||
fi
|
||||
|
||||
case ${DISTRO} in
|
||||
debian)
|
||||
# Debian Forky has a workaround because of
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1038383
|
||||
if [[ "${VERSION}" == "unstable" ]] || [[ "${VERSION}" == "testing" ]] || [[ "${VERSION_CODENAME}" == "forky" ]]; then
|
||||
CODENAME=unstable
|
||||
LINKNAME=
|
||||
else
|
||||
# "stable" Debian release
|
||||
CODENAME=${VERSION_CODENAME}
|
||||
LINKNAME=-${CODENAME}
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
# ubuntu and its derivatives
|
||||
if [[ -n "${UBUNTU_CODENAME}" ]]; then
|
||||
CODENAME=${UBUNTU_CODENAME}
|
||||
if [[ -n "${CODENAME}" ]]; then
|
||||
LINKNAME=-${CODENAME}
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# check for long options
|
||||
for arg in "$@"; do
|
||||
case "${arg}" in
|
||||
(--help|-h) usage ;;
|
||||
(--version) usage error ;;
|
||||
(--) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# read optional command line arguments
|
||||
if [ "$#" -ge 1 ] && [ "${1::1}" != "-" ]; then
|
||||
if [ "$1" != "all" ]; then
|
||||
LLVM_VERSION=$1
|
||||
else
|
||||
# special case for ./llvm.sh all
|
||||
ALL=1
|
||||
fi
|
||||
OPTIND=2
|
||||
if [ "$#" -ge 2 ]; then
|
||||
if [ "$2" == "all" ]; then
|
||||
# Install all packages
|
||||
ALL=1
|
||||
OPTIND=3
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
while getopts ":hm:n:" arg; do
|
||||
case $arg in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
m)
|
||||
BASE_URL=${OPTARG}
|
||||
;;
|
||||
n)
|
||||
CODENAME=${OPTARG}
|
||||
if [[ "${CODENAME}" == "unstable" ]]; then
|
||||
# link name does not apply to unstable repository
|
||||
LINKNAME=
|
||||
else
|
||||
LINKNAME=-${CODENAME}
|
||||
fi
|
||||
CODENAME_FROM_ARGUMENTS="true"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
error "This script must be run as root!"
|
||||
fi
|
||||
|
||||
declare -A LLVM_VERSION_PATTERNS
|
||||
LLVM_VERSION_PATTERNS[9]="-9"
|
||||
LLVM_VERSION_PATTERNS[10]="-10"
|
||||
LLVM_VERSION_PATTERNS[11]="-11"
|
||||
LLVM_VERSION_PATTERNS[12]="-12"
|
||||
LLVM_VERSION_PATTERNS[13]="-13"
|
||||
LLVM_VERSION_PATTERNS[14]="-14"
|
||||
LLVM_VERSION_PATTERNS[15]="-15"
|
||||
LLVM_VERSION_PATTERNS[16]="-16"
|
||||
LLVM_VERSION_PATTERNS[17]="-17"
|
||||
LLVM_VERSION_PATTERNS[18]="-18"
|
||||
LLVM_VERSION_PATTERNS[19]="-19"
|
||||
LLVM_VERSION_PATTERNS[20]="-20"
|
||||
LLVM_VERSION_PATTERNS[21]="-21"
|
||||
LLVM_VERSION_PATTERNS[22]="-22"
|
||||
LLVM_VERSION_PATTERNS[23]="-23"
|
||||
LLVM_VERSION_PATTERNS[24]=""
|
||||
|
||||
if [ ! ${LLVM_VERSION_PATTERNS[$LLVM_VERSION]+_} ]; then
|
||||
error "This script does not support LLVM version $LLVM_VERSION" 3
|
||||
fi
|
||||
|
||||
LLVM_VERSION_STRING=${LLVM_VERSION_PATTERNS[$LLVM_VERSION]}
|
||||
|
||||
# join the repository name
|
||||
if [[ -n "${CODENAME}" ]]; then
|
||||
REPO_NAME="deb ${BASE_URL}/${CODENAME}/ llvm-toolchain${LINKNAME}${LLVM_VERSION_STRING} main"
|
||||
# check if the repository exists for the distro and version
|
||||
if ! check_url "${BASE_URL}/${CODENAME}/"; then
|
||||
if [[ -n "${CODENAME_FROM_ARGUMENTS}" ]]; then
|
||||
error "Specified codename '${CODENAME}' is not supported by this script." 2
|
||||
else
|
||||
error "Distribution '${DISTRO}' in version '${VERSION}' is not supported by this script." 2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# install everything
|
||||
|
||||
if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then
|
||||
GPG_KEY_URL="https://apt.llvm.org/llvm-snapshot.gpg.key"
|
||||
if ! check_url "$GPG_KEY_URL"; then
|
||||
error "GPG key not reachable at $GPG_KEY_URL" 2
|
||||
fi
|
||||
download_key "$GPG_KEY_URL" | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||
fi
|
||||
|
||||
if [[ -z "`apt-key list 2> /dev/null | grep -i llvm`" ]]; then
|
||||
# Delete the key in the old format
|
||||
apt-key del AF4F7421 || true
|
||||
fi
|
||||
|
||||
|
||||
# Add repository based on distribution
|
||||
if [[ "${VERSION_CODENAME}" == "bookworm" ]]; then
|
||||
# add it twice to workaround:
|
||||
# https://github.com/llvm/llvm-project/issues/62475
|
||||
add-apt-repository -y "${REPO_NAME}"
|
||||
add-apt-repository -y "${REPO_NAME}"
|
||||
elif [[ $is_new_debian -eq 1 ]]; then
|
||||
# workaround missing add-apt-repository in newer Debian and use new source.list format
|
||||
SOURCES_FILE="/etc/apt/sources.list.d/http_apt_llvm_org_${CODENAME}_-${VERSION_CODENAME}.sources"
|
||||
TEXT_TO_ADD="Types: deb
|
||||
Architectures: amd64 arm64
|
||||
Signed-By: /etc/apt/trusted.gpg.d/apt.llvm.org.asc
|
||||
URIs: ${BASE_URL}/${CODENAME}/
|
||||
Suites: llvm-toolchain${LINKNAME}${LLVM_VERSION_STRING}
|
||||
Components: main"
|
||||
echo "$TEXT_TO_ADD" | tee -a "$SOURCES_FILE" > /dev/null
|
||||
else
|
||||
add-apt-repository -y "${REPO_NAME}"
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
PKG="clang-$LLVM_VERSION lldb-$LLVM_VERSION lld-$LLVM_VERSION clangd-$LLVM_VERSION"
|
||||
if [[ $ALL -eq 1 ]]; then
|
||||
# same as in test-install.sh
|
||||
# No worries if we have dups
|
||||
PKG="$PKG clang-tidy-$LLVM_VERSION clang-format-$LLVM_VERSION clang-tools-$LLVM_VERSION llvm-$LLVM_VERSION-dev lld-$LLVM_VERSION lldb-$LLVM_VERSION llvm-$LLVM_VERSION-tools libomp-$LLVM_VERSION-dev libc++-$LLVM_VERSION-dev libc++abi-$LLVM_VERSION-dev libclang-common-$LLVM_VERSION-dev libclang-$LLVM_VERSION-dev libclang-cpp$LLVM_VERSION-dev liblldb-$LLVM_VERSION-dev libunwind-$LLVM_VERSION-dev"
|
||||
if test $LLVM_VERSION -gt 14; then
|
||||
PKG="$PKG libclang-rt-$LLVM_VERSION-dev libpolly-$LLVM_VERSION-dev"
|
||||
fi
|
||||
fi
|
||||
apt-get install -y $PKG
|
||||
@@ -1833,11 +1833,11 @@ struct AnimaConditioner : public Conditioner {
|
||||
std::shared_ptr<RunnerWeightManager> weight_manager = nullptr,
|
||||
const TokenizerConfig& tokenizers = {}) {
|
||||
llm = std::make_shared<LLM::LLMRunner>(LLM::LLMArch::QWEN3,
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
false,
|
||||
weight_manager);
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
false,
|
||||
weight_manager);
|
||||
qwen_tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 151643);
|
||||
if (!qwen_tokenizer) {
|
||||
qwen_tokenizer = std::make_shared<Qwen2Tokenizer>();
|
||||
@@ -2026,11 +2026,11 @@ struct LLMEmbedder : public Conditioner {
|
||||
arch = LLM::LLMArch::QWEN3_5;
|
||||
}
|
||||
llm = std::make_shared<LLM::LLMRunner>(arch,
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
enable_vision,
|
||||
weight_manager);
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
enable_vision,
|
||||
weight_manager);
|
||||
int pad_id = 151643;
|
||||
if (arch == LLM::LLMArch::MISTRAL_SMALL_3_2 || arch == LLM::LLMArch::MINISTRAL_3_3B) {
|
||||
pad_id = 11;
|
||||
@@ -3312,7 +3312,7 @@ struct LLMEmbedder : public Conditioner {
|
||||
for (const auto& [index, image_embed] : image_embeds) {
|
||||
int64_t begin = std::max<int64_t>(0, index - 1);
|
||||
int64_t end = std::min<int64_t>(static_cast<int64_t>(tags.size()),
|
||||
index + image_embed.shape()[1] + 1);
|
||||
index + image_embed.shape()[1] + 1);
|
||||
std::fill(tags.begin() + begin, tags.begin() + end, 0);
|
||||
}
|
||||
int64_t tag_count = static_cast<int64_t>(tags.size());
|
||||
@@ -3492,9 +3492,9 @@ struct LLaDAImageEmbedder : public Conditioner {
|
||||
// <|endoftext|> doubles as the pad token in LLaDA2's tokenizer.json.
|
||||
tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 156892);
|
||||
query_former = std::make_shared<LLaDAImageTE::QueryFormerRunner>(backend,
|
||||
tensor_storage_map,
|
||||
query_former_prefix,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
query_former_prefix,
|
||||
weight_manager);
|
||||
text_projection = std::make_shared<LLaDAImageTE::TextProjectionRunner>(backend,
|
||||
tensor_storage_map,
|
||||
text_projection_prefix,
|
||||
@@ -3696,20 +3696,20 @@ struct LTXAVEmbedder : public Conditioner {
|
||||
LLM::LLMArch arch = detect_gemma_arch(tensor_storage_map, llm_prefix);
|
||||
LOG_INFO("ltxav text encoder: %s", arch == LLM::LLMArch::GEMMA4_12B ? "gemma 4" : "gemma 3");
|
||||
llm = std::make_shared<LLM::LLMRunner>(arch,
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
llm_prefix,
|
||||
false,
|
||||
weight_manager);
|
||||
backend,
|
||||
tensor_storage_map,
|
||||
llm_prefix,
|
||||
false,
|
||||
weight_manager);
|
||||
tokenizer = tokenizers.create(TokenizerConfig::MAIN, llm->config.vocab_size, 0, true);
|
||||
if (!tokenizer) {
|
||||
tokenizer = std::make_shared<GemmaTokenizer>();
|
||||
}
|
||||
dual_projection = tensor_storage_map.find(projector_prefix + ".video_aggregate_embed.weight") != tensor_storage_map.end();
|
||||
projector = std::make_shared<LTXAVTextProjectionRunner>(backend,
|
||||
tensor_storage_map,
|
||||
projector_prefix,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
projector_prefix,
|
||||
weight_manager);
|
||||
}
|
||||
|
||||
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors) override {
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace sd::backend_fit {
|
||||
vm_statistics64_data_t stats{};
|
||||
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
|
||||
const bool ok = host_page_size(host, &page_size) == KERN_SUCCESS &&
|
||||
host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&stats, &count) == KERN_SUCCESS;
|
||||
host_statistics64(host, HOST_VM_INFO64, (host_info64_t)&stats, &count) == KERN_SUCCESS;
|
||||
mach_port_deallocate(mach_task_self(), host);
|
||||
if (ok) {
|
||||
return ((int64_t)stats.free_count + stats.inactive_count) * page_size;
|
||||
@@ -262,10 +262,10 @@ namespace sd::backend_fit {
|
||||
|
||||
const auto& runtime_devices = plan.runtimes[ci].devices;
|
||||
const bool fits_runtime = !runtime_devices.empty() &&
|
||||
std::all_of(runtime_devices.begin(), runtime_devices.end(), [&](size_t di) {
|
||||
std::all_of(runtime_devices.begin(), runtime_devices.end(), [&](size_t di) {
|
||||
const int64_t headroom = headroom_for(ci, di);
|
||||
return headroom <= remaining[di] && comp.params_bytes <= remaining[di] - headroom;
|
||||
});
|
||||
});
|
||||
if (fits_runtime) {
|
||||
decision.params_location = ParamsLocation::MAIN_GPU;
|
||||
decision.params_device = runtime_devices.front();
|
||||
|
||||
@@ -896,7 +896,7 @@ std::optional<Tensor<float>> GGMLRunner::execute_graph(ggml_cgraph* graph, int n
|
||||
const bool last = index + 1 == plan.segments.size();
|
||||
auto fail_segment = [&](const char* phase) {
|
||||
LOG_ERROR("%s segment %zu/%zu (%s) failed during %s", get_desc().c_str(),
|
||||
index + 1, plan.segments.size(), segment.group_name.c_str(), phase);
|
||||
index + 1, plan.segments.size(), segment.group_name.c_str(), phase);
|
||||
return std::nullopt;
|
||||
};
|
||||
cut_cache_.prune(segment.live_cut_names);
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace sd {
|
||||
input_tensor->data = cached_tensor->data == nullptr
|
||||
? nullptr
|
||||
: static_cast<void*>(static_cast<char*>(cached_tensor->data) +
|
||||
input_tensor->view_offs);
|
||||
input_tensor->view_offs);
|
||||
input_tensor->extra = cached_tensor->extra;
|
||||
} else {
|
||||
input_tensor->buffer = cached_tensor->buffer;
|
||||
|
||||
@@ -154,12 +154,12 @@ struct PhotoMakerExtension : public GenerationExtension {
|
||||
|
||||
PMVersion pm_version = std::strstr(model_path.c_str(), "v2") != nullptr ? PM_VERSION_2 : PM_VERSION_1;
|
||||
pmid_model = std::make_shared<PhotoMakerIDEncoder>(ctx.backend_for(SDBackendModule::PHOTOMAKER),
|
||||
ctx.tensor_storage_map,
|
||||
"pmid",
|
||||
ctx.version,
|
||||
pm_version,
|
||||
20.f,
|
||||
ctx.model_manager);
|
||||
ctx.tensor_storage_map,
|
||||
"pmid",
|
||||
ctx.version,
|
||||
pm_version,
|
||||
20.f,
|
||||
ctx.model_manager);
|
||||
pmid_model->set_scale_overrides(ctx.params->linear_scale, ctx.params->attn_scale);
|
||||
if (pm_version == PM_VERSION_2) {
|
||||
LOG_INFO("using PhotoMaker Version 2");
|
||||
|
||||
@@ -660,7 +660,7 @@ namespace Rope {
|
||||
const int axes_dim_num = static_cast<int>(axes_dim.size());
|
||||
auto make_image_ids = [=, &result](int image_h, int image_w, int image_index) {
|
||||
std::vector<std::vector<float>> image_ids(static_cast<size_t>(bs) * image_h * image_w,
|
||||
std::vector<float>(axes_dim_num, 0.f));
|
||||
std::vector<float>(axes_dim_num, 0.f));
|
||||
result.positions.append_image(image_h, image_w);
|
||||
int h_start = -(image_h - image_h / 2);
|
||||
int w_start = -(image_w - image_w / 2);
|
||||
|
||||
@@ -543,18 +543,18 @@ namespace Boogu {
|
||||
blocks["x_embedder"] = std::make_shared<Linear>(this->config.patch_size * this->config.patch_size * this->config.in_channels, this->config.hidden_size, true);
|
||||
blocks["ref_image_patch_embedder"] = std::make_shared<Linear>(this->config.patch_size * this->config.patch_size * this->config.in_channels, this->config.hidden_size, true);
|
||||
blocks["time_caption_embed"] = std::make_shared<LuminaCombinedTimestepCaptionEmbedding>(this->config.hidden_size,
|
||||
this->config.instruction_feat_dim,
|
||||
256,
|
||||
this->config.norm_eps,
|
||||
this->config.timestep_scale);
|
||||
this->config.instruction_feat_dim,
|
||||
256,
|
||||
this->config.norm_eps,
|
||||
this->config.timestep_scale);
|
||||
|
||||
for (int i = 0; i < this->config.num_refiner_layers; i++) {
|
||||
blocks["noise_refiner." + std::to_string(i)] = std::make_shared<BooguImageTransformerBlock>(this->config.hidden_size,
|
||||
this->config.num_attention_heads,
|
||||
this->config.num_kv_heads,
|
||||
this->config.multiple_of,
|
||||
this->config.norm_eps,
|
||||
true);
|
||||
this->config.num_attention_heads,
|
||||
this->config.num_kv_heads,
|
||||
this->config.multiple_of,
|
||||
this->config.norm_eps,
|
||||
true);
|
||||
blocks["ref_image_refiner." + std::to_string(i)] = std::make_shared<BooguImageTransformerBlock>(this->config.hidden_size,
|
||||
this->config.num_attention_heads,
|
||||
this->config.num_kv_heads,
|
||||
@@ -562,11 +562,11 @@ namespace Boogu {
|
||||
this->config.norm_eps,
|
||||
true);
|
||||
blocks["context_refiner." + std::to_string(i)] = std::make_shared<BooguImageTransformerBlock>(this->config.hidden_size,
|
||||
this->config.num_attention_heads,
|
||||
this->config.num_kv_heads,
|
||||
this->config.multiple_of,
|
||||
this->config.norm_eps,
|
||||
false);
|
||||
this->config.num_attention_heads,
|
||||
this->config.num_kv_heads,
|
||||
this->config.multiple_of,
|
||||
this->config.norm_eps,
|
||||
false);
|
||||
}
|
||||
|
||||
for (int i = 0; i < this->config.num_double_stream_layers; i++) {
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Flux3 {
|
||||
set_backend_tensor_data(pe, pe_values.data());
|
||||
auto runner_ctx = get_context();
|
||||
auto out = model.forward(&runner_ctx, x, text, references, make_input(*params.timesteps), make_input(zero),
|
||||
config.flow_map ? make_input(*extra->target_timestep) : nullptr, pe);
|
||||
config.flow_map ? make_input(*extra->target_timestep) : nullptr, pe);
|
||||
ggml_build_forward_expand(gf, out);
|
||||
return gf;
|
||||
};
|
||||
|
||||
@@ -238,10 +238,10 @@ namespace HiDreamO1 {
|
||||
blocks["language_model"] = std::make_shared<LLM::TextModel>(this->config.llm);
|
||||
blocks["t_embedder1"] = std::make_shared<TimestepEmbedder>(this->config.llm.hidden_size);
|
||||
blocks["x_embedder"] = std::make_shared<BottleneckPatchEmbed>(this->config.patch_size * this->config.patch_size * 3,
|
||||
this->config.llm.hidden_size / 4,
|
||||
this->config.llm.hidden_size);
|
||||
this->config.llm.hidden_size / 4,
|
||||
this->config.llm.hidden_size);
|
||||
blocks["final_layer2"] = std::make_shared<FinalLayer>(this->config.llm.hidden_size,
|
||||
this->config.patch_size * this->config.patch_size * 3);
|
||||
this->config.patch_size * this->config.patch_size * 3);
|
||||
}
|
||||
|
||||
std::shared_ptr<LLM::TextModel> text_model() {
|
||||
|
||||
@@ -302,9 +302,9 @@ namespace Hunyuan {
|
||||
int64_t head_dim = this->config.hidden_size / this->config.num_heads;
|
||||
blocks["txt_in"] = std::make_shared<TokenRefiner>(this->config.context_in_dim, this->config.num_heads, head_dim, 2);
|
||||
blocks["img_in"] = std::make_shared<PatchEmbed>(static_cast<int64_t>(224) /*Not used*/,
|
||||
this->config.patch_size,
|
||||
this->config.in_channels,
|
||||
this->config.hidden_size);
|
||||
this->config.patch_size,
|
||||
this->config.in_channels,
|
||||
this->config.hidden_size);
|
||||
blocks["time_in"] = std::make_shared<Flux::MLPEmbedder>(256, this->config.hidden_size);
|
||||
if (this->config.vec_in_dim > 0) {
|
||||
blocks["vector_in"] = std::make_shared<Flux::MLPEmbedder>(this->config.vec_in_dim, this->config.hidden_size);
|
||||
|
||||
@@ -73,9 +73,9 @@ namespace Krea2 {
|
||||
int64_t dim_head = head_dim();
|
||||
int64_t unit = dim_head / 16;
|
||||
axes_dim = {
|
||||
static_cast<int>(dim_head - 12 * unit),
|
||||
static_cast<int>(6 * unit),
|
||||
static_cast<int>(6 * unit),
|
||||
static_cast<int>(dim_head - 12 * unit),
|
||||
static_cast<int>(6 * unit),
|
||||
static_cast<int>(6 * unit),
|
||||
};
|
||||
axes_dim_sum = axes_dim[0] + axes_dim[1] + axes_dim[2];
|
||||
}
|
||||
@@ -387,10 +387,10 @@ namespace Krea2 {
|
||||
this->config.mlp_multiplier,
|
||||
this->config.norm_eps);
|
||||
blocks["refiner_blocks." + std::to_string(i)] = std::make_shared<KreaTextFusionBlock>(this->config.text_dim,
|
||||
this->config.text_heads,
|
||||
this->config.text_kv_heads,
|
||||
this->config.mlp_multiplier,
|
||||
this->config.norm_eps);
|
||||
this->config.text_heads,
|
||||
this->config.text_kv_heads,
|
||||
this->config.mlp_multiplier,
|
||||
this->config.norm_eps);
|
||||
}
|
||||
blocks["projector"] = std::make_shared<Linear>(this->config.text_layers, 1, false);
|
||||
}
|
||||
@@ -613,8 +613,8 @@ namespace Krea2 {
|
||||
explicit Krea2Model(Krea2Config config)
|
||||
: config(std::move(config)) {
|
||||
blocks["first"] = std::make_shared<Linear>(this->config.patch_size * this->config.patch_size * this->config.in_channels,
|
||||
this->config.features,
|
||||
true);
|
||||
this->config.features,
|
||||
true);
|
||||
blocks["tmlp"] = std::make_shared<KreaTimeMLP>(this->config);
|
||||
blocks["txtfusion"] = std::make_shared<KreaTextFusionTransformer>(this->config);
|
||||
blocks["txtmlp"] = std::make_shared<KreaTextMLP>(this->config);
|
||||
|
||||
@@ -442,10 +442,10 @@ namespace LingBotVideo {
|
||||
: hidden_size(config.hidden_size) {
|
||||
blocks["norm1"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["attn"] = std::make_shared<LingBotVideoAttention>(config.hidden_size,
|
||||
config.num_attention_heads,
|
||||
config.qkv_bias,
|
||||
config.out_bias,
|
||||
config.norm_eps);
|
||||
config.num_attention_heads,
|
||||
config.qkv_bias,
|
||||
config.out_bias,
|
||||
config.norm_eps);
|
||||
blocks["norm_post_attn"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["norm2"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
if (sparse) {
|
||||
@@ -509,14 +509,14 @@ namespace LingBotVideo {
|
||||
int64_t patch_dim = config.patch_t * config.patch_h * config.patch_w * config.in_channels;
|
||||
blocks["patch_embedder"] = std::make_shared<Linear>(patch_dim, config.hidden_size, config.patch_embed_bias);
|
||||
blocks["time_embedder"] = std::make_shared<Qwen::TimestepEmbedding>(config.freq_dim,
|
||||
config.hidden_size,
|
||||
config.hidden_size,
|
||||
0,
|
||||
config.timestep_mlp_bias);
|
||||
config.hidden_size,
|
||||
config.hidden_size,
|
||||
0,
|
||||
config.timestep_mlp_bias);
|
||||
blocks["time_modulation.1"] = std::make_shared<Linear>(config.hidden_size, 6 * config.hidden_size, true);
|
||||
blocks["text_embedder"] = std::make_shared<LingBotVideoTextEmbedder>(config.text_dim,
|
||||
config.hidden_size,
|
||||
config.norm_eps);
|
||||
config.hidden_size,
|
||||
config.norm_eps);
|
||||
for (int i = 0; i < config.depth; i++) {
|
||||
bool sparse = config.sparse_layers.find(i) != config.sparse_layers.end();
|
||||
blocks["blocks." + std::to_string(i)] = std::make_shared<LingBotVideoBlock>(config, sparse);
|
||||
@@ -524,8 +524,8 @@ namespace LingBotVideo {
|
||||
blocks["norm_out"] = std::make_shared<LayerNorm>(config.hidden_size, config.norm_eps, false);
|
||||
blocks["norm_out_modulation.1"] = std::make_shared<Linear>(config.hidden_size, 2 * config.hidden_size, true);
|
||||
blocks["proj_out"] = std::make_shared<Linear>(config.hidden_size,
|
||||
config.patch_t * config.patch_h * config.patch_w * config.out_channels,
|
||||
true);
|
||||
config.patch_t * config.patch_h * config.patch_w * config.out_channels,
|
||||
true);
|
||||
}
|
||||
|
||||
ggml_tensor* forward(GGMLRunnerContext* ctx,
|
||||
|
||||
@@ -463,7 +463,7 @@ namespace LLaDAImage {
|
||||
static_cast<int>(x->ne[0]),
|
||||
config.patch_size,
|
||||
static_cast<int>(context->ne[1]),
|
||||
semantic != nullptr ? static_cast<int>(semantic->ne[1]) : 0,
|
||||
semantic != nullptr ? static_cast<int>(semantic->ne[1]) : 0,
|
||||
ZImage::SEQ_MULTI_OF,
|
||||
config.theta,
|
||||
config.axes_dim));
|
||||
|
||||
@@ -597,9 +597,9 @@ namespace LTXV {
|
||||
: embedding_dim(embedding_dim), embedding_coefficient(embedding_coefficient) {
|
||||
blocks["emb.timestep_embedder"] = std::make_shared<TimestepEmbedder>(embedding_dim);
|
||||
blocks["linear"] = std::make_shared<Linear>(embedding_dim,
|
||||
embedding_coefficient * embedding_dim,
|
||||
true,
|
||||
true);
|
||||
embedding_coefficient * embedding_dim,
|
||||
true,
|
||||
true);
|
||||
}
|
||||
|
||||
std::pair<ggml_tensor*, ggml_tensor*> forward(GGMLRunnerContext* ctx,
|
||||
@@ -1257,7 +1257,7 @@ namespace LTXV {
|
||||
v_context,
|
||||
attn2.get(),
|
||||
v_table,
|
||||
cross_attention_adaln ? params["prompt_scale_shift_table"] : nullptr,
|
||||
cross_attention_adaln ? params["prompt_scale_shift_table"] : nullptr,
|
||||
v_timestep,
|
||||
v_prompt_timestep,
|
||||
v_dim,
|
||||
@@ -1275,7 +1275,7 @@ namespace LTXV {
|
||||
a_context,
|
||||
audio_attn2.get(),
|
||||
a_table,
|
||||
cross_attention_adaln ? params["audio_prompt_scale_shift_table"] : nullptr,
|
||||
cross_attention_adaln ? params["audio_prompt_scale_shift_table"] : nullptr,
|
||||
a_timestep,
|
||||
a_prompt_timestep,
|
||||
a_dim,
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace MingImage {
|
||||
const int64_t n_txt = context->ne[1] + direct->ne[1];
|
||||
const int64_t n_img = ((x->ne[0] + config.patch_size - 1) / config.patch_size) *
|
||||
((x->ne[1] + config.patch_size - 1) / config.patch_size);
|
||||
auto padded = finish_rope_pe(Rope::gen_z_image_pe(
|
||||
auto padded = finish_rope_pe(Rope::gen_z_image_pe(
|
||||
static_cast<int>(x->ne[1]), static_cast<int>(x->ne[0]), config.patch_size, 1,
|
||||
static_cast<int>(n_txt), ZImage::SEQ_MULTI_OF, {}, Rope::RefIndexMode::FIXED,
|
||||
config.theta, config.axes_dim));
|
||||
|
||||
@@ -235,9 +235,9 @@ namespace MiniMaxH3 {
|
||||
blocks["norm1"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["norm2"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["attn"] = std::make_shared<Attention>(config.hidden_size,
|
||||
config.num_attention_heads,
|
||||
config.attention_head_dim,
|
||||
config.qk_norm_eps);
|
||||
config.num_attention_heads,
|
||||
config.attention_head_dim,
|
||||
config.qk_norm_eps);
|
||||
blocks["mlp"] = std::make_shared<MLP>(config.hidden_size, config.ffn_hidden_size);
|
||||
}
|
||||
|
||||
@@ -392,11 +392,11 @@ namespace MiniMaxH3 {
|
||||
blocks["norm1"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["norm2"] = std::make_shared<RMSNorm>(config.hidden_size, config.norm_eps);
|
||||
blocks["attn"] = std::make_shared<Attention>(config.hidden_size,
|
||||
config.num_attention_heads,
|
||||
config.attention_head_dim,
|
||||
config.qk_norm_eps);
|
||||
config.num_attention_heads,
|
||||
config.attention_head_dim,
|
||||
config.qk_norm_eps);
|
||||
blocks["mlp"] = std::make_shared<MLP>(config.hidden_size,
|
||||
config.ffn_hidden_size);
|
||||
config.ffn_hidden_size);
|
||||
blocks["adaln_proj"] = std::make_shared<AdaLayerNormModulation>(config.time_embed_dim,
|
||||
config.hidden_size,
|
||||
6,
|
||||
@@ -483,8 +483,8 @@ namespace MiniMaxH3 {
|
||||
auto row = modulation_row(ctx->ggml_ctx, mods, config.hidden_size, 2, 1, segment.modulation_row);
|
||||
auto value = norm->forward(ctx, ggml_ext_slice(ctx->ggml_ctx, x, 1, segment.start, segment.end));
|
||||
return ggml_add(ctx->ggml_ctx,
|
||||
ggml_add(ctx->ggml_ctx, value, ggml_mul(ctx->ggml_ctx, value, row[1])),
|
||||
row[0]);
|
||||
ggml_add(ctx->ggml_ctx, value, ggml_mul(ctx->ggml_ctx, value, row[1])),
|
||||
row[0]);
|
||||
};
|
||||
return {video_out->forward(ctx, apply(video)),
|
||||
audio_out->forward(ctx, apply(audio))};
|
||||
@@ -847,10 +847,10 @@ namespace MiniMaxH3 {
|
||||
const auto& condition = condition_videos[index];
|
||||
auto axes = condition_spatial_axes(condition);
|
||||
int64_t count = condition.shape()[2] *
|
||||
static_cast<int64_t>(axes.first.size() * axes.second.size());
|
||||
bool is_first = keyframe_indices.empty() || keyframe_indices[static_cast<int64_t>(index)] == 0;
|
||||
float keyframe_t = is_first ? static_cast<float>(text_len)
|
||||
: static_cast<float>(text_len) + video_duration - FRAME_RESCALE;
|
||||
static_cast<int64_t>(axes.first.size() * axes.second.size());
|
||||
bool is_first = keyframe_indices.empty() || keyframe_indices[static_cast<int64_t>(index)] == 0;
|
||||
float keyframe_t = is_first ? static_cast<float>(text_len)
|
||||
: static_cast<float>(text_len) + video_duration - FRAME_RESCALE;
|
||||
for (int64_t t = 0; t < condition.shape()[2]; ++t) {
|
||||
for (float h : axes.first) {
|
||||
for (float w : axes.second) {
|
||||
@@ -904,9 +904,9 @@ namespace MiniMaxH3 {
|
||||
|
||||
if (block.kind != MiniMaxH3ReferenceKind::AUDIO) {
|
||||
GGML_ASSERT(ref_video != nullptr);
|
||||
auto axes = condition_spatial_axes(*ref_video);
|
||||
int64_t count = ref_video->shape()[2] *
|
||||
static_cast<int64_t>(axes.first.size() * axes.second.size());
|
||||
auto axes = condition_spatial_axes(*ref_video);
|
||||
int64_t count = ref_video->shape()[2] *
|
||||
static_cast<int64_t>(axes.first.size() * axes.second.size());
|
||||
float video_end = append_video_positions(*ref_video, cursor);
|
||||
layout.sequence_segments.push_back({row,
|
||||
row + count,
|
||||
|
||||
@@ -644,7 +644,7 @@ namespace Pid {
|
||||
|
||||
int64_t effective_down_factor = config.lq_latent_down_factor / unpatchify_factor;
|
||||
float z_to_patch_ratio = static_cast<float>(config.lq_sr_scale * effective_down_factor) /
|
||||
static_cast<float>(config.patch_size);
|
||||
static_cast<float>(config.patch_size);
|
||||
GGML_ASSERT(z_to_patch_ratio >= 1.0f);
|
||||
if (lq_latent->ne[0] != target_pW || lq_latent->ne[1] != target_pH) {
|
||||
lq_latent = ggml_interpolate(ctx->ggml_ctx,
|
||||
|
||||
@@ -224,9 +224,9 @@ namespace PixArt {
|
||||
PixArtModel(const PixArtConfig& config)
|
||||
: config(config) {
|
||||
blocks["x_embedder.proj"] = std::make_shared<Conv2d>(config.in_channels,
|
||||
config.hidden_size,
|
||||
std::pair<int, int>{static_cast<int>(config.patch_size), static_cast<int>(config.patch_size)},
|
||||
std::pair<int, int>{static_cast<int>(config.patch_size), static_cast<int>(config.patch_size)});
|
||||
config.hidden_size,
|
||||
std::pair<int, int>{static_cast<int>(config.patch_size), static_cast<int>(config.patch_size)},
|
||||
std::pair<int, int>{static_cast<int>(config.patch_size), static_cast<int>(config.patch_size)});
|
||||
blocks["t_embedder"] = std::make_shared<PixArtTimestepEmbedding>(ADALN_EMBED_DIM, config.hidden_size);
|
||||
blocks["t_block.1"] = std::make_shared<Linear>(config.hidden_size, 6 * config.hidden_size);
|
||||
blocks["y_embedder.y_proj.fc1"] = std::make_shared<Linear>(config.caption_channels, config.hidden_size);
|
||||
@@ -237,7 +237,7 @@ namespace PixArt {
|
||||
}
|
||||
blocks["final_layer.norm_final"] = std::make_shared<LayerNorm>(config.hidden_size, 1e-6f, false);
|
||||
blocks["final_layer.linear"] = std::make_shared<Linear>(config.hidden_size,
|
||||
config.patch_size * config.patch_size * config.out_channels);
|
||||
config.patch_size * config.patch_size * config.out_channels);
|
||||
}
|
||||
|
||||
ggml_tensor* forward(GGMLRunnerContext* ctx,
|
||||
|
||||
@@ -486,8 +486,8 @@ namespace Qwen {
|
||||
}
|
||||
QwenImage21PrefixCache cache;
|
||||
if (prefix_cache_enabled && !prefix_cache_disabled && extra != nullptr && extra->prefix_id != 0 && layout.prefix_length > 0) {
|
||||
cache.name = "qwen_image_2_1.prefix." + std::to_string(extra->prefix_id) +
|
||||
".circular." + std::to_string(circular_x_enabled) + std::to_string(circular_y_enabled);
|
||||
cache.name = "qwen_image_2_1.prefix." + std::to_string(extra->prefix_id) +
|
||||
".circular." + std::to_string(circular_x_enabled) + std::to_string(circular_y_enabled);
|
||||
cache.prefix_length = layout.prefix_length;
|
||||
if (prefix_cache_type != GGML_TYPE_COUNT) {
|
||||
cache.type = prefix_cache_type;
|
||||
@@ -536,7 +536,7 @@ namespace Qwen {
|
||||
auto build = [&]() {
|
||||
auto graph = new_graph_custom(QWEN_IMAGE_GRAPH_SIZE * 2);
|
||||
auto pe = ggml_new_tensor_4d(compute_ctx, GGML_TYPE_F32, 2, 2, config.head_dim / 2,
|
||||
layout.positions.size() - (cached ? layout.prefix_length : 0));
|
||||
layout.positions.size() - (cached ? layout.prefix_length : 0));
|
||||
set_backend_tensor_data(pe, pe_data.data());
|
||||
std::vector<ggml_tensor*> masks, ref_inputs;
|
||||
for (const auto& mask : mask_data) {
|
||||
@@ -549,7 +549,7 @@ namespace Qwen {
|
||||
}
|
||||
auto ctx = get_context(graph);
|
||||
auto out = model.forward(&ctx, make_input(x), make_input(*inputs.timesteps), cached ? nullptr : make_input(context),
|
||||
ref_inputs, pe, layout, masks, checked_cache);
|
||||
ref_inputs, pe, layout, masks, checked_cache);
|
||||
if (!flash_attn_used) {
|
||||
return static_cast<ggml_cgraph*>(nullptr);
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ namespace SenseNovaU1 {
|
||||
blocks["language_model.model"] = std::make_shared<TextModel>(config);
|
||||
blocks["fm_modules.vision_model_mot_gen.embeddings"] = std::make_shared<VisionEmbeddings>(config);
|
||||
blocks["fm_modules.timestep_embedder"] = std::make_shared<TimestepEmbedder>(config.hidden_size,
|
||||
config.timestep_embedding_size);
|
||||
config.timestep_embedding_size);
|
||||
if (config.add_noise_scale_embedding) {
|
||||
blocks["fm_modules.noise_scale_embedder"] = std::make_shared<TimestepEmbedder>(config.hidden_size,
|
||||
config.timestep_embedding_size);
|
||||
|
||||
@@ -9,13 +9,13 @@ static bool build_anima(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<AnimaConditioner>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Anima::AnimaRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,17 @@ static bool build_boogu_image(const sd::model_builders::Context& ctx, const Toke
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Boogu::BooguImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_ernie_image(const sd::model_builders::Context& ctx, const Toke
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<ErnieImage::ErnieImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ static bool build_fibo2(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<Fibo2Conditioner>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map, weight_manager, tokenizers);
|
||||
tensor_storage_map, weight_manager, tokenizers);
|
||||
result.diffusion = std::make_shared<Fibo2::Fibo2Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,18 @@ static bool build_flux2(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
bool is_chroma = false;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Flux::FluxRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ static bool build_flux3(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map, version, "", false, weight_manager, tokenizers);
|
||||
tensor_storage_map, version, "", false, weight_manager, tokenizers);
|
||||
result.diffusion = std::make_shared<Flux3::Flux3Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@ static bool build_hidream_o1(const sd::model_builders::Context& ctx, const Token
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<HiDreamO1::HiDreamO1Conditioner>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<HiDreamO1::HiDreamO1Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,17 @@ static bool build_hunyuan_video(const sd::model_builders::Context& ctx, const To
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Hunyuan::HunyuanVideoRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_ideogram4(const sd::model_builders::Context& ctx, const Tokeni
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Ideogram4::Ideogram4Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ static bool build_iris(const sd::model_builders::Context& ctx, const TokenizerCo
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map, version, "", false, weight_manager, tokenizers);
|
||||
tensor_storage_map, version, "", false, weight_manager, tokenizers);
|
||||
result.diffusion = std::make_shared<Iris::IrisRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_krea2(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Krea2::Krea2Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_lens(const sd::model_builders::Context& ctx, const TokenizerCo
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Lens::LensRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ static bool build_lingbot_video(const sd::model_builders::Context& ctx, const To
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<LingBotVideo::LingBotVideoRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,17 +9,17 @@ static bool build_llada_image(const sd::model_builders::Context& ctx, const Toke
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLaDAImageEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
"queryformer",
|
||||
"text_projection",
|
||||
"sigvq",
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
"queryformer",
|
||||
"text_projection",
|
||||
"sigvq",
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<LLaDAImage::LLaDAImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,18 +9,18 @@ static bool build_longcat(const sd::model_builders::Context& ctx, const Tokenize
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Flux::FluxRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@ static bool build_ltxav(const sd::model_builders::Context& ctx, const TokenizerC
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LTXAVEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
"text_embedding_projection",
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
"text_encoders.llm",
|
||||
"text_embedding_projection",
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<LTXV::LTXAVRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_mage_flow(const sd::model_builders::Context& ctx, const Tokeni
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<MageFlow::MageFlowRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ static bool build_ming_image(const sd::model_builders::Context& ctx, const Token
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<MingImageEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map, weight_manager, tokenizers);
|
||||
tensor_storage_map, weight_manager, tokenizers);
|
||||
result.diffusion = std::make_shared<MingImage::MingImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
tensor_storage_map, "model.diffusion_model", weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_minimax_h3(const sd::model_builders::Context& ctx, const Token
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
true,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<MiniMaxH3::MiniMaxH3Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,12 @@ static bool build_minit2i(const sd::model_builders::Context& ctx, const Tokenize
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<MiniT2IConditioner>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
weight_manager);
|
||||
result.diffusion = std::make_shared<MiniT2I::MiniT2IRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model.model.net",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model.model.net",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ static bool build_moss_image(const sd::model_builders::Context& ctx,
|
||||
ctx.tensor_storage_map, ctx.version, "", false,
|
||||
ctx.weight_manager, tokenizers);
|
||||
runners.diffusion = std::make_shared<MOSSImage::MOSSImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
ctx.tensor_storage_map, "model.diffusion_model", ctx.weight_manager);
|
||||
ctx.tensor_storage_map, "model.diffusion_model", ctx.weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_pid(const sd::model_builders::Context& ctx, const TokenizerCon
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<Pid::PiDRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model.net",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model.net",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,17 +31,17 @@ static bool build_pixart(const sd::model_builders::Context& ctx, const Tokenizer
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<T5CLIPEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
true,
|
||||
0,
|
||||
false,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
tensor_storage_map,
|
||||
true,
|
||||
0,
|
||||
false,
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
result.diffusion = std::make_shared<PixArt::PixArtRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager,
|
||||
sd_ctx_params->model_args);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,12 +11,12 @@ static bool build_qwen_image(const sd::model_builders::Context& ctx, const Token
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
bool enable_vision = version != VERSION_QWEN_IMAGE_LAYERED;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
enable_vision,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
enable_vision,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
if (version == VERSION_QWEN_IMAGE_2_1) {
|
||||
result.diffusion = std::make_shared<Qwen::QwenImage21Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
|
||||
@@ -34,10 +34,10 @@ static bool build_sd(const sd::model_builders::Context& ctx, const TokenizerConf
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<UNetModelRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
static prediction_t detect_sdxl_prediction(const String2TensorStorage& weights) {
|
||||
|
||||
@@ -9,13 +9,13 @@ static bool build_sd3(const sd::model_builders::Context& ctx, const TokenizerCon
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<SD3CLIPEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<MMDiTRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ static bool build_sensenova_u1(const sd::model_builders::Context& ctx, const Tok
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<SenseNovaU1Conditioner>();
|
||||
result.diffusion = std::make_shared<SenseNovaU1::SenseNovaU1Runner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,16 +10,16 @@ static bool build_wan(const sd::model_builders::Context& ctx, const TokenizerCon
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<T5CLIPEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
true,
|
||||
0,
|
||||
true,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
true,
|
||||
0,
|
||||
true,
|
||||
weight_manager);
|
||||
result.diffusion = std::make_shared<WAN::WanRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
if (strlen(SAFE_STR(sd_ctx_params->high_noise_diffusion_model_path)) > 0) {
|
||||
result.high_noise_diffusion = std::make_shared<WAN::WanRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
|
||||
@@ -9,17 +9,17 @@ static bool build_z_image(const sd::model_builders::Context& ctx, const Tokenize
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<ZImage::ZImageRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
version,
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,16 @@ static bool build_z_image_l2p(const sd::model_builders::Context& ctx, const Toke
|
||||
const auto version = ctx.version;
|
||||
const auto& weight_manager = ctx.weight_manager;
|
||||
result.conditioner = std::make_shared<LLMEmbedder>(ctx.backends.runtime_backend(SDBackendModule::TE),
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
tensor_storage_map,
|
||||
version,
|
||||
"",
|
||||
false,
|
||||
weight_manager,
|
||||
tokenizers);
|
||||
result.diffusion = std::make_shared<ZImageL2P::ZImageL2PRunner>(ctx.backends.runtime_backend(SDBackendModule::DIFFUSION),
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"model.diffusion_model",
|
||||
weight_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -347,8 +347,8 @@ namespace LLaDAImageTE {
|
||||
blocks["visual.blocks." + std::to_string(i)] = std::make_shared<SigVQBlock>(config);
|
||||
}
|
||||
blocks["vqmodel.quant_conv"] = std::make_shared<Conv2d>(config.hidden_size,
|
||||
config.codebook_embed_dim,
|
||||
std::make_pair(1, 1));
|
||||
config.codebook_embed_dim,
|
||||
std::make_pair(1, 1));
|
||||
blocks["prior_projector.net.0.proj"] = std::make_shared<Linear>(config.semantic_embed_dim, config.semantic_embed_dim, true);
|
||||
blocks["prior_projector.net.2"] = std::make_shared<Linear>(config.semantic_embed_dim, config.semantic_embed_dim, true);
|
||||
}
|
||||
|
||||
@@ -1087,9 +1087,9 @@ namespace LTXV {
|
||||
|
||||
auto& tensor_storage_map = model_loader.get_tensor_storage_map();
|
||||
auto ltx_audio_vae = std::make_shared<LTXAudioVAERunner>(backend,
|
||||
tensor_storage_map,
|
||||
prefix,
|
||||
model_manager);
|
||||
tensor_storage_map,
|
||||
prefix,
|
||||
model_manager);
|
||||
|
||||
if (!model_manager->set_loader(std::move(model_loader)) ||
|
||||
!model_manager->register_runner_params(ModelComponent::AudioVAE,
|
||||
|
||||
+11
-11
@@ -497,12 +497,12 @@ namespace LTXVAE {
|
||||
GGML_ASSERT(out_channels % factor == 0);
|
||||
|
||||
blocks["conv"] = std::make_shared<CausalConv3d>(in_channels,
|
||||
out_channels / factor,
|
||||
3,
|
||||
std::tuple<int, int, int>{1, 1, 1},
|
||||
1,
|
||||
true,
|
||||
force_conv_prec_f32);
|
||||
out_channels / factor,
|
||||
3,
|
||||
std::tuple<int, int, int>{1, 1, 1},
|
||||
1,
|
||||
true,
|
||||
force_conv_prec_f32);
|
||||
blocks["skip_downsample"] = std::make_shared<WAN::AvgDown3D>(in_channels, out_channels, factor_t, factor_s);
|
||||
blocks["conv_downsample"] = std::make_shared<WAN::AvgDown3D>(out_channels / factor, out_channels, factor_t, factor_s);
|
||||
}
|
||||
@@ -1077,11 +1077,11 @@ namespace LTXVAE {
|
||||
patch_size);
|
||||
}
|
||||
blocks["decoder"] = std::make_shared<Decoder>(version,
|
||||
tensor_storage_map,
|
||||
prefix,
|
||||
patch_size,
|
||||
false,
|
||||
timestep_conditioning);
|
||||
tensor_storage_map,
|
||||
prefix,
|
||||
patch_size,
|
||||
false,
|
||||
timestep_conditioning);
|
||||
blocks["per_channel_statistics"] = std::make_shared<PerChannelStatistics>();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,10 +76,10 @@ namespace MiniMaxH3 {
|
||||
blocks["block.2"] = std::make_shared<AudioEncoderResidualUnit>(in_channels, 9);
|
||||
blocks["block.3"] = std::make_shared<AudioSnake1D>(in_channels);
|
||||
blocks["block.4"] = std::make_shared<LTXV::Conv1D>(in_channels,
|
||||
out_channels,
|
||||
2 * stride,
|
||||
stride,
|
||||
static_cast<int>(std::ceil(stride / 2.f)));
|
||||
out_channels,
|
||||
2 * stride,
|
||||
stride,
|
||||
static_cast<int>(std::ceil(stride / 2.f)));
|
||||
}
|
||||
|
||||
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
|
||||
@@ -300,12 +300,12 @@ namespace MiniMaxH3 {
|
||||
}
|
||||
blocks["activation_post"] = std::make_shared<LTXV::Activation1D>(channels);
|
||||
blocks["conv_post"] = std::make_shared<LTXV::Conv1D>(channels,
|
||||
1,
|
||||
7,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
false);
|
||||
1,
|
||||
7,
|
||||
1,
|
||||
3,
|
||||
1,
|
||||
false);
|
||||
}
|
||||
|
||||
ggml_tensor* forward(GGMLRunnerContext* ctx, ggml_tensor* x) {
|
||||
|
||||
@@ -449,8 +449,8 @@ namespace MiniMaxH3VAE {
|
||||
MiniMaxH3VideoVAE() {
|
||||
blocks["encoder"] = std::make_shared<Encoder>();
|
||||
blocks["quant_conv"] = std::make_shared<Conv3d>(48,
|
||||
48,
|
||||
std::tuple{1, 1, 1});
|
||||
48,
|
||||
std::tuple{1, 1, 1});
|
||||
blocks["post_quant_conv"] = std::make_shared<Conv3d>(24,
|
||||
24,
|
||||
std::tuple{1, 1, 1});
|
||||
|
||||
@@ -340,7 +340,7 @@ bool ModelLoader::init_from_safetensors_index_file(const std::string& file_path,
|
||||
const auto expected = (std::filesystem::u8path(file_path).parent_path() /
|
||||
std::filesystem::u8path(entry.value().get<std::string>()))
|
||||
.lexically_normal();
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
for (const auto& shard : parsed_tensor_names_) {
|
||||
if (std::filesystem::u8path(shard.first).lexically_normal() == expected) {
|
||||
found = shard.second.count(entry.key()) != 0;
|
||||
|
||||
+14
-14
@@ -568,7 +568,7 @@ bool ModelManager::stage_tensors_to_compute_backend(const std::vector<TensorStat
|
||||
ggml_backend_alloc_ctx_tensors_from_buft(staging_ctx, staging_buft);
|
||||
if (compute_buffer == nullptr) {
|
||||
LOG_ERROR("model manager alloc compute params backend buffer failed, num_tensors = %zu",
|
||||
staged_tensors.size());
|
||||
staged_tensors.size());
|
||||
ggml_free(staging_ctx);
|
||||
return false;
|
||||
}
|
||||
@@ -692,8 +692,8 @@ bool ModelManager::apply_loras_to_params(const std::vector<TensorState*>& states
|
||||
// The temporary runner is destroyed before this manager call returns.
|
||||
auto borrowed_manager = std::shared_ptr<ModelManager>(this, [](ModelManager*) {});
|
||||
auto lora = std::make_shared<LoraModel>(id, compute_backend, target->params_backend,
|
||||
borrowed_manager, lora_spec.file_id, lora_version_,
|
||||
target->residency_mode);
|
||||
borrowed_manager, lora_spec.file_id, lora_version_,
|
||||
target->residency_mode);
|
||||
|
||||
LoraModel::filter_t lora_tensor_filter = nullptr;
|
||||
if (!lora_spec.tensor_name_prefix_filter.empty()) {
|
||||
@@ -1409,8 +1409,8 @@ bool ModelManager::assign_compute_backend(const std::vector<ggml_tensor*>& tenso
|
||||
|
||||
const bool params_follow_compute = state->params_follow_compute_backend ||
|
||||
state->residency_mode == ResidencyMode::Disk;
|
||||
const bool compute_changes = state->compute_backend != compute_backend;
|
||||
const bool params_changes = params_follow_compute && state->params_backend != compute_backend;
|
||||
const bool compute_changes = state->compute_backend != compute_backend;
|
||||
const bool params_changes = params_follow_compute && state->params_backend != compute_backend;
|
||||
if (!compute_changes && !params_changes) {
|
||||
continue;
|
||||
}
|
||||
@@ -1501,7 +1501,7 @@ size_t ModelManager::compute_backend_resident_bytes(ggml_backend_t compute_backe
|
||||
? buffer_type != nullptr && ggml_backend_buft_get_device(buffer_type) == compute_device
|
||||
: std::any_of(split_devices->second.begin(), split_devices->second.end(), [&](const auto& entry) {
|
||||
return ggml_backend_get_device(entry.first) == compute_device;
|
||||
});
|
||||
});
|
||||
if (!on_device) {
|
||||
return;
|
||||
}
|
||||
@@ -1782,10 +1782,10 @@ ModelManager::CapacityCheck ModelManager::check_capacity(
|
||||
const size_t resident = add(weights_resident, add(other_runtime, request.runtime_resident_bytes));
|
||||
if (log_details) {
|
||||
LOG_WARN("model manager memory on %s: reported free %.2f MB / total %.2f MB, tracked weights %.2f MB / other runtime %.2f MB / current runtime %.2f MB",
|
||||
ggml_backend_name(backend),
|
||||
free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0),
|
||||
weights_resident / (1024.0 * 1024.0), other_runtime / (1024.0 * 1024.0),
|
||||
request.runtime_resident_bytes / (1024.0 * 1024.0));
|
||||
ggml_backend_name(backend),
|
||||
free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0),
|
||||
weights_resident / (1024.0 * 1024.0), other_runtime / (1024.0 * 1024.0),
|
||||
request.runtime_resident_bytes / (1024.0 * 1024.0));
|
||||
}
|
||||
if (free_bytes == 0 && total_bytes == 0) {
|
||||
return SIZE_MAX;
|
||||
@@ -1797,7 +1797,7 @@ ModelManager::CapacityCheck ModelManager::check_capacity(
|
||||
}
|
||||
// A wrapped report may reflect real pressure; reclaim before accepting the tracked estimate.
|
||||
LOG_VERBOSE("ignoring impossible free memory report on %s (%.2f MB free / %.2f MB total), using tracked residency",
|
||||
ggml_backend_name(backend), free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0));
|
||||
ggml_backend_name(backend), free_bytes / (1024.0 * 1024.0), total_bytes / (1024.0 * 1024.0));
|
||||
free_bytes = total_bytes;
|
||||
result.requires_reclamation = true;
|
||||
}
|
||||
@@ -1907,9 +1907,9 @@ bool ModelManager::ensure_compute_backend_capacity(
|
||||
}
|
||||
const bool reloadable = state->residency_mode == ResidencyMode::Disk ||
|
||||
state->compute_backend != state->params_backend;
|
||||
const bool resident = state->compute_backend == state->params_backend
|
||||
? state->loaded_to_params_backend
|
||||
: state->staged_to_compute_backend;
|
||||
const bool resident = state->compute_backend == state->params_backend
|
||||
? state->loaded_to_params_backend
|
||||
: state->staged_to_compute_backend;
|
||||
if (reloadable && resident) {
|
||||
eviction_states.insert(state);
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ bool StableDiffusionGGML::register_row_split_runner_params(ModelComponent compon
|
||||
size_t free_bytes = 0, total_bytes = 0;
|
||||
ggml_backend_dev_memory(dev, &free_bytes, &total_bytes);
|
||||
int64_t usable_bytes = std::max<int64_t>((int64_t)free_bytes - compute_headroom_bytes,
|
||||
(int64_t)free_bytes / 8);
|
||||
(int64_t)free_bytes / 8);
|
||||
tensor_split[reg_index] = usable_bytes > 0 ? (float)((double)usable_bytes / (1024.0 * 1024.0)) : 1.0f;
|
||||
}
|
||||
|
||||
@@ -511,8 +511,8 @@ bool StableDiffusionGGML::register_layer_split_runner_params(ModelComponent comp
|
||||
model->set_runtime_backends(module_backends);
|
||||
model->set_graph_cut_layer_split_backend_vram_limits(layer_split_vram_limits_for_backends(module_backends));
|
||||
model->set_graph_cut_layer_split_enabled(true);
|
||||
const bool params_follow_runtime = backend_manager.params_backend_follows_runtime(module) ||
|
||||
backend_manager.params_backend_is_disk(module);
|
||||
const bool params_follow_runtime = backend_manager.params_backend_follows_runtime(module) ||
|
||||
backend_manager.params_backend_is_disk(module);
|
||||
ggml_backend_t initial_params_backend = params_follow_runtime ? module_backends[0] : params_backend_for(module);
|
||||
if (initial_params_backend == nullptr) {
|
||||
return false;
|
||||
@@ -1593,8 +1593,8 @@ std::shared_ptr<LoraModel> StableDiffusionGGML::load_lora_model(const ModelManag
|
||||
? ModelManager::ResidencyMode::Disk
|
||||
: ModelManager::ResidencyMode::ParamBackend;
|
||||
auto lora = std::make_shared<LoraModel>(lora_log_id(lora_spec), backend_for(module), params_backend_for(module),
|
||||
model_manager, lora_spec.file_id, version, mode,
|
||||
backend_manager.params_backend_follows_runtime(module));
|
||||
model_manager, lora_spec.file_id, version, mode,
|
||||
backend_manager.params_backend_follows_runtime(module));
|
||||
LoraModel::filter_t lora_tensor_filter = module_filter;
|
||||
if (!lora_spec.tensor_name_prefix_filter.empty()) {
|
||||
lora_tensor_filter = [module_filter, prefix = lora_spec.tensor_name_prefix_filter](const std::string& tensor_name) {
|
||||
@@ -2008,11 +2008,11 @@ void StableDiffusionGGML::preview_image(int step,
|
||||
: sd::ops::slice(latents, 2, 0, channels)
|
||||
: latents;
|
||||
if (preview_mode == PREVIEW_PROJ) {
|
||||
int patch_sz = 1;
|
||||
const float(*latent_rgb_proj)[3] = nullptr;
|
||||
float* latent_rgb_bias = nullptr;
|
||||
const float* latent_alpha_proj = nullptr;
|
||||
float latent_alpha_bias = 1.f;
|
||||
int patch_sz = 1;
|
||||
const float (*latent_rgb_proj)[3] = nullptr;
|
||||
float* latent_rgb_bias = nullptr;
|
||||
const float* latent_alpha_proj = nullptr;
|
||||
float latent_alpha_bias = 1.f;
|
||||
|
||||
if (channels == 128) {
|
||||
if (sd_version_uses_flux2_vae(version)) {
|
||||
@@ -2294,8 +2294,8 @@ sd::Tensor<float> StableDiffusionGGML::sample(const std::shared_ptr<DiffusionMod
|
||||
const bool cache_qwen_prefix = version == VERSION_QWEN_IMAGE_2_1 &&
|
||||
std::none_of(generation_extensions.begin(), generation_extensions.end(),
|
||||
[](const auto& extension) { return extension->is_enabled(); });
|
||||
using QwenPrefixInputs = std::tuple<const sd::Tensor<float>*, const sd::Tensor<int32_t>*,
|
||||
const std::vector<sd::Tensor<float>>*>;
|
||||
using QwenPrefixInputs = std::tuple<const sd::Tensor<float>*, const sd::Tensor<int32_t>*,
|
||||
const std::vector<sd::Tensor<float>>*>;
|
||||
std::vector<QwenPrefixInputs> qwen_prefix_inputs;
|
||||
|
||||
RunnerEndOnExit sample_control_runner_end{!control_image.empty() && control_net != nullptr ? control_net.get() : nullptr};
|
||||
@@ -2596,7 +2596,7 @@ sd::Tensor<float> StableDiffusionGGML::sample(const std::shared_ptr<DiffusionMod
|
||||
auto* extra = std::get_if<QwenImage21DiffusionExtra>(&diffusion_params.extra);
|
||||
if (extra != nullptr) {
|
||||
auto key = std::make_tuple(diffusion_params.context, extra->image_slots,
|
||||
diffusion_params.ref_image_params.pass_to_dit ? diffusion_params.ref_latents : nullptr);
|
||||
diffusion_params.ref_image_params.pass_to_dit ? diffusion_params.ref_latents : nullptr);
|
||||
auto entry = std::find(qwen_prefix_inputs.begin(), qwen_prefix_inputs.end(), key);
|
||||
extra->prefix_id = static_cast<uint64_t>(entry - qwen_prefix_inputs.begin()) + 1;
|
||||
if (entry == qwen_prefix_inputs.end()) {
|
||||
|
||||
@@ -939,10 +939,10 @@ namespace sd::pipeline {
|
||||
}
|
||||
LOG_INFO("hires fix: loading model upscaler from '%s'", request.hires.model_path);
|
||||
hires_upscaler = std::make_unique<UpscalerGGML>(sd->n_threads,
|
||||
false,
|
||||
request.hires.upscale_tile_size,
|
||||
sd->backend_spec,
|
||||
sd->params_backend_spec);
|
||||
false,
|
||||
request.hires.upscale_tile_size,
|
||||
sd->backend_spec,
|
||||
sd->params_backend_spec);
|
||||
const size_t max_graph_vram_bytes = sd->max_graph_vram_bytes_for_module(SDBackendModule::UPSCALER);
|
||||
hires_upscaler->set_max_graph_vram_bytes(max_graph_vram_bytes);
|
||||
if (!hires_upscaler->load_from_file(request.hires.model_path,
|
||||
|
||||
@@ -184,12 +184,12 @@ namespace sd::model_builders {
|
||||
weight_manager);
|
||||
} else {
|
||||
auto model = std::make_shared<AutoEncoderKL>(ctx.backends.runtime_backend(SDBackendModule::VAE),
|
||||
tensor_storage_map,
|
||||
"first_stage_model",
|
||||
false,
|
||||
false,
|
||||
vae_version,
|
||||
weight_manager);
|
||||
tensor_storage_map,
|
||||
"first_stage_model",
|
||||
false,
|
||||
false,
|
||||
vae_version,
|
||||
weight_manager);
|
||||
const auto* definition = find_model_definition(version);
|
||||
if (definition && definition->configure_vae) {
|
||||
definition->configure_vae(ctx, options, *model);
|
||||
|
||||
+11
-11
@@ -689,8 +689,8 @@ namespace sd::pipeline {
|
||||
int source_index = std::min(reference.frame_count - 1,
|
||||
static_cast<int>(std::floor(frame * source_fps / 24.0)));
|
||||
auto source = ensure_image_tensor_channels(
|
||||
sd_image_to_tensor(reference.frames[source_index]),
|
||||
3);
|
||||
sd_image_to_tensor(reference.frames[source_index]),
|
||||
3);
|
||||
if (source.empty()) {
|
||||
LOG_ERROR("invalid frame %d in MiniMax-H3 reference video %d",
|
||||
source_index + 1,
|
||||
@@ -818,7 +818,7 @@ namespace sd::pipeline {
|
||||
keyframes.shape()[2],
|
||||
1,
|
||||
1},
|
||||
conditioned_mask);
|
||||
conditioned_mask);
|
||||
latents.denoise_mask = sd::ops::concat(latents.denoise_mask, keyframe_mask, 2);
|
||||
latents.video_positions = build_ltxv_video_positions(latents.init_latent.shape()[0],
|
||||
latents.init_latent.shape()[1],
|
||||
@@ -1106,10 +1106,10 @@ namespace sd::pipeline {
|
||||
inactive.shape()[1],
|
||||
inactive.shape()[2]}); // [t, h/vae_scale_factor, vae_scale_factor, w/vae_scale_factor, vae_scale_factor]
|
||||
mask_context = mask_context.permute({1, 3, 4, 0, 2}) // [vae_scale_factor, vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor]
|
||||
.reshape({inactive.shape()[0],
|
||||
inactive.shape()[1],
|
||||
inactive.shape()[2],
|
||||
request->vae_scale_factor * request->vae_scale_factor}); // [vae_scale_factor*vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor]
|
||||
.reshape({inactive.shape()[0],
|
||||
inactive.shape()[1],
|
||||
inactive.shape()[2],
|
||||
request->vae_scale_factor * request->vae_scale_factor}); // [vae_scale_factor*vae_scale_factor, t, h/vae_scale_factor, w/vae_scale_factor]
|
||||
|
||||
if (!ref_image_latent.empty()) {
|
||||
vace_context = sd::ops::concat(ref_image_latent, vace_context, 2); // [b, 2*c, t+1, h/vae_scale_factor, w/vae_scale_factor]
|
||||
@@ -1387,9 +1387,9 @@ namespace sd::pipeline {
|
||||
|
||||
auto& upsampler = scope.runner;
|
||||
upsampler = std::make_unique<LTXVUpsampler::LatentUpsamplerRunner>(sd->backend_for(SDBackendModule::UPSCALER),
|
||||
model_manager->loader().get_tensor_storage_map(),
|
||||
prefix,
|
||||
model_manager);
|
||||
model_manager->loader().get_tensor_storage_map(),
|
||||
prefix,
|
||||
model_manager);
|
||||
const size_t max_graph_vram_bytes = sd->max_graph_vram_bytes_for_module(SDBackendModule::UPSCALER);
|
||||
upsampler->set_max_graph_vram_bytes(max_graph_vram_bytes);
|
||||
if (upsampler->model == nullptr) {
|
||||
@@ -1869,7 +1869,7 @@ namespace sd::pipeline {
|
||||
x_t,
|
||||
std::move(noise),
|
||||
embeds.cond,
|
||||
hires_request.use_uncond ? embeds.uncond : SDCondition(),
|
||||
hires_request.use_uncond ? embeds.uncond : SDCondition(),
|
||||
embeds.img_uncond,
|
||||
sd::Tensor<float>(),
|
||||
0.f,
|
||||
|
||||
@@ -842,7 +842,7 @@ struct CacheDitConditionState {
|
||||
|
||||
const float* input_data = input.data();
|
||||
float diff = CacheDitState::calculate_residual_diff(
|
||||
it->second.prev_input.data(), input_data, ne);
|
||||
it->second.prev_input.data(), input_data, ne);
|
||||
|
||||
float effective_threshold = config.residual_diff_threshold;
|
||||
if (config.Fn_compute_blocks > 0) {
|
||||
|
||||
@@ -164,8 +164,8 @@ namespace sd::guidance {
|
||||
if (has_tensor(input.pred_img_uncond)) {
|
||||
const sd::Tensor<float>& pred_img_uncond = *input.pred_img_uncond;
|
||||
output.pred = pred_img_uncond +
|
||||
image_guidance_scale_ * (pred_uncond - pred_img_uncond) +
|
||||
guidance_scale * (pred_cond - pred_uncond);
|
||||
image_guidance_scale_ * (pred_uncond - pred_img_uncond) +
|
||||
guidance_scale * (pred_cond - pred_uncond);
|
||||
|
||||
} else {
|
||||
output.pred = pred_uncond + guidance_scale * (pred_cond - pred_uncond);
|
||||
@@ -224,8 +224,8 @@ namespace sd::guidance {
|
||||
if (has_tensor(input.pred_img_uncond)) {
|
||||
const sd::Tensor<float>& pred_img_uncond = *input.pred_img_uncond;
|
||||
output.pred = pred_img_uncond +
|
||||
image_guidance_scale_ * (pred_uncond - pred_img_uncond) +
|
||||
guidance_scale * (pred_cond - pred_uncond);
|
||||
image_guidance_scale_ * (pred_uncond - pred_img_uncond) +
|
||||
guidance_scale * (pred_cond - pred_uncond);
|
||||
} else {
|
||||
output.pred = pred_uncond + guidance_scale * (pred_cond - pred_uncond);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user