Repository navigation
[refactor] Flatten Ming-flash-omni-2.0 imagegen args #4587
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,19 +104,17 @@ def expand_cfg_prompts( | |
| ) -> list[_CfgExpandedPrompt]: | ||
| """Expand a text-to-image request into one CFG-text companion (opt-in). | ||
|
|
||
| Triggers only when a non-empty | ||
| ``sampling_params.extra_args["image_gen"]["negative_prompt"]`` is set on | ||
| the stage-0 params; otherwise returns ``[]`` and the pipeline falls back | ||
| to zero negative (Ming's default behavior). | ||
| Triggers only when a non-empty `negative_prompt` is set flat on the stage-0 params | ||
| (`sampling_params.extra_args`); otherwise returns an empty list | ||
| and the pipeline falls back to zero negative (Ming's default behavior). | ||
| """ | ||
| if not isinstance(prompt, dict): | ||
| return [] | ||
| if prompt.get("modalities") != ["image"]: | ||
| return [] | ||
|
|
||
| extra_args = getattr(sampling_params, "extra_args", None) or {} | ||
| image_gen_args = extra_args.get("image_gen") or {} | ||
| negative = image_gen_args.get("negative_prompt") | ||
| negative = extra_args.get("negative_prompt") | ||
| if not isinstance(negative, str) or not negative.strip(): | ||
| return [] | ||
|
|
||
|
|
@@ -328,7 +326,7 @@ def _resolve_token_ids_from_stage_or_defaults( | |
| def _extract_byte5_from_sampling_params(sampling_params: Any) -> list[str] | None: | ||
| """Read ``byte5_text`` from the diffusion-stage sampling_params. | ||
|
|
||
| Looks up ``sampling_params.extra_args["image_gen"]["byte5_text"]`` (the | ||
| Looks up `sampling_params.extra_args["byte5_text"]` key (the | ||
| explicit API surface for ByT5 glyph text). Returns ``None`` if absent or | ||
| malformed, so callers can fall back to other sources. | ||
| """ | ||
|
|
@@ -337,10 +335,9 @@ def _extract_byte5_from_sampling_params(sampling_params: Any) -> list[str] | Non | |
| extra = getattr(sampling_params, "extra_args", None) | ||
| if not isinstance(extra, dict): | ||
| return None | ||
| image_gen = extra.get("image_gen") | ||
| if not isinstance(image_gen, dict): | ||
| return None | ||
| texts = image_gen.get("byte5_text") | ||
| texts = extra.get("byte5_text") | ||
| if isinstance(texts, str): | ||
| texts = [texts] | ||
| if isinstance(texts, list) and texts: | ||
| return [t for t in texts if isinstance(t, str)] | ||
| return None | ||
|
Comment on lines
341
to
343
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vllm_omni/diffusion/models/ming_flash_omni/pipeline_ming_imagegen.py#L239-L241 Seems
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Revised as allowing str as well |
||
|
|
@@ -361,10 +358,9 @@ def thinker2imagegen( | |
| CFG negative conditioning. Unknown-suffix outputs are skipped. | ||
|
|
||
| ``sampling_params`` is the diffusion stage's own SamplingParams, supplied | ||
| by the orchestrator. ByT5 explicit ``byte5_text`` is read from | ||
| ``sampling_params.extra_args.image_gen.byte5_text`` (preferred); falls | ||
| back to ``prompt.image_gen_extra_args.byte5_text``, then to auto-extraction | ||
| from quoted prompt text. | ||
| by the orchestrator. ByT5 explicit ``byte5_text`` is read from the flat | ||
| `sampling_params.extra_args.byte5_text` key (preferred); otherwise it is | ||
| auto-extracted from quoted prompt text. | ||
| """ | ||
| thinker_outputs = source_outputs | ||
| image_patch_token_id, image_end_token_id, num_query_tokens = _resolve_token_ids_from_stage_or_defaults(stage=None) | ||
|
|
@@ -417,17 +413,10 @@ def thinker2imagegen( | |
| if ref_image is not None: | ||
| extra["reference_image"] = ref_image | ||
|
|
||
| # ByT5 glyph text: prefer sampling_params (stage-1 explicit API), then | ||
| # prompt.image_gen_extra_args (serving_chat path), then auto-extract | ||
| # from quoted prompt text. | ||
| # ByT5 glyph text: prefer the flat byte5_text on sampling_params | ||
| # (stage-1 explicit API), else auto-extract from quoted prompt text. | ||
| prompt_text = prompt.get("prompt", "") | ||
| sp_byte5 = _extract_byte5_from_sampling_params(sampling_params) | ||
| if sp_byte5: | ||
| byte5_texts: list[str] | None = sp_byte5 | ||
| else: | ||
| ig_extra = prompt.get("image_gen_extra_args") or {} | ||
| cand = ig_extra.get("byte5_text") | ||
| byte5_texts = cand if isinstance(cand, list) and cand else None | ||
| byte5_texts: list[str] | None = _extract_byte5_from_sampling_params(sampling_params) | ||
|
|
||
| if byte5_texts: | ||
| extra["byte5_text"] = [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.