@@ -69,8 +69,17 @@ def predict_noise(self, x, timestep, model_options={}, seed=None):
69
69
negative_cond = self .conds .get ("negative" , None )
70
70
empty_cond = self .conds .get ("empty_negative_prompt" , None )
71
71
72
- (noise_pred_pos , noise_pred_neg , noise_pred_empty ) = \
73
- comfy .samplers .calc_cond_batch (self .inner_model , [positive_cond , negative_cond , empty_cond ], x , timestep , model_options )
72
+ conds = [positive_cond , negative_cond , empty_cond ]
73
+
74
+ out = comfy .samplers .calc_cond_batch (self .inner_model , conds , x , timestep , model_options )
75
+
76
+ # Apply pre_cfg_functions since sampling_function() is skipped
77
+ for fn in model_options .get ("sampler_pre_cfg_function" , []):
78
+ args = {"conds" :conds , "conds_out" : out , "cond_scale" : self .cfg , "timestep" : timestep ,
79
+ "input" : x , "sigma" : timestep , "model" : self .inner_model , "model_options" : model_options }
80
+ out = fn (args )
81
+
82
+ noise_pred_pos , noise_pred_neg , noise_pred_empty = out
74
83
cfg_result = perp_neg (x , noise_pred_pos , noise_pred_neg , noise_pred_empty , self .neg_scale , self .cfg )
75
84
76
85
# normally this would be done in cfg_function, but we skipped
@@ -82,6 +91,7 @@ def predict_noise(self, x, timestep, model_options={}, seed=None):
82
91
"denoised" : cfg_result ,
83
92
"cond" : positive_cond ,
84
93
"uncond" : negative_cond ,
94
+ "cond_scale" : self .cfg ,
85
95
"model" : self .inner_model ,
86
96
"uncond_denoised" : noise_pred_neg ,
87
97
"cond_denoised" : noise_pred_pos ,
0 commit comments