-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Two issues are being fixed: - The default value of `-1`, intended to represent all arguments are qubits, does not actually work. Instead, it introduces a off by one error, cutting off one of the qubit values. - The abstract evaluation did not work with the default value, and instead assumed the value was always set manually. Credit to @positr0nium for unearthing this :) --------- Co-authored-by: Ali Asadi <10773383+maliasadi@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright 2024 Xanadu Quantum Technologies Inc. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Unit tests for the JAX primitives module.""" | ||
|
||
import pytest | ||
|
||
from catalyst.jax_primitives import AbstractQbit, qinst_p | ||
|
||
|
||
class TestQinstPrim: | ||
"""Test the quantum instruction primitive.""" | ||
|
||
def test_abstract_eval_no_len(self): | ||
"""Test that the number of qubits is properly deduced when not set automatically.""" | ||
|
||
qb0, qb1 = (AbstractQbit(),) * 2 | ||
result = qinst_p.abstract_eval(qb0, qb1, op="GarbageOp")[0] | ||
|
||
assert len(result) == 2 | ||
assert all(isinstance(r, AbstractQbit) for r in result) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main(["-x", __file__]) |