Giter VIP home page Giter VIP logo

Comments (5)

chriseclectic avatar chriseclectic commented on July 19, 2024

Can you test if with this change in json_to_op_bfunc in operations.hpp fixes it?

JSON::get_value(op.memory, "memory", js);
JSON::get_value(op.registers, "register", js);

to

uint_t tmp;
if (JSON::get_value(tmp, "register", js)) {
  op.registers.push_back(tmp);
}
if (JSON::get_value(tmp, "memory", js)) {
  op.memory.push_back(tmp);
}

NB: Do we actually need the "memory" part for bfunc? If only register used by the spec then the last part can just be removed.

from qiskit-aer.

kdk avatar kdk commented on July 19, 2024

That gets it past the JSON validation failure and the simulation completes, but the counts returned aren't what I wouldn't expect.

For the circuit above:

         ┌───┐┌─┐          
q1_0: |0>┤ H ├┤M├──────────
         └───┘└╥┘┌─────┐┌─┐
q1_1: |0>──────╫─┤  X  ├┤M├
               ║ ├──┴──┤└╥┘
 c2_0: 0 ══════╩═╡ = 1 ╞═╬═
                 └─────┘ ║ 
 c3_0: 0 ════════════════╩═

I get (with qobj-conditionals from terra and the fix above):

{'0 0': 513, '0 1': 511}

With old-style conditionals from terra and master aer I get:

{'0 0': 519, '1 1': 505}

Looking briefly, it looks like apply_bfunc is making the right comparison, but its result is not being written to the provided register. (I'm not at all familiar with the simulator code, but it looks like apply_bfunc is returning the boolean result of the comparison, but State::apply_ops is not getting that return value written to the register.)

Re: "memory", the spec lists it as "(optional): Memory slot in which to store the boolean function result" presumably for debugging.

from qiskit-aer.

chriseclectic avatar chriseclectic commented on July 19, 2024

@kdk ok thanks for looking into it. I've tried fixing it in PR #55 if you want to test it.

Note: there might still be bugs in the actual logic of the bfunc function since it hasn't really well tested.

from qiskit-aer.

kdk avatar kdk commented on July 19, 2024

👍 Awesome, tested on #55 and it looks good. Thanks!

from qiskit-aer.

chriseclectic avatar chriseclectic commented on July 19, 2024

Closed by #55

from qiskit-aer.

Related Issues (20)

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.