Scheduler parameter ignored when creating StableDiffusionPipeline

I’m trying to write a program to learn about various diffusers, starting with StableDiffusionPipeline. I am able to generate images, but I am now trying to set a scheduler other than the default.

My code to create the pipeline is

    if (os.path.isdir(modelPath)):
        pipe = StableDiffusionPipeline.from_pretrained(modelPath, scheduler=sampler, torch_dtype=torch.float16)
    else:
        pipe = StableDiffusionPipeline.from_single_file(modelPath, scheduler=sampler, torch_dtype=torch.float16)

I print the scheduler object I pass to this call and get
Scheduler requested DDIMScheduler {
“_class_name”: “DDIMScheduler”,
“_diffusers_version”: “0.18.2”,
“beta_end”: 0.03,
“beta_schedule”: “squaredcos_cap_v2”,
“beta_start”: 0.001,
“clip_sample”: false,
“clip_sample_range”: 0.0,
“dynamic_thresholding_ratio”: 0.5,
“num_train_timesteps”: 1,
“prediction_type”: “sample”,
“rescale_betas_zero_snr”: false,
“sample_max_value”: 0.0,
“set_alpha_to_one”: true,
“steps_offset”: 0.0,
“thresholding”: false,
“timestep_spacing”: “trailing”,
“trained_betas”: null
}

I print pipe.scheduler after creating the pipeline and I get

Using scheduler: PNDMScheduler {
“_class_name”: “PNDMScheduler”,
“_diffusers_version”: “0.18.2”,
“beta_end”: 0.012,
“beta_schedule”: “scaled_linear”,
“beta_start”: 0.00085,
“clip_sample”: false,
“num_train_timesteps”: 1000,
“prediction_type”: “epsilon”,
“set_alpha_to_one”: false,
“skip_prk_steps”: true,
“steps_offset”: 1,
“timestep_spacing”: “leading”,
“trained_betas”: null
}

I don’t understand why the scheduler parameter is being ignored. Could it be because the parameters I set in my scheduler are invalid, so the pipeline is silently ignoring my scheduler and continuing to the the default one?
Am I misunderstanding something?

I found that if I explicitly set pipe.scheduler to my scheduler after creating the pipeline, that works.
This seems to be resolved by Allow non-default schedulers to be easily swapped into `DiffusionPipeline` classes · Issue #183 · huggingface/diffusers · GitHub, so I’m not sure why using the scheduler= parameter is not working.