Skip to content

Commit 75c6149

Browse files
committed
refactor(tx): fix failed to offload t5
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 7d9176a commit 75c6149

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

conditioner.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ struct FluxCLIPEmbedder : public Conditioner {
10941094
struct ggml_tensor* pooled = NULL; // [768,]
10951095
std::vector<float> hidden_states_vec;
10961096

1097-
size_t chunk_len = 256;
1097+
size_t chunk_len = 255;
10981098
size_t chunk_count = t5_tokens.size() / chunk_len;
10991099
for (int chunk_idx = 0; chunk_idx < chunk_count; chunk_idx++) {
11001100
// clip_l
@@ -1181,7 +1181,7 @@ struct FluxCLIPEmbedder : public Conditioner {
11811181
int height,
11821182
int adm_in_channels = -1,
11831183
bool force_zero_embeddings = false) {
1184-
auto tokens_and_weights = tokenize(text, 256, true);
1184+
auto tokens_and_weights = tokenize(text, 255, true);
11851185
return get_learned_condition_common(work_ctx, n_threads, tokens_and_weights, clip_skip, force_zero_embeddings);
11861186
}
11871187

stable-diffusion.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -400,15 +400,7 @@ class StableDiffusionGGML {
400400
first_stage_model->alloc_params_buffer();
401401
first_stage_model->get_param_tensors(tensors, "first_stage_model");
402402
} else {
403-
clip_backend = backend;
404-
bool use_t5xxl = false;
405-
if (sd_version_is_dit(version)) {
406-
use_t5xxl = true;
407-
}
408-
if (!ggml_backend_is_cpu(backend) && use_t5xxl && conditioner_wtype != GGML_TYPE_F32) {
409-
clip_on_cpu = true;
410-
LOG_INFO("set clip_on_cpu to true");
411-
}
403+
clip_backend = backend;
412404
if (clip_on_cpu && !ggml_backend_is_cpu(backend)) {
413405
LOG_INFO("CLIP: Using CPU backend");
414406
clip_backend = ggml_backend_cpu_init();

0 commit comments

Comments
 (0)