Code Monkey home page Code Monkey logo

quantumproject's People

Watchers

 avatar  avatar

quantumproject's Issues

BUG: redundant identical `measure` gate

Environment

  • qiskit.version: 0.22.0
  • Python version: 3.8.0
  • Operating system: Ubuntu 18.04

What is happening?

The file InefficientNot.py has two consecutive measurements on the same qubit and bit, making the second redundant.

How can we reproduce the issue?

To reproduce the problem I visualized the circuit:

from qiskit import QuantumCircuit
def inefficientNOT(inefficiencies, inp, layout = [0], n_times = 100):
    """
    This NOT gate includes an int number of inefficiencies, which determines
    how many qc.x gates the NOT will apply. Note that inefficiencies
    should always be an odd number for the gate to function as a not

    """
    qc = QuantumCircuit(1, 1) # A quantum circuit with a single qubit and a single classical bit
    qc.reset(0)

    if inp=='1':
        qc.x(0)

    qc.barrier()
    """We apply a predefined number of inefficiencies.
    Unfortunately, and contrary to our expectations, this did not yield a decreased
    accuracy result when running on a quantum computer. For the inefficiency-reduced accuracy,
    we will use the NOT() function instead"""
    for i in range(inefficiencies):
        print(i+1, "x gates have been added")
        qc.x(0)
    #barrier between gate operation and measurement
    qc.barrier()
    qc.measure(0,0)
    trial = qc.measure(0,0)
    return qc
    # OMITTED CODE

qc = inefficientNOT(
    inefficiencies=3,
    inp='1',
)
qc.draw()

Output:

1 x gates have been added
2 x gates have been added
3 x gates have been added
          ┌───┐ ░ ┌───┐┌───┐┌───┐ ░ ┌─┐┌─┐
  q: ─|0>─┤ X ├─░─┤ X ├┤ X ├┤ X ├─░─┤M├┤M├
          └───┘ ░ └───┘└───┘└───┘ ░ └╥┘└╥┘
c: 1/════════════════════════════════╩══╩═
                                     0  0

Where two measurements are added.

What should happen?

I would have expected a single measurement since adding two measurements on the same qubit and bit is redundant and makes the circuit more complex.

Any suggestions?

I would remove the second measurement.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.