core-api
Use the DPM-Solver PyTorch and JAX single-file APIs directly: noise schedules, model wrappers, solver settings, inversion/noising helpers, and tiny validation checks.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- core-api
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Use the DPM-Solver PyTorch and JAX single-file APIs directly: noise schedules, model wrappers, solver settings, inversion/noising helpers, and tiny validation checks.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md5.2 KB
- 参考文档references/noise-schedules-and-wrappers.md3.7 KB
- 参考文档references/troubleshooting.md3.1 KB
- 脚本scripts/minimal_jax_sample.py1.5 KB
- 脚本scripts/minimal_torch_sample.py1.5 KB
03 SKILL.md 正文
Core API
Use this sub-skill when a user wants to copy DPM-Solver into custom diffusion code, wrap their own model, choose solver settings, debug API calls, or run a small backend smoke test without executing the repository's large examples.
When To Read
Read this sub-skill for tasks that mention:
NoiseScheduleVP,model_wrapper,DPM_Solver,sample,inverse, oradd_noise.- Discrete beta schedules,
alphas_cumprod, continuous VP SDE schedules, or log-SNR time steps. algorithm_type="dpmsolver"versus"dpmsolver++", JAXpredict_x0, solver order,skip_type,method,denoise_to_zero, or dynamic thresholding.- A custom PyTorch or JAX diffusion model that should sample in 10-25 function evaluations.
Workflow
- Choose the backend file:
- PyTorch: copy
../../scripts/dpm_solver_pytorch.py. - JAX: copy
../../scripts/dpm_solver_jax.py.
- PyTorch: copy
- Read
references/api-reference.mdfor exact signatures, backend differences, and minimal integration skeletons. - Read
../../references/solver-choice-guide.mdbefore recommending order/method/step settings. - Use
references/noise-schedules-and-wrappers.mdwhen converting a model's training-time labels or parameterization to the continuous-time noise prediction interface. - Run one bundled smoke script before deeper debugging:
- If the user needs DDPM, ScoreSDE, or Stable Diffusion commands, route to the corresponding sibling sub-skill instead of expanding this page.
Recommended Direct PyTorch Skeleton
import torch
from dpm_solver_pytorch import NoiseScheduleVP, model_wrapper, DPM_Solver
# `model(x, t_input, **kwargs)` must return the model's prediction.
noise_schedule = NoiseScheduleVP(schedule="discrete", betas=betas)
model_fn = model_wrapper(
model,
noise_schedule,
model_type="noise",
guidance_type="uncond",
model_kwargs=model_kwargs,
)
solver = DPM_Solver(model_fn, noise_schedule, algorithm_type="dpmsolver++")
sample = solver.sample(
x_T,
steps=20,
order=2,
skip_type="time_uniform",
method="multistep",
)
Recommended Direct JAX Skeleton
import jax.numpy as jnp
from dpm_solver_jax import NoiseScheduleVP, model_wrapper, DPM_Solver
noise_schedule = NoiseScheduleVP(schedule="linear", continuous_beta_0=0.1, continuous_beta_1=20.0)
model_fn = model_wrapper(model, noise_schedule, model_type="noise", guidance_type="uncond")
solver = DPM_Solver(model_fn, noise_schedule, predict_x0=False)
sample = solver.sample(x_T, steps=20, order=3, skip_type="time_uniform", method="singlestep")
Common Decisions
- Use
schedule="discrete"withbetasoralphas_cumprodwhen adapting a DDPM-style model trained on integer time labels. - Use
schedule="linear"for continuous VP SDE / ScoreSDE-like integration. - In PyTorch,
algorithm_type="dpmsolver++"is the DPM-Solver++ path; in JAX, usepredict_x0=Truefor the comparable data-prediction solver path. - Use order 2 for large guidance scales and order 3 for unconditional or lightly guided sampling.
- Use
return_intermediate=Trueonly in PyTorch and only for non-adaptive methods. - Use PyTorch
inverseandadd_noisefor inversion/editing workflows; the root JAX file does not expose equivalent public helpers.
Troubleshooting
Read references/troubleshooting.md for API
misuse, tensor shape, dynamic thresholding, JAX classifier-free guidance, and
schedule conversion failures. Read the root
../../references/troubleshooting.md
for install/backend/checkpoint issues shared with examples.
Boundaries
- Do not run the original repository examples from this sub-skill.
- Do not promise sample quality without a known-good high-step baseline and a matching noise schedule.
- Do not recommend JAX
model_type="score", classifier-free guidance, orthresholding=Truein the unpatched root JAX file without warning about the verified compatibility caveats. - Do not apply dynamic thresholding to latent-space Stable Diffusion latents.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).