From 6398fbc391519ce033d97d23925fd13ec4ed85a7 Mon Sep 17 00:00:00 2001 From: Hengyue-Bi <616730841@qq.com> Date: Tue, 15 Jul 2025 02:54:38 +0800 Subject: [PATCH 1/3] Fix: Align VAE processing in ControlNet SD3 training with inference (#11909) Fix: Apply vae_shift_factor in ControlNet SD3 training --- examples/controlnet/train_controlnet_sd3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/controlnet/train_controlnet_sd3.py b/examples/controlnet/train_controlnet_sd3.py index 746063f9d6..592e5d7766 100644 --- a/examples/controlnet/train_controlnet_sd3.py +++ b/examples/controlnet/train_controlnet_sd3.py @@ -1330,7 +1330,7 @@ def main(args): # controlnet(s) inference controlnet_image = batch["conditioning_pixel_values"].to(dtype=weight_dtype) controlnet_image = vae.encode(controlnet_image).latent_dist.sample() - controlnet_image = controlnet_image * vae.config.scaling_factor + controlnet_image = (controlnet_image - vae.config.shift_factor) * vae.config.scaling_factor control_block_res_samples = controlnet( hidden_states=noisy_model_input, From 48a551251d149ad92a959ed8fb41640ff3703a84 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 09:15:57 +0530 Subject: [PATCH 2/3] Bump aiohttp from 3.10.10 to 3.12.14 in /examples/server (#11924) Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.10.10 to 3.12.14. - [Release notes](https://github.com/aio-libs/aiohttp/releases) - [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst) - [Commits](https://github.com/aio-libs/aiohttp/compare/v3.10.10...v3.12.14) --- updated-dependencies: - dependency-name: aiohttp dependency-version: 3.12.14 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/server/requirements.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/server/requirements.txt b/examples/server/requirements.txt index 5cc6e2303b..b91a8861a0 100644 --- a/examples/server/requirements.txt +++ b/examples/server/requirements.txt @@ -1,10 +1,10 @@ # This file was autogenerated by uv via the following command: # uv pip compile requirements.in -o requirements.txt -aiohappyeyeballs==2.4.3 +aiohappyeyeballs==2.6.1 # via aiohttp -aiohttp==3.10.10 +aiohttp==3.12.14 # via -r requirements.in -aiosignal==1.3.1 +aiosignal==1.4.0 # via aiohttp annotated-types==0.7.0 # via pydantic @@ -29,7 +29,6 @@ filelock==3.16.1 # huggingface-hub # torch # transformers - # triton frozenlist==1.5.0 # via # aiohttp @@ -111,7 +110,9 @@ prometheus-client==0.21.0 prometheus-fastapi-instrumentator==7.0.0 # via -r requirements.in propcache==0.2.0 - # via yarl + # via + # aiohttp + # yarl py-consul==1.5.3 # via -r requirements.in pydantic==2.9.2 @@ -155,7 +156,9 @@ triton==3.3.0 # via torch typing-extensions==4.12.2 # via + # aiosignal # anyio + # exceptiongroup # fastapi # huggingface-hub # multidict @@ -168,5 +171,5 @@ urllib3==2.5.0 # via requests uvicorn==0.32.0 # via -r requirements.in -yarl==1.16.0 +yarl==1.18.3 # via aiohttp From 06fd4277973d9ca14f7cdf364943c28de95e5510 Mon Sep 17 00:00:00 2001 From: Aryan Date: Tue, 15 Jul 2025 10:47:41 +0530 Subject: [PATCH 3/3] [tests] Improve Flux tests (#11919) update --- tests/pipelines/flux/test_pipeline_flux.py | 107 ++++++--------------- 1 file changed, 30 insertions(+), 77 deletions(-) diff --git a/tests/pipelines/flux/test_pipeline_flux.py b/tests/pipelines/flux/test_pipeline_flux.py index 0df0e028ff..a848ec615e 100644 --- a/tests/pipelines/flux/test_pipeline_flux.py +++ b/tests/pipelines/flux/test_pipeline_flux.py @@ -155,7 +155,7 @@ class FluxPipelineFastTests( # Outputs should be different here # For some reasons, they don't show large differences - assert max_diff > 1e-6 + self.assertGreater(max_diff, 1e-6, "Outputs should be different for different prompts.") def test_fused_qkv_projections(self): device = "cpu" # ensure determinism for the device-dependent torch.Generator @@ -187,14 +187,17 @@ class FluxPipelineFastTests( image = pipe(**inputs).images image_slice_disabled = image[0, -3:, -3:, -1] - assert np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), ( - "Fusion of QKV projections shouldn't affect the outputs." + self.assertTrue( + np.allclose(original_image_slice, image_slice_fused, atol=1e-3, rtol=1e-3), + ("Fusion of QKV projections shouldn't affect the outputs."), ) - assert np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), ( - "Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled." + self.assertTrue( + np.allclose(image_slice_fused, image_slice_disabled, atol=1e-3, rtol=1e-3), + ("Outputs, with QKV projection fusion enabled, shouldn't change when fused QKV projections are disabled."), ) - assert np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), ( - "Original outputs should match when fused QKV projections are disabled." + self.assertTrue( + np.allclose(original_image_slice, image_slice_disabled, atol=1e-2, rtol=1e-2), + ("Original outputs should match when fused QKV projections are disabled."), ) def test_flux_image_output_shape(self): @@ -209,7 +212,11 @@ class FluxPipelineFastTests( inputs.update({"height": height, "width": width}) image = pipe(**inputs).images[0] output_height, output_width, _ = image.shape - assert (output_height, output_width) == (expected_height, expected_width) + self.assertEqual( + (output_height, output_width), + (expected_height, expected_width), + f"Output shape {image.shape} does not match expected shape {(expected_height, expected_width)}", + ) def test_flux_true_cfg(self): pipe = self.pipeline_class(**self.get_dummy_components()).to(torch_device) @@ -220,7 +227,9 @@ class FluxPipelineFastTests( inputs["negative_prompt"] = "bad quality" inputs["true_cfg_scale"] = 2.0 true_cfg_out = pipe(**inputs, generator=torch.manual_seed(0)).images[0] - assert not np.allclose(no_true_cfg_out, true_cfg_out) + self.assertFalse( + np.allclose(no_true_cfg_out, true_cfg_out), "Outputs should be different when true_cfg_scale is set." + ) @nightly @@ -269,45 +278,17 @@ class FluxPipelineSlowTests(unittest.TestCase): image = pipe(**inputs).images[0] image_slice = image[0, :10, :10] + # fmt: off expected_slice = np.array( - [ - 0.3242, - 0.3203, - 0.3164, - 0.3164, - 0.3125, - 0.3125, - 0.3281, - 0.3242, - 0.3203, - 0.3301, - 0.3262, - 0.3242, - 0.3281, - 0.3242, - 0.3203, - 0.3262, - 0.3262, - 0.3164, - 0.3262, - 0.3281, - 0.3184, - 0.3281, - 0.3281, - 0.3203, - 0.3281, - 0.3281, - 0.3164, - 0.3320, - 0.3320, - 0.3203, - ], + [0.3242, 0.3203, 0.3164, 0.3164, 0.3125, 0.3125, 0.3281, 0.3242, 0.3203, 0.3301, 0.3262, 0.3242, 0.3281, 0.3242, 0.3203, 0.3262, 0.3262, 0.3164, 0.3262, 0.3281, 0.3184, 0.3281, 0.3281, 0.3203, 0.3281, 0.3281, 0.3164, 0.3320, 0.3320, 0.3203], dtype=np.float32, ) + # fmt: on max_diff = numpy_cosine_similarity_distance(expected_slice.flatten(), image_slice.flatten()) - - assert max_diff < 1e-4 + self.assertLess( + max_diff, 1e-4, f"Image slice is different from expected slice: {image_slice} != {expected_slice}" + ) @slow @@ -377,42 +358,14 @@ class FluxIPAdapterPipelineSlowTests(unittest.TestCase): image = pipe(**inputs).images[0] image_slice = image[0, :10, :10] + # fmt: off expected_slice = np.array( - [ - 0.1855, - 0.1680, - 0.1406, - 0.1953, - 0.1699, - 0.1465, - 0.2012, - 0.1738, - 0.1484, - 0.2051, - 0.1797, - 0.1523, - 0.2012, - 0.1719, - 0.1445, - 0.2070, - 0.1777, - 0.1465, - 0.2090, - 0.1836, - 0.1484, - 0.2129, - 0.1875, - 0.1523, - 0.2090, - 0.1816, - 0.1484, - 0.2110, - 0.1836, - 0.1543, - ], + [0.1855, 0.1680, 0.1406, 0.1953, 0.1699, 0.1465, 0.2012, 0.1738, 0.1484, 0.2051, 0.1797, 0.1523, 0.2012, 0.1719, 0.1445, 0.2070, 0.1777, 0.1465, 0.2090, 0.1836, 0.1484, 0.2129, 0.1875, 0.1523, 0.2090, 0.1816, 0.1484, 0.2110, 0.1836, 0.1543], dtype=np.float32, ) + # fmt: on max_diff = numpy_cosine_similarity_distance(expected_slice.flatten(), image_slice.flatten()) - - assert max_diff < 1e-4, f"{image_slice} != {expected_slice}" + self.assertLess( + max_diff, 1e-4, f"Image slice is different from expected slice: {image_slice} != {expected_slice}" + )