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: Max Qubit number limit Deutsch-Josza #429

Closed
PetarJurcevic opened this issue Dec 12, 2023 · 2 comments
Closed

Bug: Max Qubit number limit Deutsch-Josza #429

PetarJurcevic opened this issue Dec 12, 2023 · 2 comments

Comments

@PetarJurcevic
Copy link

PetarJurcevic commented Dec 12, 2023

Running the current version Deutsch-Josza algorithm with >21Q gives an error

----> 1 cir = dj_benchmark.DeutschJozsa(22, 'constant_circuit')
      2 transpile(cir, basis_gates=['x', 'sx', 'rz', 'cx'], optimization_level=3).draw()

File c:\Users\2J7579897\Notebooks_general\QEDC-benchmark\QC-App-Oriented-Benchmarks\deutsch-jozsa/qiskit\dj_benchmark.py:93, in DeutschJozsa(num_qubits, type)
     91 # Add a constant or balanced oracle function
     92 if type == 0: Uf = constant_oracle(input_size, num_qubits)
---> 93 else: Uf = balanced_oracle(input_size, num_qubits)
     94 qc.append(Uf, qr)
     96 qc.barrier()

File c:\Users\2J7579897\Notebooks_general\QEDC-benchmark\QC-App-Oriented-Benchmarks\deutsch-jozsa/qiskit\dj_benchmark.py:54, in balanced_oracle(input_size, num_qubits)
     52 b_str = "10101010101010101010"              # permit input_string up to 20 chars
     53 for qubit in range(input_size):
---> 54     if b_str[qubit] == '1':
     55         qc.x(qubit)
     57 qc.barrier()

IndexError: string index out of range

Possible Fixes:

  • Expand bit string b_str in dj_benchmark.py by a few more characters
  • create a dynamic bit string b_str depending on qubit number/ max qubit number
@rtvuser1
Copy link
Collaborator

rtvuser1 commented Jan 2, 2024

This issue has been fixed.
We now create a dynamic bit string b_str depending on num_qubits

@rtvuser1
Copy link
Collaborator

rtvuser1 commented Jan 2, 2024

Closed.
This issue has been fixed.
We now create a dynamic bit string b_str depending on num_qubits.

@rtvuser1 rtvuser1 closed this as completed Jan 2, 2024
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