@@ -89,6 +89,8 @@ struct SDParams {
8989 std::vector<int > high_noise_skip_layers = {7 , 8 , 9 };
9090 sd_sample_params_t high_noise_sample_params;
9191
92+ float moe_boundary = 0 .875f ;
93+
9294 int video_frames = 1 ;
9395 int fps = 16 ;
9496
@@ -117,6 +119,7 @@ struct SDParams {
117119 SDParams () {
118120 sd_sample_params_init (&sample_params);
119121 sd_sample_params_init (&high_noise_sample_params);
122+ high_noise_sample_params.sample_steps = -1 ;
120123 }
121124};
122125
@@ -167,6 +170,7 @@ void print_params(SDParams params) {
167170 printf (" height: %d\n " , params.height );
168171 printf (" sample_params: %s\n " , SAFE_STR (sample_params_str));
169172 printf (" high_noise_sample_params: %s\n " , SAFE_STR (high_noise_sample_params_str));
173+ printf (" moe_boundary: %.3f\n " , params.moe_boundary );
170174 printf (" strength(img2img): %.2f\n " , params.strength );
171175 printf (" rng: %s\n " , sd_rng_type_name (params.rng_type ));
172176 printf (" seed: %ld\n " , params.seed );
@@ -243,7 +247,7 @@ void print_usage(int argc, const char* argv[]) {
243247 printf (" --high-noise-scheduler {discrete, karras, exponential, ays, gits} Denoiser sigma scheduler (default: discrete)\n " );
244248 printf (" --high-noise-sampling-method {euler, euler_a, heun, dpm2, dpm++2s_a, dpm++2m, dpm++2mv2, ipndm, ipndm_v, lcm, ddim_trailing, tcd}\n " );
245249 printf (" (high noise) sampling method (default: \" euler_a\" )\n " );
246- printf (" --high-noise-steps STEPS (high noise) number of sample steps (default: 20 )\n " );
250+ printf (" --high-noise-steps STEPS (high noise) number of sample steps (default: -1 = auto )\n " );
247251 printf (" SLG will be enabled at step int([STEPS]*[START]) and disabled at int([STEPS]*[END])\n " );
248252 printf (" --strength STRENGTH strength for noising/unnoising (default: 0.75)\n " );
249253 printf (" --style-ratio STYLE-RATIO strength for keeping input identity (default: 20)\n " );
@@ -274,6 +278,8 @@ void print_usage(int argc, const char* argv[]) {
274278 printf (" --chroma-t5-mask-pad PAD_SIZE t5 mask pad size of chroma\n " );
275279 printf (" --video-frames video frames (default: 1)\n " );
276280 printf (" --fps fps (default: 24)\n " );
281+ printf (" --moe-boundary BOUNDARY Timestep boundary for Wan2.2 MoE model. (default: 0.875)\n " );
282+ printf (" Only enabled if `--high-noise-steps` is set to -1\n " );
277283 printf (" -v, --verbose print extra info\n " );
278284}
279285
@@ -362,7 +368,7 @@ bool parse_options(int argc, const char** argv, ArgOptions& options) {
362368 std::string arg;
363369 for (int i = 1 ; i < argc; i++) {
364370 bool found_arg = false ;
365- arg = argv[i];
371+ arg = argv[i];
366372
367373 for (auto & option : options.string_options ) {
368374 if ((option.short_name .size () > 0 && arg == option.short_name ) || (option.long_name .size () > 0 && arg == option.long_name )) {
@@ -423,7 +429,7 @@ bool parse_options(int argc, const char** argv, ArgOptions& options) {
423429 for (auto & option : options.manual_options ) {
424430 if ((option.short_name .size () > 0 && arg == option.short_name ) || (option.long_name .size () > 0 && arg == option.long_name )) {
425431 found_arg = true ;
426- int ret = option.cb (argc, argv, i);
432+ int ret = option.cb (argc, argv, i);
427433 if (ret < 0 ) {
428434 invalid_arg = true ;
429435 break ;
@@ -435,7 +441,7 @@ bool parse_options(int argc, const char** argv, ArgOptions& options) {
435441 break ;
436442 }
437443 if (!found_arg) {
438- fprintf (stderr, " error: unknown argument: %s\n " , arg.c_str ());
444+ fprintf (stderr, " error: unknown argument: %s\n " , arg.c_str ());
439445 return false ;
440446 }
441447 }
@@ -507,6 +513,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
507513 {" " , " --strength" , " " , ¶ms.strength },
508514 {" " , " --style-ratio" , " " , ¶ms.style_ratio },
509515 {" " , " --control-strength" , " " , ¶ms.control_strength },
516+ {" " , " --moe-boundary" , " " , ¶ms.moe_boundary },
510517 };
511518
512519 options.bool_options = {
@@ -767,8 +774,7 @@ void parse_args(int argc, const char** argv, SDParams& params) {
767774 }
768775
769776 if (params.high_noise_sample_params .sample_steps <= 0 ) {
770- fprintf (stderr, " error: the high_noise_sample_steps must be greater than 0\n " );
771- exit (1 );
777+ params.high_noise_sample_params .sample_steps = -1 ;
772778 }
773779
774780 if (params.strength < 0 .f || params.strength > 1 .f ) {
@@ -1222,6 +1228,7 @@ int main(int argc, const char* argv[]) {
12221228 params.height ,
12231229 params.sample_params ,
12241230 params.high_noise_sample_params ,
1231+ params.moe_boundary ,
12251232 params.strength ,
12261233 params.seed ,
12271234 params.video_frames ,
0 commit comments