unsloth/studio/backend/core/inference
Daniel Han bce892a7f7 Studio diffusion: ControlNet for the Images workflow (diffusers)
Add ControlNet conditioning, the #2 most-used diffusion workflow after
LoRA, on the diffusers backend for the families with ControlNet pipelines
(FLUX.1 and Qwen-Image), with Union models as the default picks.

Backend
- New core/inference/diffusion_controlnet.py: family-gated discovery
  (curated Union models + local dirs + bare owner/name repos), resolution
  to a loadable repo/dir, control-image preprocessing (passthrough +
  a dependency-free canny edge map), and a supports_controlnet gate.
- diffusion.py: a ControlNet manager parallel to the LoRA one. Loads the
  (small) ControlNet model once via from_pretrained (cached by id) and
  builds the family's ControlNet pipeline via Pipeline.from_pipe(base,
  controlnet=model), reusing the resident base modules at their loaded
  dtype (no reload, no recast). Passes the control image + conditioning
  scale + guidance start/end at generate time; cleared on unload.
- Families: FLUX.1 -> FluxControlNetPipeline/Model, Qwen-Image ->
  QwenImageControlNetPipeline/Model. Others declare none (gated off).
- Gated off for the native engine, GGUF-via-diffusers, and torchao
  fp8/int8 dense (same rule as LoRA). v1 conditions txt2img only.
- Request contract: optional controlnet on DiffusionGenerateRequest;
  supports_controlnet in status; the choice persisted in gallery meta.
- New GET /api/models/diffusion-controlnets for the picker.

Frontend
- A ControlNet control in the Images rail (model select + control-image
  upload + control-type select + strength slider), gated by the loaded
  model's supports_controlnet + family, shown for text-to-image.

Tests
- New test_diffusion_controlnet.py (10): discovery/resolve/preprocess/gate
  helpers, request validation, family wiring, and the diffusers pipe
  manager (loads once, caches, from_pipe with controlnet, rejects
  unsupported families).
2026-07-01 05:06:02 +00:00
..
__init__.py Studio: make code comments and docstrings more succinct (#6029) 2026-06-08 23:07:28 -07:00
_html_to_md.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
anthropic_compat.py Studio: improve OpenAI- and Anthropic-compatible API spec compliance (#6010) 2026-06-09 17:13:25 +02:00
api_monitor.py Studio: trim serving-log noise and surface llama-server engine stats (#6377) 2026-06-17 05:37:57 -07:00
audio_codecs.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
chat_template_helpers.py Studio: make code comments and docstrings more succinct (#6029) 2026-06-08 23:07:28 -07:00
chat_templates.py Studio: bundle Gemma 4 chat templates (E2B/E4B + larger) and auto-apply to unsloth/gemma-4-*-GGUF (#6245) 2026-06-12 05:49:39 -07:00
defaults.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
diffusion.py Studio diffusion: ControlNet for the Images workflow (diffusers) 2026-07-01 05:06:02 +00:00
diffusion_arch_patches.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_attention.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 12:03:36 +00:00
diffusion_cache.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 12:36:49 +00:00
diffusion_compile_cache.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_controlnet.py Studio diffusion: ControlNet for the Images workflow (diffusers) 2026-07-01 05:06:02 +00:00
diffusion_device.py Studio diffusion (Phase 16) review fixes: native engine robustness 2026-06-29 05:19:25 +00:00
diffusion_eager_patches.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_engine_router.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_families.py Studio diffusion: ControlNet for the Images workflow (diffusers) 2026-07-01 05:06:02 +00:00
diffusion_gguf_compile.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_lora.py Studio diffusion: LoRA adapters for the Images workflow 2026-07-01 04:00:34 +00:00
diffusion_memory.py Studio diffusion: image workflows (safetensors, image-conditioned, editing) + Images UI 2026-07-01 01:23:52 +00:00
diffusion_patch_backend.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-07-01 01:25:36 +00:00
diffusion_precision.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-25 14:43:45 +00:00
diffusion_prequant.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 11:24:35 +00:00
diffusion_speed.py Studio diffusion: eager patches + torch.compile cache speed phase 2026-07-01 01:23:43 +00:00
diffusion_transformer_quant.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-27 07:33:16 +00:00
external_provider.py Studio: ignore unsupported env proxy during Studio startup (#6102) 2026-06-11 05:13:27 -07:00
gpu_arbiter.py Studio diffusion (Phase 16): route no-GPU loads to the native sd.cpp engine 2026-06-28 04:30:21 +00:00
image_gallery.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-25 03:21:55 +00:00
inference.py fix(studio): handle multimodal list content in inference text paths (#4383) (#6480) 2026-06-23 01:26:11 -07:00
key_exchange.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
llama_cpp.py Studio: honor stream=false on the GGUF agentic tool path (#6570) (#6618) 2026-06-24 15:37:08 +01:00
llama_http.py Studio: serialize non-streaming responses once and pool the proxy client (#6393) 2026-06-17 22:38:02 -07:00
llama_server_args.py studio: deterministic VRAM auto-fit for GGUF (MTP reserve, compute buffer, total-based budget) (#6312) 2026-06-17 03:10:22 -07:00
llama_stats.py Studio: trim serving-log noise and surface llama-server engine stats (#6377) 2026-06-17 05:37:57 -07:00
mcp_client.py Studio: enable stdio MCP servers on a loopback bind (#6295) 2026-06-15 03:02:32 +01:00
mcp_config_import.py studio: show MCP "Import config" on the add-server form (#6030) 2026-06-11 16:17:22 +01:00
message_content.py fix(studio): handle multimodal list content in inference text paths (#4383) (#6480) 2026-06-23 01:26:11 -07:00
mlx_inference.py Expose runtime context length for hub models (#6154) 2026-06-11 22:13:53 +03:00
orchestrator.py Studio: persistent per-user trust_remote_code approval cache (#6551) 2026-06-22 05:12:49 -07:00
pricing.py Reduce and tighten code comments and docstrings repo-wide (#6095) 2026-06-08 23:09:51 -07:00
providers.py Studio: Add custom provider option to Connections (#6112) 2026-06-12 13:09:35 +02:00
runtime_context.py Expose runtime context length for hub models (#6154) 2026-06-11 22:13:53 +03:00
safetensors_agentic.py Studio: show tool-call progress for large GGUF tool arguments (#6484) 2026-06-22 05:50:10 -07:00
sd_cpp_args.py [pre-commit.ci] auto fixes from pre-commit.com hooks 2026-06-26 03:20:02 +00:00
sd_cpp_backend.py Studio diffusion: ControlNet for the Images workflow (diffusers) 2026-07-01 05:06:02 +00:00
sd_cpp_engine.py Phase 16 review fixes: engine-switch unload, sd.cpp error mapping, per-image seeds, Qwen sampler 2026-06-28 05:44:22 +00:00
tensor_fallback.py studio: deterministic VRAM auto-fit for GGUF (MTP reserve, compute buffer, total-based budget) (#6312) 2026-06-17 03:10:22 -07:00
tool_call_parser.py Fix Gemma 4 GGUF OpenAI API streams (#6476) 2026-06-23 06:13:56 -07:00
tool_loop_controller.py Studio: clean-room compact RAG (knowledge bases, hybrid search, fast indexing) (#5910) 2026-06-09 21:17:04 -07:00
tools.py Use UTF-8 for Python code-execution subprocess I/O (#6489 class) (#6548) 2026-06-22 09:06:03 -07:00
worker.py Generalize transformers tier selection by probing AutoConfig (#6550) 2026-06-22 08:20:06 -07:00