Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qfactor state vector instantiation #139

Open
peachnuts opened this issue Mar 23, 2023 · 1 comment
Open

Qfactor state vector instantiation #139

peachnuts opened this issue Mar 23, 2023 · 1 comment
Labels
feature request New feature or request

Comments

@peachnuts
Copy link
Contributor

Example to reproduce the issue:

circuit = Circuit(2)
circuit.append_gate(VariableUnitaryGate(1), [0])
circuit.append_gate(VariableUnitaryGate(1), [1])
circuit.append_gate(VariableUnitaryGate(2), [0, 1])
state = StateVector(np.array([1, 0, 0, 0]))
circuit.instantiate(state)

Errors:

Traceback (most recent call last):
File "/bqskit/examples/instantiate2.py", line 39, in
circuit.instantiate(state)
File "/bqskit/bqskit/ir/circuit.py", line 2826, in instantiate
params_list = [
File "/bqskit/bqskit/ir/circuit.py", line 2827, in
instantiater.instantiate(self, target, start)
File "/bqskit/bqskit/ir/opt/instantiaters/qfactor.py", line 45, in instantiate
return QFactorInstantiatorNative.instantiate(self, circuit, target, x0)
TypeError: dimensionality mismatch:
from=1, to=2

Note: the bqskit version is 1.1.0a2.

@edyounis
Copy link
Member

Thanks for the bug report!

This is because Qfactor does not currently support state prep yet. When you use VariableUnitaryGates the instantiation pipeline will select Qfactor by default as the instantiater. We plan on adding support for state instantiation in Qfactor soon.

In the meantime, you can use differentiable gates, e.g. PauliGate rather than VariableUnitaryGates.

@edyounis edyounis changed the title Instantiation for state vector doesn't work Qfactor state vector instantiation Oct 15, 2023
@edyounis edyounis added the feature request New feature or request label Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants