fix: use patch token count for the Flux scheduler (#2293)

This commit is contained in:
DrMkdaddy authored and GitHub committed 2026-11-08 21:37:06 +08:00
1 parent f61053c25d
commit b43af40461
3 files changed
+14 -1

No files matched your search

+4
View File
@@ -1437,6 +1437,10 @@ namespace Flux {
return "flux";
}
int get_patch_size() const override {
return config.patch_size;
}
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors, const std::string& prefix) override {
flux.get_param_tensors(tensors, prefix);
}
+4
View File
@@ -237,6 +237,10 @@ public:
virtual sd::Tensor<float> compute(int n_threads,
const DiffusionParams& diffusion_params) = 0;
virtual int get_patch_size() const {
return 1;
}
void get_param_tensors(std::map<std::string, ggml_tensor*>& tensors) {
get_param_tensors(tensors, prefix);
}
+6 -1
View File
@@ -2930,7 +2930,12 @@ int StableDiffusionGGML::get_image_channels() const {
int StableDiffusionGGML::get_image_seq_len(int h, int w) {
int vae_scale_factor = get_vae_scale_factor();
return (h / vae_scale_factor) * (w / vae_scale_factor);
int patch_size = diffusion_model != nullptr ? diffusion_model->get_patch_size() : 1;
int latent_h = h / vae_scale_factor;
int latent_w = w / vae_scale_factor;
int tokens_h = (latent_h + patch_size - 1) / patch_size;
int tokens_w = (latent_w + patch_size - 1) / patch_size;
return tokens_h * tokens_w;
}
sd::Tensor<float> StableDiffusionGGML::generate_init_latent(int width,