Skip to content

Commit 1e690e1

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

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
@@ -1144,7 +1144,7 @@ struct FluxCLIPEmbedder : public Conditioner {
11441144
struct ggml_tensor* pooled = NULL; // [768,]
11451145
std::vector<float> hidden_states_vec;
11461146

1147-
size_t chunk_len = 256;
1147+
size_t chunk_len = 255;
11481148
size_t chunk_count = t5_tokens.size() / chunk_len;
11491149
for (int chunk_idx = 0; chunk_idx < chunk_count; chunk_idx++) {
11501150
// clip_l
@@ -1231,7 +1231,7 @@ struct FluxCLIPEmbedder : public Conditioner {
12311231
int height,
12321232
int adm_in_channels = -1,
12331233
bool force_zero_embeddings = false) {
1234-
auto tokens_and_weights = tokenize(text, 256, true);
1234+
auto tokens_and_weights = tokenize(text, 255, true);
12351235
return get_learned_condition_common(work_ctx, n_threads, tokens_and_weights, clip_skip, force_zero_embeddings);
12361236
}
12371237

stable-diffusion.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,7 @@ class StableDiffusionGGML {
393393
first_stage_model->alloc_params_buffer();
394394
first_stage_model->get_param_tensors(tensors);
395395
} else {
396-
clip_backend = backend;
397-
bool use_t5xxl = false;
398-
if (sd_version_is_dit(version)) {
399-
use_t5xxl = true;
400-
}
401-
if (!ggml_backend_is_cpu(backend) && use_t5xxl && conditioner_wtype != GGML_TYPE_F32) {
402-
clip_on_cpu = true;
403-
LOG_INFO("set clip_on_cpu to true");
404-
}
396+
clip_backend = backend;
405397
if (clip_on_cpu && !ggml_backend_is_cpu(backend)) {
406398
LOG_INFO("CLIP: Using CPU backend");
407399
clip_backend = ggml_backend_cpu_init();

0 commit comments

Comments
 (0)