Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

Fix post-merge test regressions

Josh Corbett2c3988ca3da2
diff --git a/docs/src/content/docs/configuration/low-vram-mode.mdx b/docs/src/content/docs/configuration/low-vram-mode.mdx
index f2b970eca6..f7f39435b3 100644
--- a/docs/src/content/docs/configuration/low-vram-mode.mdx
+++ b/docs/src/content/docs/configuration/low-vram-mode.mdx
@@ -178,7 +178,7 @@ This setting processes parts of the PiD pixel pathway in chunks and uses float32
`device_working_mem_gb` sets a floor for the reservation. To realize the full PiD savings at 1024px-2048px, lower that setting as needed for your GPU.
-It is disabled by default because it is **not output-preserving**: neither change is bit-exact, and the few-step sampler amplifies the difference into a slightly different image. The delta is small — around 43 dB PSNR, visually indistinguishable in side-by-side comparisons — but it is real, so the same seed and workflow will not reproduce an unoptimized decode exactly. Decoding speed is roughly unchanged: chunking costs about 4%, which the cheaper sampler math largely offsets.
+It is disabled by default because it is **not output-preserving**. The combined optimized path is not guaranteed to be bit-exact: chunking can change GPU kernel and reduction choices, while the float32 sampler differs from the default float64 path. The few-step sampler amplifies the difference into a slightly different image. The delta is small — around 43 dB PSNR, visually indistinguishable in side-by-side comparisons — but it is real, so the same seed and workflow will not reproduce an unoptimized decode exactly. Decoding speed is roughly unchanged: chunking costs about 4%, which the cheaper sampler math largely offsets.
When the setting is active, each decode logs the resolution, the patch-token count and whether chunking actually engaged — worth checking, since the option is server-wide and never recorded in image metadata. See [PiD Super-Resolution Decode](/features/pid-decode/) for supported models and usage.
diff --git a/docs/src/content/docs/features/pid-decode.mdx b/docs/src/content/docs/features/pid-decode.mdx
index 0192e96097..e50c3b2b8e 100644
--- a/docs/src/content/docs/features/pid-decode.mdx
+++ b/docs/src/content/docs/features/pid-decode.mdx
@@ -89,7 +89,7 @@ pid_memory_optimization: true
This setting applies to every supported PiD decoder. It reduces peak activation and sampler memory by processing parts of the pixel pathway in chunks and by running the sampler's intermediates in float32 instead of float64 — measured on an RTX 4090, a 2048px decode peaks at ~1.5 GB of activations instead of ~3.7 GB. Decoding speed is roughly unchanged.
-It is disabled by default because it **changes the decoded image**. Neither the chunked pathway nor the float32 sampler math is bit-exact with the default path, and the few-step sampler amplifies that into a small but real difference (~43 dB PSNR — visually indistinguishable, numerically not identical). A seed that reproduced an image with the setting off will not reproduce it exactly with the setting on, and because this is a server-wide `invokeai.yaml` option it is not recorded in image metadata — each decode logs that it ran optimized instead.
+It is disabled by default because it **changes the decoded image**. The combined optimized path is not guaranteed to be bit-exact with the default path: chunking can change GPU kernel and reduction choices, while the float32 sampler math differs from the default float64 path. The few-step sampler amplifies that into a small but real difference (~43 dB PSNR — visually indistinguishable, numerically not identical). A seed that reproduced an image with the setting off will not reproduce it exactly with the setting on, and because this is a server-wide `invokeai.yaml` option it is not recorded in image metadata — each decode logs that it ran optimized instead.
- **Turn off "Scale Before Processing"** on the Canvas when using PiD — PiD already decodes at 4×, so pre-scaling would inflate the work and is blocked.
- **Inpaint / Outpaint** are not supported with PiD yet; use text-to-image or image-to-image.
diff --git a/tests/app/services/session_processor/test_encoder_offload.py b/tests/app/services/session_processor/test_encoder_offload.py
index d9e582ab2b..e189aa2043 100644
--- a/tests/app/services/session_processor/test_encoder_offload.py
+++ b/tests/app/services/session_processor/test_encoder_offload.py
@@ -23,11 +23,16 @@ from invokeai.backend.util.devices import TorchDevice
@pytest.fixture(autouse=True)
def reset_state() -> Iterator[None]:
GENERATION_DEVICE_POOL.reset()
- try:
- yield
- finally:
- TorchDevice.clear_session_device()
- GENERATION_DEVICE_POOL.reset()
+ # These tests intentionally model a two-GPU pool on machines with any
+ # hardware topology. Keep the real pool/session-pin behavior under test,
+ # but do not let the runner switch torch to the fictional second device.
+ target = "invokeai.app.services.session_processor.session_processor_default._set_torch_current_device"
+ with patch(target):
+ try:
+ yield
+ finally:
+ TorchDevice.clear_session_device()
+ GENERATION_DEVICE_POOL.reset()
class _FakeInvocation:
diff --git a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
index 855dc25651..0c18ce3bdc 100644
--- a/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
+++ b/tests/app/services/shared/sqlite_migrator/migrations/test_migration_2026_08_06_add_project_boards.py
@@ -535,8 +535,9 @@ def test_it_runs_once_through_the_real_migrator_and_is_not_reapplied(tmp_path: P
before = SqliteMigrator(db=db)
for migration in all_migrations:
- if migration.id != MIGRATION_ID:
- before.register_migration(migration)
+ if migration.id == MIGRATION_ID:
+ break
+ before.register_migration(migration)
before.run_migrations()
cursor = db._conn.cursor()
diff --git a/tests/app/services/users/test_token_service.py b/tests/app/services/users/test_token_service.py
index 3dec800082..e9d61bc925 100644
--- a/tests/app/services/users/test_token_service.py
+++ b/tests/app/services/users/test_token_service.py
@@ -2,7 +2,14 @@
from datetime import timedelta
-from invokeai.app.services.auth.token_service import TokenData, create_access_token, verify_token
+import pytest
+
+from invokeai.app.services.auth.token_service import TokenData, create_access_token, set_jwt_secret, verify_token
+
+
[email protected](scope="module", autouse=True)
+def setup_jwt_secret() -> None:
+ set_jwt_secret("test-secret-key-for-unit-tests-only-do-not-use-in-production")
def test_create_access_token():
diff --git a/tests/backend/pid/test_pid_chunked_equivalence.py b/tests/backend/pid/test_pid_chunked_equivalence.py
index de2c08f14d..ef1a821fb4 100644
--- a/tests/backend/pid/test_pid_chunked_equivalence.py
+++ b/tests/backend/pid/test_pid_chunked_equivalence.py
@@ -4,8 +4,8 @@
CPU. That is a real assertion about the *math* - and it holds exactly - but it cannot see the shape
of the problem the setting actually has, because the shipped path runs on CUDA under bf16 autocast
(`PiDDecoder.decode` sets `autocast_dtype = torch.bfloat16` for every CUDA decode) with `BL` in the
-thousands rather than 8. There, splitting a GEMM into 1024-row slices makes cuBLAS pick different
-kernels and reduction orders, and the results differ by bf16 ULPs.
+thousands rather than 8. There, splitting a GEMM into 1024-row slices can make cuBLAS pick different
+kernels and reduction orders, so the results may differ by bf16 ULPs.
Measured on an RTX 4090 (torch 2.7.1+cu128), production `PiTBlock` dimensions:
@@ -21,9 +21,10 @@ The CPU column is *not* a portable guarantee, and this module originally claimed
`torch.equal` there passed on x86-64/MKL and failed on macOS/Accelerate in CI: splitting a GEMM along
its row dimension can select a micro-kernel with different K-blocking, so bit-exactness is a property
of the BLAS, not of the chunking. What is portable is that chunking only *reassociates* work, so the
-contract here is a distance bound on both paths - tight and scaled to the signal on fp32, wider and
-absolute under bf16 autocast (relative tolerances are useless there: activations pass through zero,
-so `max|rel|` reaches 1e3 on elements whose absolute error is a single bf16 ULP).
+contract here is a distance bound on both paths that also permits exact equality - tight and scaled
+to the signal on fp32, wider and absolute under bf16 autocast (relative tolerances are useless there:
+activations pass through zero, so `max|rel|` reaches 1e3 on elements whose absolute error is a single
+bf16 ULP).
"""
from collections.abc import Iterator
@@ -151,13 +152,13 @@ def test_chunking_matches_the_unchunked_path_on_cpu(image_px: int, batch_size: i
)
[email protected](not torch.cuda.is_available(), reason="the divergence only exists on the accelerated path")
[email protected](not torch.cuda.is_available(), reason="the accelerated-path contract requires CUDA")
@pytest.mark.parametrize(("image_px", "batch_size"), [(1024, 1), (2048, 1), (2048, 2)])
def test_chunking_stays_within_the_documented_tolerance_on_cuda_bf16(image_px: int, batch_size: int) -> None:
"""The shipped path: CUDA + bf16 autocast, BL well above the chunk size.
- Asserting equality here would be asserting something false. Asserting a bound is the honest
- contract, and it is what the docs promise users who enable the setting.
+ Equality depends on the GPU and kernels selected, so a distance bound is the portable contract
+ promised to users who enable the setting. Exact equality is also a valid result.
"""
block = _build_block("cuda")
x, s_cond = _inputs(image_px, batch_size, "cuda")
@@ -180,9 +181,6 @@ def test_chunking_stays_within_the_documented_tolerance_on_cuda_bf16(image_px: i
difference = (chunked.float() - unchunked.float()).abs()
assert difference.max().item() <= _BF16_ABSOLUTE_TOLERANCE
assert difference.mean().item() <= _BF16_MEAN_ABSOLUTE_TOLERANCE
- # And it is genuinely not exact - if this ever starts failing, the divergence is gone and the
- # tolerance contract (plus the "output changes" wording in the docs) should be revisited.
- assert difference.max().item() > 0.0
def test_discriminator_feature_extraction_never_reaches_the_chunked_pixel_blocks() -> None: