Fix device mismatch in test_copy_cache_modifiers assertions #271
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.
The
test_copy_cache_modifierstest was comparing GPU tensors with CPU tensors, causingtorch.allclose()to fail with a device mismatch error across all 30 parameterized test cases.Changes
device=results.deviceparameter totorch.full()call in the assertion to ensure comparison tensors are created on the same device as the results tensorOriginal prompt
This section details on the original issue you should resolve
<issue_title>Fix cache modifiers unittests bug</issue_title>
<issue_description> FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-None] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-.wb] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-.cg] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-.cs] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[None-.wt] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-None] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-.wb] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-.cg] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-.cs] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[-.wt] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-None] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-.wb] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-.cg] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-.cs] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.ca-.wt] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
FAILED tests/unittests/test_copy_cache_modifiers.py::test_copy_cache_modifiers[.cg-None] - RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!
assert torch.allclose(results[i], torch.full((BLOCK_SIZE,), expected_value, dtype=torch.float32)), (
E RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cpu!
______________________ test_copy_cache_modifiers[.cg-.cs] ______________________
tests/unittests/test_copy_cache_modifiers.py:102: in test_copy_cache_modifiers
assert torch.allclose(results[i], torch.full((BLOCK_SIZE,), expected_value, dtype=torch.float32)), (
E RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cpu!
______________________ test_copy_cache_modifiers[.cg-.wt] ______________________
tests/unittests/test_copy_cache_modifiers.py:102: in test_copy_cache_modifiers
assert torch.allclose(results[i], torch.full((BLOCK_SIZE,), expected_value, dtype=torch.float32)), (
E RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cpu!
_____________________ test_copy_cache_modifiers[...
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.