Skip to content

Commit 775ceb0

Browse files
jiqing-fengDN6
authored andcommitted
Add XPU expected slice for SlowBnb4BitFluxControlWithLoraTests::test_lora_loading (#14202)
* fix xpu slice Signed-off-by: jiqing-feng <jiqing.feng@intel.com> * complete comment Signed-off-by: jiqing-feng <jiqing.feng@intel.com> --------- Signed-off-by: jiqing-feng <jiqing.feng@intel.com>
1 parent 0c0a42b commit 775ceb0

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/quantization/bnb/test_mixed_int8.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
from ...testing_utils import (
3636
CaptureLogger,
37+
Expectations,
3738
backend_empty_cache,
3839
is_bitsandbytes_available,
3940
is_torch_available,
@@ -693,7 +694,16 @@ def test_lora_loading(self):
693694
generator=torch.Generator().manual_seed(42),
694695
).images
695696
out_slice = output[0, -3:, -3:, -1].flatten()
696-
expected_slice = np.array([0.2029, 0.2136, 0.2268, 0.1921, 0.1997, 0.2185, 0.2021, 0.2183, 0.2292])
697+
# Hardware-dependent: the Control LoRA dequantizes and expands `x_embedder`, and the error
698+
# accumulates over the 8 denoising steps enough that even different CUDA GPUs disagree, so
699+
# reference slices are stored per accelerator backend.
700+
expected_slices = Expectations(
701+
{
702+
(None, None): np.array([0.2029, 0.2136, 0.2268, 0.1921, 0.1997, 0.2185, 0.2021, 0.2183, 0.2292]),
703+
("xpu", 5): np.array([0.0955, 0.1223, 0.1509, 0.0872, 0.1155, 0.1890, 0.0754, 0.1028, 0.2178]),
704+
}
705+
)
706+
expected_slice = expected_slices.get_expectation()
697707

698708
max_diff = numpy_cosine_similarity_distance(expected_slice, out_slice)
699709
assert max_diff < 1e-3, f"{out_slice=} != {expected_slice=}"

0 commit comments

Comments
 (0)