Port or add a model to SD.Next using a phased integration flow: select the least-new-code path that follows SD.Next conventions, invoke port-pipeline when no upstream Diffusers implementation exists, then implement loader and routing updates and validate.
74%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./.github/skills/port-model/SKILL.mdRead the task, identify the model architecture and artifact layout, choose the integration path that requires the least amount of new code while adhering to SD.Next patterns, implement the loader and pipeline wiring, and validate the result.
pipelines/<model> package and loader.github/instructions/core.instructions.md for relevant core runtime and model porting guidance before proceeding.Prefer the smallest correct integration path.
pipelines/<model>.Before collecting inputs: If the model repository is gated (HTTP 403, access agreement required, or waiting list):
secrets.json in the workspace root for a huggingface_token fieldBefore editing anything, determine these facts:
If any of these remain unclear after reading the repo and source artifacts, ask concise clarifying questions before implementing.
Before implementing model-reference updates, explicitly ask the user which category the model belongs to:
basecloudquantdistillednunchakucommunityDo not guess this category. Use the user answer to decide which reference JSON file(s) to update.
Before implementing a pipeline, explicitly ask the user if the model already has an upstream Diffusers pipeline that can be reused. If the desired model implementation does not already exist in upstream Diffusers, ask for the reference implementation's code path. A repository URL is acceptable when the code path is not yet available locally. Do not begin a custom pipeline port until the reference implementation is identified.
When no usable upstream Diffusers implementation exists:
port-pipeline. Ask for any missing values before proceeding.port-pipeline skill with the model task, artifact layout, components, source code path, destination path, target class name, and relevant findings already gathered. Do not ask the user to repeat known details.port-pipeline implement and validate the custom Diffusers pipeline, then return control to this port-model workflow. Continue the remaining SD.Next model integration and validation here.port-pipeline was invoked from this port-model run, its final handoff must return to this run rather than invoke port-model again.Start by reading the task description, then inspect the closest matching implementations.
.github/copilot-instructions.md.github/instructions/core.instructions.mdpipelines/generic.pypipelines/model_*.py files similar to the target modelmodules/sd_models.pymodules/sd_detect.pymodules/modeldata.pyUseful examples by pattern:
pipelines/model_chroma.py, pipelines/model_z_image.pypipelines/f_lite/pipelines/model_z_image.py, pipelines/model_flux2_klein.pyUse this quick order before diving into detailed path requirements:
Use this path when the model already has a usable Diffusers pipeline and component classes.
Implement:
pipelines/model_<name>.pymodules/sd_models.py dispatch branch in load_diffuser_forcemodules/sd_detect.py filename autodetect branch if appropriatemodules/modeldata.py model type detection branchEvery base-model family loader, whether upstream or custom, must be dispatched from an explicit detected-model-type branch in modules/sd_models.py:load_diffuser_force. Do not rely on load_diffuser_folder or another generic fallback to trigger a family loader.
Reuse:
generic.load_transformer(...)generic.load_text_encoder(...)sd_hijack_te.init_hijack(pipe) and sd_hijack_vae.init_hijack(pipe) where relevantUse this path when the model architecture, sampler, or prompt encoding is not available upstream.
Implement:
pipelines/<model>/__init__.pypipelines/<model>/model.pypipelines/<model>/pipeline.pypipelines/model_<name>.pymodules/sd_models.py, modules/sd_detect.py, and modules/modeldata.pyModel module responsibilities:
Pipeline module responsibilities:
DiffusionPipeline subclass__init__from_pretrainedencode_prompt or equivalent prompt preparation__call__If custom pipeline is provided by user, check it for accuracy and completness but do not assume it is perfect. Make necessary adjustments to fit SD.Next patterns and validate the result.
Fix all relative imports to be absolute and compatible with SD.Next repo structure, make sure that all imports are resolvable and make sure it passes ruff checks.
Use this path when the model source is not a normal Diffusers repository.
Requirements:
Do not fake a from_pretrained implementation that silently assumes missing subfolders exist.
Most new model families need all of these:
pipelines/model_<name>.py
Purpose: SD.Next loader entry pointmodules/sd_models.py
Purpose: route detected model type to the correct loadermodules/sd_detect.py
Purpose: detect model family from filename or repo namemodules/modeldata.py
Purpose: classify loaded pipeline instance back into SD.Next model typeAdd only what the model actually needs.
Check these conditional runtime registries and update them when the new model type needs the behavior they control:
modules/sd_samplers_common.py:flow_models when the model needs scheduler configs with use_flow_sigmas to use flow sigmas.modules/vae/model_map.py:vae_map when SD.Next VAE handling needs to map the model type to a VAE family.Reference catalog touchpoints are also required for model ports intended to appear in SD.Next model references.
data/reference-base.json for basedata/reference-cloud.json for clouddata/reference-quantized.json for quantdata/reference-distilled.json for distilleddata/reference-nunchaku.json for nunchakudata/reference-community.json for communityIf the model belongs to multiple categories, update each corresponding data/reference*.json file.
When adding a new model in the user-confirmed base category, also update both wiki model pages:
wiki/Model-Support.md, using the existing linked-name and variant style.wiki/Models.md for the new base model variants, following the existing table columns and formatting.These wiki updates apply to new base models, not models added only to cloud, quant, distilled, nunchaku, or community categories.
Possible extra integration points:
diffusers.pipelines.auto_pipeline.AUTO_*_PIPELINES_MAPPING when task switching matterspipe.task_args when SD.Next needs default runtime kwargs such as output_typeIn pipelines/model_<name>.py:
sd_models.path_to_repo(checkpoint_info)sd_models.hf_auth_check(checkpoint_info)model_quant.get_dit_args(...) for load argsdevices.dtypegeneric.load_transformer(...), define a TransformerSpec for the model and pass it through the native_spec= argument. Put the spec in the model package or another appropriate shared module, and define the model's checkpoint prefixes, converter, and sibling handling as needed; do not omit the spec or rely on the generic single-file fallback.allow_quant at its loader default for generic.load_transformer(...) and generic.load_text_encoder(...) unless a verified model-specific constraint requires disabling or otherwise overriding quantization.generic.load_transformer(...) and generic.load_text_encoder(...). Let the pipeline's from_pretrained(...) load its processor, tokenizer, and other declared components unless a verified model-specific requirement calls for separate loading.generic.load_text_encoder(...) when possiblepipe.task_args = {'output_type': 'np'} when the pipeline should default to numpy output for SD.Nextdevices.torch_gc(...)Do not hardcode assumptions about CUDA-only execution, local paths, or one-off environment state.
When building a custom pipeline:
diffusers.DiffusionPipelineDiffusionPipeline.register_modules(...)prompt, negative_prompt, generator, output_type, and return_dict when the task is text-to-image-likeDo not add generic Stable Diffusion arguments that the model does not support.
After implementation, validate in this order:
Always report what was validated and what was not.
When the user asks to add or port a model for references, also perform these steps:
data/reference*.json file(s) based on the user-confirmed category.models/Reference for the new model.Notes:
models/Reference (capital R).When porting a new model or model family to SD.Next, also update CHANGELOG.md:
## Update for 2026-04-10)Example format:
- [BRIA FIBO](https://huggingface.co/briaai/FIBO) 8B parameter text-to-image model using Flow Matching
includes *Normal*, *Edit*, and *Lite* (distilled) variants
features lightweight SmolLM3-3B text encoder with efficient inferencesd_models.py but not sd_detect.pymodules/modeldata.py still classifies the pipeline incorrectlyChromatorch_dtype or other loader args are passed twiceWhen using this skill, the final implementation should usually include:
vladmandic/sdnext
6657d06
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.