vladmandic/sdnext/port-model
Claude Code and agent skill by vladmandic/sdnext
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install vladmandic/sdnext/port-modelSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as vladmandic/sdnext/port-model.
Port Model To SD.Next And Diffusers
Read 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.
When To Use
- The user wants to add a new model family to SD.Next
- A standalone inference script needs to become a Diffusers-style pipeline
- A raw checkpoint or safetensors repo needs an SD.Next loader
- A model already exists in Diffusers but is not yet wired into SD.Next
- A custom architecture needs a repo-local
pipelines/<model>package and loader
Guidance
- Consult
.github/instructions/core.instructions.mdfor relevant core runtime and model porting guidance before proceeding.
Core Rule
Prefer the smallest correct integration path.
- If upstream Diffusers already supports the model cleanly, reuse the upstream pipeline and only add SD.Next wiring.
- If the model requires custom architecture or sampler behavior, add a repo-local pipeline package under
pipelines/<model>. - If the model ships as a raw checkpoint instead of a Diffusers repo, load or remap weights explicitly instead of pretending it is a standard Diffusers layout.
Handle Gated Models
Before collecting inputs: If the model repository is gated (HTTP 403, access agreement required, or waiting list):
- Check
secrets.jsonin the workspace root for ahuggingface_tokenfield - If token exists, use it to authenticate and attempt access
- If token missing, invalid, or access still denied, abort the port work immediately and report:
- Model name and repo link
- Specific access barrier (gated, closed, waiting list, license agreement)
- Required steps for user to gain access or provide token
- Do not proceed with implementation
Inputs To Collect First
Before editing anything, determine these facts:
- Model task: text-to-image, img2img, inpaint, editing, video, multimodal, or other
- Artifact format: Diffusers repo, local folder, single-file safetensors, ckpt, GGUF, or custom layout
- Core components: transformer or UNet, VAE or VQ model, text encoder, tokenizer or processor, scheduler, image encoder, adapters
- Whether output is latent-space or direct pixel-space
- Whether the model family has one fixed architecture or multiple variants
- Whether prompt encoding follows a normal tokenizer path or a custom chat/template path
- Whether there is an existing in-repo analogue to copy structurally
If any of these remain unclear after reading the repo and source artifacts, ask concise clarifying questions before implementing.
Mandatory Category Question
Before implementing model-reference updates, explicitly ask the user which category the model belongs to:
basecloudquantdistillednunchakucommunity
Do not guess this category. Use the user answer to decide which reference JSON file(s) to update.
Mandatory Pipeline Question
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.
Custom Pipeline Handoff
When no usable upstream Diffusers implementation exists:
- Collect the reference implementation code path, destination path in this repository, and target pipeline class name required by
port-pipeline. Ask for any missing values before proceeding. - Invoke the
port-pipelineskill 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. - Let
port-pipelineimplement and validate the custom Diffusers pipeline, then return control to thisport-modelworkflow. Continue the remaining SD.Next model integration and validation here. - If
port-pipelinewas invoked from thisport-modelrun, its final handoff must return to this run rather than invokeport-modelagain.
Repo Files To Check
Start by reading the task description, then inspect the closest matching implementations.
.github/copilot-instructions.md.github/instructions/core.instructions.mdpipelines/generic.pypipelines/model_*.pyfiles similar to the target modelmodules/sd_models.pymodules/sd_detect.pymodules/modeldata.py
Useful examples by pattern:
- Existing upstream Diffusers loader:
pipelines/model_chroma.py,pipelines/model_z_image.py - Custom in-repo pipeline package:
pipelines/f_lite/ - Shared Qwen loader pattern:
pipelines/model_z_image.py,pipelines/model_flux2_klein.py
Integration Decision Tree
Use this quick order before diving into detailed path requirements:
- If an upstream Diffusers pipeline already covers the model, choose path 1.
- If upstream support is insufficient but the model can be expressed as a Diffusers-style custom package, choose path 2.
- If artifacts are raw checkpoints or single-file weights without a usable Diffusers layout, choose path 3.
1. Upstream Diffusers Support Exists
Use this path when the model already has a usable Diffusers pipeline and component classes.
Implement:
pipelines/model_<name>.pymodules/sd_models.pydispatch branch inload_diffuser_forcemodules/sd_detect.pyfilename autodetect branch if appropriatemodules/modeldata.pymodel type detection branch
Every 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(...)- Existing processor or tokenizer loading patterns
sd_hijack_te.init_hijack(pipe)andsd_hijack_vae.init_hijack(pipe)where relevant
2. Custom Pipeline Needed
Use 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>.py- SD.Next registration in
modules/sd_models.py,modules/sd_detect.py, andmodules/modeldata.py
Model module responsibilities:
- Architecture classes
- Config handling and defaults
- Weight remapping or checkpoint conversion helpers
- Raw checkpoint loading helpers if needed
Pipeline module responsibilities:
DiffusionPipelinesubclass__init__from_pretrainedencode_promptor equivalent prompt preparation__call__- Output dataclass
- Optional callback handling and output conversion
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.
3. Raw Checkpoint Or Single-File Weights
Use this path when the model source is not a normal Diffusers repository.
Requirements:
- Resolve checkpoint path from local file, local directory, or Hub repo
- Load state dict directly
- Remap keys when training format differs from inference format
- Infer config from tensor shapes only if the model family truly varies and no config file exists
- Raise explicit errors for ambiguous or incomplete layouts
Do not fake a from_pretrained implementation that silently assumes missing subfolders exist.
Required SD.Next Touchpoints
Most new model families need all of these:
pipelines/model_<name>.py
Purpose: SD.Next loader entry point
modules/sd_models.py
Purpose: route detected model type to the correct loader
modules/sd_detect.py
Purpose: detect model family from filename or repo name
modules/modeldata.py
Purpose: classify loaded pipeline instance back into SD.Next model type
Add 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_modelswhen the model needs scheduler configs withuse_flow_sigmasto use flow sigmas.modules/vae/model_map.py:vae_mapwhen 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.jsonforbasedata/reference-cloud.jsonforclouddata/reference-quantized.jsonforquantdata/reference-distilled.jsonfordistilleddata/reference-nunchaku.jsonfornunchakudata/reference-community.jsonforcommunity
If 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:
- Add the model family to
wiki/Model-Support.md, using the existing linked-name and variant style. - Add one or more rows to
wiki/Models.mdfor the new base model variants, following the existing table columns and formatting. - Use official source links and verified architecture, parameter, encoder, size, license, and release-date details. Leave unavailable details blank or clearly unspecified; do not infer them.
- Check both pages for an existing entry first and update it instead of adding a duplicate.
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_MAPPINGwhen task switching matterspipe.task_argswhen SD.Next needs default runtime kwargs such asoutput_type- VAE hijack, TE hijack, or task-specific processors
Loader Conventions
In pipelines/model_<name>.py:
- Use
sd_models.path_to_repo(checkpoint_info) - Call
sd_models.hf_auth_check(checkpoint_info) - Use
model_quant.get_dit_args(...)for load args - Respect
devices.dtype - Log meaningful loader details
- When using
generic.load_transformer(...), define aTransformerSpecfor the model and pass it through thenative_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. - Leave
allow_quantat its loader default forgeneric.load_transformer(...)andgeneric.load_text_encoder(...)unless a verified model-specific constraint requires disabling or otherwise overriding quantization. - Explicitly preload only the transformer and text encoder through
generic.load_transformer(...)andgeneric.load_text_encoder(...). Let the pipeline'sfrom_pretrained(...)load its processor, tokenizer, and other declared components unless a verified model-specific requirement calls for separate loading. - Reuse
generic.load_text_encoder(...)when possible - Set
pipe.task_args = {'output_type': 'np'}when the pipeline should default to numpy output for SD.Next - Clean up temporary references and call
devices.torch_gc(...)
Do not hardcode assumptions about CUDA-only execution, local paths, or one-off environment state.
Pipeline Conventions
When building a custom pipeline:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.github/skills/port-model/SKILL.md
Popularity
- Repository stars
- 7,095
- Repository forks
- 555
- 7-day trend score
- 44
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 24 May 2026, 6 months ago.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/vladmandic/sdnext/port-model)