Optimum/Neuron: RuntimeError: forward() is missing value for argument 'argument_4'

I’m trying to render an image on AWS Inferentia2 using Optimum NeuronX. I have converted juggernautXL_v8Rundiffusion model to the Diffusers format using sdxl-to-diffusers-v2 and then to Neuron format with:

optimum-cli export neuron \
    --model juggernautXL_v8Rundiffusion \
    --task stable-diffusion-xl \
    --batch_size 1 --num_images_per_prompt 1 \
    --height 1024 --width 1024 \
    juggernautXL_v8Rundiffusion_neuron

Then I’m trying to generate an image with this Python code:

from optimum.neuron import NeuronStableDiffusionPipeline
stable_diffusion = NeuronStableDiffusionPipeline.from_pretrained(model_path)
image = stable_diffusion(prompt).images[0]

But it fails with:

RuntimeError: forward() is missing value for argument 'argument_4'. 
Declaration: forward(__torch__.torch_neuronx.xla_impl.trace.___torch_mangle_11.NeuronModule self, 
Tensor argument_1, Tensor argument_2, Tensor argument_3, Tensor argument_4, Tensor argument_5)
-> ((Tensor))

Any idea why? Do I need any other parameters other than prompt in the inference step?

Figured it out. It’s a SDXL model so needed to use NeuronStableDiffusionXLPipeline instead of NeuronStableDiffusionPipeline.

Just in case someone comes across this too.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.