2
$\begingroup$

I'm trying to implement an algorithm (https://dl.acm.org/citation.cfm?id=1128034, basically a simple Grover Algorithm in which the oracle is made of a Fitness operator- some CNOT gates- and 2 adders) and when I try to simulate it on ibm_qasm_simulator I get the error: "Job resulted in the following QASM status(es): ERROR.". If I export the qasm code and simulate it online, I got the following error: ERROR_TRANSPILING_JOB but the original and transpiled code look identical.

I'm using qiskit 0.8.2:

'qiskit': '0.11.1', 
'qiskit-terra': '0.8.2', 
'qiskit-ignis': '0.1.1', 
'qiskit-aer': '0.2.3', 
'qiskit-ibmq-provider': '0.3.1', 
'qiskit-aqua': '0.5.3'

The QASM code, as generated by qiskit and modified a little bit to include the subcircuits is:

OPENQASM 2.0;
include "qelib1.inc";
gate majority a,b,c
{
  cx c,b;
  cx c,a;
  ccx a,b,c;
}
gate unmaj a,b,c
{
  ccx a,b,c;
  cx c,a;
  cx a,b;
}
gate add4 a0,a1,a2,a3,b0,b1,b2,b3,cin,cout
{
  majority cin,b0,a0;
  majority a0,b1,a1;
  majority a1,b2,a2;
  majority a2,b3,a3;
  cx a3,cout;
  unmaj a2,b3,a3;
  unmaj a1,b2,a2;
  unmaj a0,b1,a1;
  unmaj cin,b0,a0;
}
gate adder8 aop0,aop1,aop2,aop3,aop4,aop5,aop6,aop7,bop0,bop1,bop2,bop3,bop4,bop5,bop6,bop7,carry0,carry1
{
    add4 aop0,aop1,aop2,aop3,bop0,bop1,bop2,bop3,carry0,carry1;
    add4 aop4,aop5,aop6,aop7,bop4,bop5,bop6,bop7,carry1,carry0;
}

gate tof ctrl0,ctrl1,ctrl2,ctrl3,ctrl4,ctrl5,ctrl6,ctrl7,anc0,anc1,anc2,anc3,anc4,anc5,anc6,tgt
{
    ccx ctrl0,ctrl1,anc0;
    ccx ctrl2,anc0,anc1;
    ccx ctrl3,anc1,anc2;
    ccx ctrl4,anc2,anc3;
    ccx ctrl5,anc3,anc4;
    ccx ctrl6,anc4,anc5;
    ccx ctrl7,anc5,anc6;
    cx anc6,tgt;
    ccx ctrl7,anc5,anc6;
    ccx ctrl6,anc4,anc5;
    ccx ctrl5,anc3,anc4;
    ccx ctrl4,anc2,anc3;
    ccx ctrl3,anc1,anc2;
    ccx ctrl2,anc0,anc1;
    ccx ctrl0,ctrl1,anc0;
}

qreg ireg[4];
qreg freg[9];
qreg mreg[8];
qreg carryreg[2];
qreg oreg[1];
qreg ancilla[3];
creg reg[9];
h ireg[0];
h ireg[1];
h ireg[2];
h ireg[3];
x mreg[1];
x mreg[2];
x mreg[4];
x mreg[5];
x mreg[6];
x mreg[7];
barrier ireg[0],ireg[1],ireg[2],ireg[3],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],freg[8],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],carryreg[0],carryreg[1],oreg[0],ancilla[0],ancilla[1],ancilla[2];
adder8 mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],carryreg[0],carryreg[1];
barrier ireg[0],ireg[1],ireg[2],ireg[3],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],freg[8],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],carryreg[0],carryreg[1],oreg[0],ancilla[0],ancilla[1],ancilla[2];
x freg[7];
cx freg[7],oreg[0];
x freg[7];
barrier ireg[0],ireg[1],ireg[2],ireg[3],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],freg[8],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],carryreg[0],carryreg[1],oreg[0],ancilla[0],ancilla[1],ancilla[2];
reset mreg[0];
reset mreg[1];
x mreg[1];
reset mreg[2];
reset mreg[3];
x mreg[3];
reset mreg[4];
reset mreg[5];
reset mreg[6];
reset mreg[7];
barrier ireg[0],ireg[1],ireg[2],ireg[3],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],freg[8],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],carryreg[0],carryreg[1],oreg[0],ancilla[0],ancilla[1],ancilla[2];
adder8 mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],carryreg[0],carryreg[1];
reset mreg[0];
reset mreg[1];
reset mreg[2];
reset mreg[3];
reset mreg[4];
reset mreg[5];
reset mreg[6];
reset mreg[7];
barrier ireg[0],ireg[1],ireg[2],ireg[3],freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],freg[8],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],mreg[7],carryreg[0],carryreg[1],oreg[0],ancilla[0],ancilla[1],ancilla[2];
h freg[0];
x freg[0];
h freg[1];
x freg[1];
h freg[2];
x freg[2];
h freg[3];
x freg[3];
h freg[4];
x freg[4];
h freg[5];
x freg[5];
h freg[6];
x freg[6];
h freg[7];
x freg[7];
h freg[8];
x freg[8];
h freg[8];
tof freg[0],freg[1],freg[2],freg[3],freg[4],freg[5],freg[6],freg[7],mreg[0],mreg[1],mreg[2],mreg[3],mreg[4],mreg[5],mreg[6],freg[8];
x freg[0];
h freg[0];
x freg[1];
h freg[1];
x freg[2];
h freg[2];
x freg[3];
h freg[3];
x freg[4];
h freg[4];
x freg[5];
h freg[5];
x freg[6];
h freg[6];
x freg[7];
h freg[7];
h freg[8];
x freg[8];
h freg[8];
measure freg[0] -> reg[0];
measure freg[1] -> reg[1];
measure freg[2] -> reg[2];
measure freg[3] -> reg[3];
measure freg[4] -> reg[4];
measure freg[5] -> reg[5];
measure freg[6] -> reg[6];
measure freg[7] -> reg[7];
measure freg[8] -> reg[8];

$\endgroup$
  • $\begingroup$ Hi, do you get this issue when you add all the gates using Qiskit, or only when you load from qasm? When I run the qasm you provided I get an error saying that custom gates are not supported, but this may only be the case in the conversion from qasm to qiskit code. $\endgroup$ – met927 Aug 27 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.