Skip to content

fix(flux2): restore Mistral processor loading - #1628

Merged
Artiprocher merged 1 commit into
modelscope:mainfrom
primorLee:fix/1324-flux2-text-parity
Aug 24, 2026
Merged

fix(flux2): restore Mistral processor loading#1628
Artiprocher merged 1 commit into
modelscope:mainfrom
primorLee:fix/1324-flux2-text-parity

Conversation

@primorLee

Copy link
Copy Markdown
Contributor

Summary

  • restore AutoProcessor loading for the Mistral3 text encoder used by FLUX.2-dev
  • retain AutoTokenizer for the Qwen3 text encoder used by FLUX.2 Klein
  • add CPU regression tests for both model-family paths

Problem

The original FLUX.2-dev integration loaded its tokenizer directory through AutoProcessor. When Klein/Qwen3 support was added, the shared loader was changed to AutoTokenizer unconditionally.

FLUX.2-dev passes structured multimodal-style message content to apply_chat_template:

{"content": [{"type": "text", "text": prompt}]}

The Mistral3 path requires its processor to normalize that structure before tokenization. Calling the bare tokenizer diverges from both reference implementations:

This explains why FLUX.2-dev prompt handling regressed while the Qwen3/Klein path still required a tokenizer.

Fix

Select the loader from the text encoder actually present in the model pool:

  • Mistral3 / FLUX.2-dev -> AutoProcessor
  • Qwen3 / FLUX.2 Klein -> AutoTokenizer

If both are absent, the default FLUX.2-dev configuration continues to use AutoProcessor.

Validation

  • baseline current main: Mistral3 processor-selection test fails; Qwen3 tokenizer test passes
  • after this change: 2 tests pass
  • python -B -m unittest discover -s tests -p test_flux2_tokenizer_selection.py -v
  • Python compilation passes for both changed files
  • Ruff passes for the new test and the new production path after excluding ten unrelated pre-existing findings in the legacy pipeline file
  • git diff --check passes

I could not run the gated FLUX.2-dev checkpoint end to end, so this PR claims restoration of the official prompt-processing path rather than an image-level parity measurement.

Closes #1324

@Artiprocher

Copy link
Copy Markdown
Collaborator

@primorLee Thanks for your contribution! We will fix it.

@Artiprocher
Artiprocher merged commit 3464a05 into modelscope:main Aug 24, 2026
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.

FLUX.2 dev generations mismatch with diffusers

2 participants