Skip to content

fix(diffusers): pass text prompts by keyword - #11836

Open
cananoo wants to merge 2 commits into
mudler:masterfrom
cananoo:fix/flux2-prompt-11833
Open

fix(diffusers): pass text prompts by keyword#11836
cananoo wants to merge 2 commits into
mudler:masterfrom
cananoo:fix/flux2-prompt-11833

Conversation

@cananoo

@cananoo cananoo commented Sep 2, 2026

Copy link
Copy Markdown

Fixes #11833

Pass text-to-image prompts using the named prompt argument. FLUX.2 pipelines accept image as their first positional argument, so the previous call left prompt unset and failed generation.

Validation: python -m compileall -q backend.py test.py; ruff check backend.py test.py --select F821; git diff --check. The focused pytest cannot run in this Windows environment because torch and diffusers are not installed. The added regression test models the FLUX.2-compatible signature. AI assistance is attributed in the commit trailer.

@cananoo
cananoo force-pushed the fix/flux2-prompt-11833 branch from e6c3b12 to a8c431c Compare September 2, 2026 10:09
@localai-org-maint-bot

Copy link
Copy Markdown
Collaborator

Review pass. The change is strictly safer than what it replaces, so this is close to merge. One caveat and one suggestion.

Why it is safe regardless of the FLUX.2 story: every diffusers text-to-image pipeline names that parameter prompt, so keyword passing cannot regress any pipeline, and it fixes any pipeline whose first positional slot is not the prompt. It does not introduce a duplicate-kwarg hazard either: if self.options already carried prompt, the old positional form raised the same TypeError.

Caveat: I could not verify the FLUX.2 premise. The commit says "FLUX.2 pipelines accept image as their first positional argument". Confirming that needs diffusers installed to introspect Flux2Pipeline.__call__, which I could not do. Worth knowing that nobody should merge this believing the FLUX.2 story is verified; merge it because keyword-passing is unconditionally correct. Related: the FLUX.2 entries in gallery/index.yaml:38313+ all route to stablediffusion-cpp, not the Python diffusers backend, so nothing shipped exercises this path today.

Suggestion: two sibling calls are still positional. backend.py:803 (self.pipe(image, ...), img2vid) and backend.py:808 (self.pipe(prompt, ...), txt2vid). If the positional-order concern is real, those have the same exposure and no test. Converting them in the same PR would close the class rather than one instance.

The new test lands in TestGenerateImageOptionsKwargsMerge, outside the @unittest.skipUnless(GRPC_AVAILABLE) gate, so it does run. Python unittest is correct here; the Ginkgo rule is Go-only.

Note that CI has never actually run on this PR: the workflow runs are all action_required and have expired, so the new test has not executed. A maintainer needs to approve workflows or you can push to retrigger.

@cananoo

cananoo commented Sep 4, 2026

Copy link
Copy Markdown
Author

Thanks for the careful review. I pushed fa26adc to close the sibling positional-call gap: the img2vid path now passes image= and the txt2vid path passes prompt=. This keeps the argument names explicit across all three diffusers generation paths. python -m compileall -q backend/python/diffusers/backend.py backend/python/diffusers/test.py and ruff check ... --select F821 pass locally. The FLUX.2 signature premise remains unverified here, as noted.

@cananoo

cananoo commented Sep 4, 2026

Copy link
Copy Markdown
Author

The updated head fa26adc has a passing DCO check. The remaining repository workflows are currently action_required and did not execute, so a maintainer approval or rerun is needed before the change can be fully evaluated.

pengmin added 2 commits September 4, 2026 15:21
FLUX.2 pipelines accept image as their first positional argument, so passing a text prompt positionally leaves prompt unset and fails generation. Use the named prompt parameter and cover the FLUX.2-compatible signature with a focused regression test.

Assisted-by: Codex:gpt-5
Signed-off-by: pengmin <minpeng@semigraph.com>
Signed-off-by: pengmin <minpeng@semigraph.com>
@cananoo
cananoo force-pushed the fix/flux2-prompt-11833 branch from fa26adc to fc083a9 Compare September 4, 2026 07:21
@cananoo

cananoo commented Sep 4, 2026

Copy link
Copy Markdown
Author

Updated the PR branch onto the latest mudler/LocalAI master (1f2f931) as requested. The PR change remains unchanged; the new head is fc083a9. Local Python compilation, Ruff F821, and git diff check pass. DCO and the repository workflows should rerun; some workflows may still require maintainer approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

diffusers backend: FLUX.2 pipelines fail with "Provide either prompt or prompt_embeds" because the prompt is passed positionally

2 participants