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

[BUG] F.2 code of QFT #63

Open
1 task done
maplexgitx0302 opened this issue Feb 10, 2024 · 1 comment
Open
1 task done

[BUG] F.2 code of QFT #63

maplexgitx0302 opened this issue Feb 10, 2024 · 1 comment

Comments

@maplexgitx0302
Copy link

Node number

Codercise F.2.1, Codercise F.2.3

Expected behavior

The code in F.2.1 and F.2.3

bits = [int(x) for x in np.binary_repr(basis_id, width=dev.num_wires)]

seems not work. This can be simply fixed by

bits = [int(x) for x in np.binary_repr(basis_id, width=num_wires)]

Another issue is in the right hand side panel, there is a figure
f2-qft2-no-swap-hand

I think the green and purple initial states (the $|x_0\rangle$ and the $|x_1\rangle$) should also be swapped in the figure. To make the circuit work in this figure, one can test the code by adding additional line

bits = [int(x) for x in np.binary_repr(basis_id, width=num_wires)]

# add this line to make initial state swapped
bits = bits[::-1]

qml.BasisStatePreparation(bits, wires=[0, 1])

Actual behavior

The error pops up when using dev.num_wires

Error: 'DefaultQubit' object has no attribute 'num_wires'

Additional information

No response

Source code

No response

Tracebacks

No response

Check other issues

  • I have searched existing GitHub issues to make sure the issue does not already exist.
@alvaro-at-xanadu
Copy link
Contributor

alvaro-at-xanadu commented Feb 12, 2024

Hello @maplexgitx0302
Thank you so much for reporting this. Strange that this passed the automatic tests 🤔!

This happens because in the newer versions of PennyLane, default.qubit changes the number of wires dynamically according to the paired circuit. It makes sense that it no longer has the num_wires attribute.

We'll push a fix and update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants