Add SeFi-Image pipeline - #14084
Conversation
|
@yiyixuxu @sayakpaul @asomoza @dg845 gentle ping - this pr is waiting for review for 3 weeks now? |
There was a problem hiding this comment.
🤗 Serge says:
Solid, well-tested first cut of the SeFi-Image pipeline, but there are several deviations from the project's coding rules (no defensive code, no unused params, # Copied from for adapted helpers) and a structural question about how the Flux2 backbone is reused.
Structure / conventions
SeFiTransformer2DModelinstantiates a fullFlux2Transformer2DModelasself.backbone, mutatestime_guidance_embedtonn.Identity(), and then reaches into its internals (x_embedder,context_embedder,pos_embed,transformer_blocks,norm_out,proj_out, the three modulation modules) to reimplement the forward. This diverges from the single-file /# Copied frommodel conventions in.ai/models.md. Consider importing the Flux2 block classes directly (with# Copied fromwhere appropriate) instead of wrapping the whole model and deleting one of its submodules. As written, the checkpoint will also carry deadtime_guidance_embedparams until thenn.Identity()swap, andself.out_channelson the SeFi model is set but never used.- Several pipeline helpers (
_prepare_text_ids,_prepare_latent_ids,_pack_latents,_unpatchify_latents) appear adapted frompipelines/flux2/pipeline_flux2.pybut lack# Copied fromheaders, somake fix-copieswon't keep them in sync._prepare_text_idsalso carries an unusedt_coordparameter (never passed by any caller).
Defensive code (repo rule: no defensive/fallback code)
SeFiPipeline.__init__re-appliesX if X is None else defaultforsemantic_channels,texture_vae_name,default_guidance_scale,default_num_inference_steps,text_encoder_hidden_layers,max_sequence_lengtheven though the signature already supplies non-Nonedefaults. This is dead code unless a caller explicitly passesNone._build_chat_textwrapsapply_chat_templatein atry/except TypeErrorfallback, and_align_text_encoder_rotary_dtypeusestry/except StopIterationplushasattr/getattrchains — both are the kind of "just in case" fallbacks the guidelines ask to drop in favor of clear expected inputs / concise errors.
LoRA decorator without the mixin
SeFiTransformer2DModel.forwardis decorated with@apply_lora_scale("joint_attention_kwargs"), but the class does not inheritPeftAdapterMixin, soscale_lora_layers/unscale_lora_layershave nothing to act on. Either add the mixin (and wire up LoRA loading) or drop the decorator so the intent isn't misleading.
Correctness question
_timesteps_and_sigmasindexes directly intoscheduler.timesteps/scheduler.sigmasat their training resolution and the pipeline never callsscheduler.set_timesteps. SinceFlowMatchEulerDiscreteSchedulerdefaults toshift=3.0, that scheduler-side shift compounds with the pipeline's owntimestep_shift_alpha. Please confirm the converted scheduler config usesshift=1.0(or otherwise document/justify the compounding), since the fast tests don't exercise real checkpoint schedules.
Minor
texture_vae_config_pathhas two branches returning the identical path (root / "vae" / "config.json"); collapse them._current_timestepis set to a sigma value (base_sigmas_schedule[i]) and handed tocallback_on_step_endas the timestep argument — slightly misleading naming.
Tests are structured correctly against the current tester mixins and cover inference, turbo validation, CFG batching, and the rotary-dtype alignment path, which is good.
serge v0.1.0 · model: claude-opus-4-8 · 32 LLM turns · 34 tool calls · 209.8s · 2083251 in / 12464 out tokens
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@vladmandic The standalone Diffusers-format checkpoints are now available and can be loaded directly with
|
What does this PR do?
Adds Diffusers support for SeFi-Image, including:
SeFiTransformer2DModelSeFiPipelineThe pipeline supports Qwen3-VL prompt encoding, SeFi dual-time denoising, classifier-free guidance for non-turbo checkpoints, turbo step validation, and model CPU offload.
Converted checkpoints
The original SeFi-Image checkpoint repositories remain unchanged.
Review follow-up
backbone.*keys strict.Before submitting
.ai/review-rules.md?Who can review?
Potential reviewers for pipelines/models: @yiyixuxu @dg845 @asomoza