test(pytorch): cover QuantizedTensor view NotImplementedError#3257
test(pytorch): cover QuantizedTensor view NotImplementedError#3257andrewwhitecdw wants to merge 2 commits into
Conversation
Signed-off-by: Andrew White <andrewh@cdw.com>
for more information, see https://pre-commit.ci
Greptile SummaryThis PR adds a single unit test (
Confidence Score: 3/5The test will fail as-is on the current main branch because the companion f-string fix in #3256 has not yet landed. The Files Needing Attention: tests/pytorch/test_quantized_tensor.py — the Important Files Changed
Sequence DiagramsequenceDiagram
participant Test as test_view_not_implemented
participant QT as QuantizedTensor
participant Dispatch as __torch_dispatch__
Test->>QT: QuantizedTensor((128,128), bfloat16)
QT-->>Test: qt (base instance)
Test->>QT: qt.view(-1)
QT->>Dispatch: "func=aten.view.default"
Dispatch-->>Test: raise NotImplementedError("...")
Note over Test,Dispatch: match expects interpolated "QuantizedTensor class..."<br/>but current code raises literal "{cls.__name__} class..." (no f-prefix)
Reviews (2): Last reviewed commit: "[pre-commit.ci] auto fixes from pre-comm..." | Re-trigger Greptile |
| with pytest.raises( | ||
| NotImplementedError, match="QuantizedTensor class does not support tensor views" | ||
| ): |
There was a problem hiding this comment.
match pattern won't match current error message
quantized_tensor.py line 711 raises NotImplementedError("{cls.__name__} class does not support tensor views") — a plain string, not an f-string — so the actual exception message is the literal {cls.__name__} class does not support tensor views, not QuantizedTensor class does not support tensor views. The pytest.raises(match=...) call uses re.search, so it will fail to match and the test will fail on the current main branch. This test is only valid once PR #3256 (which adds the f prefix) is merged; the PR description acknowledges this dependency but it is worth ensuring #3256 lands before or together with this one.
Add a unit test for the previously uncovered error path in QuantizedTensor.torch_dispatch when .view() is called on the base QuantizedTensor class.
This complements the fix in #3256 by ensuring the NotImplementedError is raised with the correct, interpolated message.