You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Coordination: #15450 (opened just before this PR, waiting for maintainer feedback)
Adds Kandinsky ImageSR 2.0, an image
super-resolution model from Kandinsky Lab. A single text-free Kandinsky 5 transformer enhances an image at its
original resolution (×1) or upscales it ×2 or ×4 in one flow step, with calibrated creativity levels 0–8.
New public API:
KandinskyImageSRTransformer3DModel
KandinskyImageSRPipeline and KandinskyImageSRPipelineOutput
single-file loading of the released GGUF Q8_0 transformer through the existing GGUFQuantizationConfig
Baked transformer. The model is conditioned on empty text only. The time embedding, the per-block
modulation and the zero-text cross-attention contribution are stored as tables with one row per supported
timestep (26 values in baked_timesteps). There are no text encoders, text blocks or cross-attention layers.
Only the baked timesteps are valid. The pipeline validates one_step_t; the model selects its table row with
an argmin instead of raising, so forward stays free of host syncs and compiles with fullgraph=True.
One flow step through the scheduler. The pipeline uses FlowMatchEulerDiscreteScheduler(shift=1.0) with sigmas=[t], which gives exactly x_0 = x_t - t * v. set_timesteps is called once per tile.
Deterministic pipeline. There is no noise and no generator argument. PipelineTesterMixin always passes
a generator to its two batch tests, so the pipeline test file overrides them with generator-free versions.
Open questions:
Should the creativity presets stay a module-level constant in the pipeline, or move into a config?
Should GGUF quantization tests (GGUFTesterMixin) be added here or in a follow-up PR?
test_compile_works_with_aot needs the CUDA toolkit headers to compile AOTInductor's C++ wrapper, and the test
machine only has the CUDA runtime (fatal error: crt/host_defines.h: No such file or directory). The same test
fails the same way for Flux there.
make quality, utils/check_copies.py, utils/check_dummies.py, utils/check_forward_call_docstrings.py and utils/check_return_annotations.py pass.
Self-review notes: see the comment below.
Before submitting
Did you use an AI agent (Claude Code, Codex, Cursor, etc.) to help with this PR? If so:
Commit Add Kandinsky ImageSR 2.0 against upstream/main, reviewed with .ai/skills/self-review and .ai/references/review-rules.md (plus code_style.md, models.md, pipelines.md, testing.md, pitfalls.md).
I read the whole diff, including the docs and tests, and compared it with the Kandinsky 6 VSR integration.
Blocking issues
None.
Non-blocking issues (left for review)
visual_modulation_table loads in the requested dtype, not float32.transformer_kandinsky_imagesr.py:304. _keep_in_fp32_modules matches whole dotted name segments, so "modulation" keeps only out_layer.modulation
in float32. This is intended: the released checkpoint stores this table in BF16 (it was baked in BF16), while time_embed_table and xattn_bias_table are F32 and stay F32.
test_compile_works_with_aot could not pass on my GPU machine. AOTInductor compiles C++ against the CUDA
toolkit headers, and the host has only the CUDA runtime (fatal error: crt/host_defines.h: No such file or directory). The same test fails the same way for Flux on that machine. Every other compile and offload tester
passes on H100.
Dead code
None found. I traced __call__ into forward and every block. Every config argument is used, and every forward/__call__ parameter is passed or documented. All classes and helpers (_tile_positions, _boundary_aware_window, ROPE_MAX_POSITIONS, DEFAULT_CREATIVITY) are reached. set_timesteps is called once per
tile on purpose, because the scheduler's step index advances after every step.
Checks run
Shared files contain only additions.git diff --numstat upstream/main...HEAD shows 0 deletions in all 16
files, including _toctree.yml, the __init__.py files, single_file_model.py and dummy_pt_objects.py.
Released config matches the model. All 10 __init__ arguments appear in kandinskylab/Kandinsky-ImageSR-2.0-Diffusers/transformer/config.json, with no extra keys. The model built on the
meta device from that config has 707/707 state-dict keys with matching shapes against the safetensors header.
GGUF doc example.from_single_file(config=..., subfolder="transformer", GGUFQuantizationConfig(bf16)) loads
the released Kandinsky-ImageSR-2.0-x1-Q8_0.gguf, the table dtypes match the checkpoint, and KandinskyImageSRPipeline.from_pretrained(..., transformer=transformer) loads the VAE and scheduler with tile_size == 1024. On H100 the GGUF pipeline upscales a 360×360 image ×4 at 48.1 dB PSNR against BF16.
Behaviour. A tiny model compiles with torch.compile(fullgraph=True) and matches eager output
(max diff 3.6e-7). With the released scheduler config, set_timesteps(sigmas=[t]) followed by step gives lq - t * v for t = 0.005, 0.244 and 0.38. All 27 creativity presets are rows in baked_timesteps.
make quality: All checks passed! / 2284 files already formatted; doc-builder style, check_doc_toc.py and check_ai.py pass.
python utils/check_copies.py, python utils/check_dummies.py: no output, exit 0.
python utils/check_forward_call_docstrings.py: All forward/__call__ arguments are documented.
python utils/check_return_annotations.py: All forward/__call__ methods have return type annotations.
CPU (macOS): DIFFUSERS_TEST_DEVICE=cpu python -m pytest tests/models/transformers/test_models_transformer_kandinsky_imagesr.py tests/pipelines/kandinsky_imagesr -q
→ 52 passed, 50 skipped, 7 warnings. The skips need an accelerator, or cover features this pipeline does not
have (callback_on_step_end, num_images_per_prompt, guidance_scale, encode_prompt, _optional_components)
and QKV fusion.
GPU (H100 80GB, torch 2.13.0+cu129): python -m pytest tests/models/transformers/test_models_transformer_kandinsky_imagesr.py tests/pipelines/kandinsky_imagesr -q
→ 1 failed, 91 passed, 10 skipped. The failure is test_compile_works_with_aot (non-blocking 2). The skips are
the features listed above and one multi-GPU test.
Verdict
READY. There are no blocking issues or dead code, the released config and checkpoint match the model, and both
documented loading paths work.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Coordination: #15450 (opened just before this PR, waiting for maintainer feedback)
Adds Kandinsky ImageSR 2.0, an image
super-resolution model from Kandinsky Lab. A single text-free Kandinsky 5 transformer enhances an image at its
original resolution (×1) or upscales it ×2 or ×4 in one flow step, with calibrated creativity levels 0–8.
New public API:
KandinskyImageSRTransformer3DModelKandinskyImageSRPipelineandKandinskyImageSRPipelineOutputGGUFQuantizationConfigCheckpoints:
kandinskylab/Kandinsky-ImageSR-2.0-Diffuserskandinskylab/Kandinsky-ImageSR-2.0-GGUFDesign notes
Things that differ from other pipelines:
modulation and the zero-text cross-attention contribution are stored as tables with one row per supported
timestep (26 values in
baked_timesteps). There are no text encoders, text blocks or cross-attention layers.Only the baked timesteps are valid. The pipeline validates
one_step_t; the model selects its table row withan
argmininstead of raising, soforwardstays free of host syncs and compiles withfullgraph=True.FlowMatchEulerDiscreteScheduler(shift=1.0)withsigmas=[t], which gives exactlyx_0 = x_t - t * v.set_timestepsis called once per tile.generatorargument.PipelineTesterMixinalways passesa
generatorto its two batch tests, so the pipeline test file overrides them with generator-free versions.Open questions:
GGUFTesterMixin) be added here or in a follow-up PR?Tests
CPU (macOS):
DIFFUSERS_TEST_DEVICE=cpu python -m pytest tests/models/transformers/test_models_transformer_kandinsky_imagesr.py tests/pipelines/kandinsky_imagesr -q # 52 passed, 50 skipped, 7 warningsGPU (H100 80GB, torch 2.13.0+cu129):
test_compile_works_with_aotneeds the CUDA toolkit headers to compile AOTInductor's C++ wrapper, and the testmachine only has the CUDA runtime (
fatal error: crt/host_defines.h: No such file or directory). The same testfails the same way for Flux there.
make quality,utils/check_copies.py,utils/check_dummies.py,utils/check_forward_call_docstrings.pyandutils/check_return_annotations.pypass.Self-review notes: see the comment below.
Before submitting
self-reviewskill on the diff?Who can review?
Pipelines and models:
yiyixuxusayakpaul