FLUX.1-dev image generation on M1 Mac using GPU

How about this?

import torch
device = torch.device("mps" if torch.backends.mps.is_available() else "cpu")
prompt = "A cat holding a sign that says hello world"
pipe.to(device)
image = pipe(
    prompt,
    height=1024,
    width=1024,
    guidance_scale=3.5,
    num_inference_steps=1,
    max_sequence_length=512,
    generator=torch.Generator(device).manual_seed(0)
).images[0]
image.save("flux-dev.png")