Quantum Programming Studio API (1.0.0)

Download OpenAPI specification:

REST API documentation for integrating with Quantum Programming Studio services.

Synthesis and Transpilation

Create a new circuit synthesis job

Creates a new circuit synthesis job in a "draft" state from the provided JSON description.

There are 4 possible types of jobs:

  • vectors synthesize quantum circuit from pairs of initial/final state vectors. Resulting circuit transforms each of initial vectors into corresponding final vector.
  • unitary decompose unitary matrix into equivalent quantum circuit with given instruction set
  • truth synthesize quantum circuit which implements logical function given as truth table.
  • circuit transpile given quantum circuit (change instruction set).

Each type of job receives input in different format and slightly different settings. See bellow:

Vectors

Synthesize quantum circuit from pair(s) of initial/target (final) state vectors.

Example input data:

{
    "name": "Untitled job",
    "type": "vectors",
    "source": {
        "vectors": {
            "text1": "[ 1, 0, 0, 0 ]",
            "text2": "[ 1/sqrt(2), 0, 0, 1/sqrt(2) ]",
            "endianness1": "little",
            "endianness2": "little"
        }
    },
    "settings": {
        "max_duration": 0,
        "allowed_gates": "u3,cx",
        "min_gates": 0,
        "max_gates": 0,
        "strategy": "strategy_a",
        "pre_processing": "",
        "max_diff": 0.001,
        "diff_method": "ignorephase",
        "single_solution": true
    }
}
  • type is string vectors

  • source.vectors object contains:

    • text1 string containing initial state vectors. One vector per line. Vector elements can be expressions (in mathjs format) like 1/sqrt(2) and complex numbers like 0.5+0.5j or 0.5+0.5i.

    • text2 string containing target (final) state vectors. One vector per line. Vector elements can contain expressions (in mathjs format) like 1/sqrt(2) and complex numbers like 0.5+0.5j or 0.5+0.5i.

    • endianness1 string. Endianness of initial vector(s). Can be big (big endian) or small (small endian - like Qiskit)

    • endianness2 string. Endianness of target vector(s). Can be big (big endian) or small (small endian - like Qiskit)

  • settings object contains:

    • strategy string. Can be one of: strategy_a (brute force or heuristics) and strategy_b OptigenQ+QSD (OptigenQ is Quantastica's method to find unitary matrix from pairs of vectors, and QSD is used to decompose matrix and return circuit). Default is strategy_a.

    • pre_processing string. Used only with strategy_a (brute force or heuristics). Can be one of: stable, experimental_1, experimental_2, experimental_3, experimental_5. Default is empty string (Empty string means "use default" which is currently stable).

    • allowed_gates string. Used only with strategy_a (brute force or heuristics). Comma delimited gate names (instruction set) to use. Default is u3,cx. With strategy_b instruction set is fixed to u3,cx.

    • min_gates and max_gates integer. Used only with strategy_a (brute force or heuristics). Default is 0 (no limits).

    • max_diff float. Used only with strategy_a (brute force or heuristics). Default is 0.001 (1e-3).

    • diff_method string. Used only with strategy_a (brute force or heuristics). Can be one of: distance (exact match), ignorephase (match up to a global phase) and abs (match absolute values). Default is ignorephase.

    • max_duration integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is 0 which means "maximum allowed by your subscription plan". Free plan has limit of a few seconds (subject to change).

    • single_solution boolean. Used only with strategy_a (brute force or heuristics). When true, solver will stop when first solution was found. When false solver will return all possible configurations of a circuit.

Unitary

Decompose unitary matrix into equivalent quantum circuit.

Example input data:

{
    "name": "Untitled job",
    "type": "unitary",
    "source": {
        "unitary": {
            "text": "[\n  [ 0.70710678118655,  0.00000000000000,  0.70710678118655,  0.00000000000000],\n  [ 0.00000000000000,  0.70710678118655,  0.00000000000000,  0.70710678118655],\n  [ 0.00000000000000,  0.70710678118655,  0.00000000000000, -0.70710678118655],\n  [ 0.70710678118655,  0.00000000000000, -0.70710678118655,  0.00000000000000]\n]",
            "endianness": "big"
        }
    },
    "settings": {
        "max_duration": 0,
        "allowed_gates": "u3,cx",
        "coupling_map": [],
        "min_gates": 0,
        "max_gates": 0,
        "strategy": "strategy_a",
        "pre_processing": "",
        "max_diff": 0.001,
        "diff_method": "ignorephase",
        "single_solution": true
    }
}
  • type is string unitary

  • source.unitary object contains:

    • text string containing unitary matrix to decompose. Matrix elements can be expressions (in mathjs format) like 1/sqrt(2) and complex numbers like 0.5+0.5j or 0.5+0.5i.

    • endianness string. Endianness of a matrix. Can be big (big endian) or small (small endian - like Qiskit)

  • settings object contains:

    • strategy string. Can be one of: strategy_a (brute force or heuristics) and strategy_b QSD. Default is strategy_a. Note that strategy_a (brute force or heuristics) returns circuit with optimal or near optimal depth, but this method has very high computational complexity and can run for a very long time (depending on number of qubits and total number of gates in the resulting circuit).

    • pre_processing string. Used only with strategy_a (brute force or heuristics). Can be one of: stable, experimental_1 and experimental_5. Default is empty string (Empty string means "use default" which is currently stable). Experimental methods have lower computational complexity and should finish sooner, but that depends on many factors, so you should try all methods and see what works best for your particular problem.

    • allowed_gates string. Used only with strategy_a (brute force or heuristics). Comma delimited gate names (instruction set) to use. Default is u3,cx. With strategy_b instruction set is fixed to u3,cx.

    • min_gates and max_gates integer. Used only with strategy_a (brute force or heuristics). Default is 0 (no limits).

    • max_diff float. Used only with strategy_a (brute force or heuristics). Default is 0.001 (1e-3).

    • diff_method string. Used only with strategy_a (brute force or heuristics). Can be one of: distance (exact match), ignorephase (match up to a global phase) hs (match up to a global phase using faster method) and abs (match absolute values). Default is ignorephase.

    • max_duration integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is 0 which means "maximum allowed by your subscription plan". Free plan has limit of a few seconds (subject to change).

    • single_solution boolean. Used only with strategy_a (brute force or heuristics). When true, solver will stop when first solution was found. When false solver will return all possible configurations of a circuit.

Truth

Synthesize quantum circuit from truth table.

Example input data:

{
    "name": "Untitled job",
    "type": "truth",
    "source": {
        "truth": {
            "text": "A\t~A\n0\t1\n1\t0\n",
            "coldefs": [
                {
                    "index": 0,
                    "title": "A",
                    "type": 0
                },
                {
                    "index": 1,
                    "title": "~A",
                    "type": 1
                }
            ],
            "numNonOverlapingQubits": 0
        }
    },
    "settings": {
        "max_duration": 0,
        "allowed_gates": "x,cx,ccx,swap",
        "min_gates": 0,
        "max_gates": 0,
        "strategy": "strategy_a",
        "pre_processing": "",
        "max_diff": 0.001,
        "diff_method": "ignorephase",
        "single_solution": true
    }
}
  • type is string truth

  • source.truth object contains:

    • text string, truth table in CSV format.

    • coldefs list of column definitions:

      • index integer. Column index in given CSV file.

      • title string. Column title in given CSV file.

      • type integer. 0 is input, 1 is output, -1 means ignore column.

  • settings object contains:

    • pre_processing string. Can be one of: stable, experimental_1 and experimental_5. Default is empty string (Empty string means "use default" which is currently stable).

    • allowed_gates string. Comma delimited gate names (instruction set) to use. Default is x,cx,ccx,swap.

    • min_gates and max_gates integer. Default is 0 (no limits).

    • max_diff float. Used only with strategy_a (brute force or heuristics). Default is 0.001 (1e-3).

    • diff_method string. Used only with strategy_a (brute force or heuristics). Can be one of: distance (exact match), ignorephase (match up to a global phase) and abs (match absolute values). Default is ignorephase.

    • max_duration integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Useful with brute force algorithm which has high computational complexity and can run for a very long time. You can decide when to stop (and for example proceed with the next job which is using different method and is waiting in a queue - if you prepared it). Default is 0 which means "maximum allowed by your subscription plan". Free plan has limit of a few seconds (subject to change).

    • single_solution boolean. Used only with strategy_a (brute force or heuristics). When True, solver will stop when first solution was found. When False solver will return all possible configurations of a circuit.

Transpile

Transpile and optimize given quantum circuit (change instruction set).

Example input data:

{
    "name": "Untitled job",
    "type": "circuit",
    "source": {
        "circuit": {
            "qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nh q[0];\ncx q[0], q[1];\n",
            "method": "replace_blocks",
            "two_pass": false,
            "block_size": 2
        }
    },
    "settings": {
        "max_duration": 0,
        "allowed_gates": "u3,cx",
        "pre_processing": "experimental1",
        "strategy": "strategy_a",
        "max_diff": 0.001,
        "diff_method": "ignorephase",
        "single_solution": true
    }
}
  • type is string circuit

  • source.circuit object contains:

    • qasm string. Source code of a quantum circuit to transpile (OpenQASM 2.0).

    • method is method name string. Can be one of: "replace_circuit", "replace_blocks", "replace_gates". Default: "replace_blocks".

    • two_pass boolean. Only if method is "replace_blocks". Performs two-step transpilation (could give better optimization in some cases).

    • block_size boolean. Only if method is "replace_blocks". Transpile in blocks of given number of qubits. Default (and recommended) value is 2.

  • settings object contains:

    • pre_processing string. Can be one of: stable, experimental_1, experimental_2, experimental_3, experimental_5. Default is empty string (Empty string means "use default" which is currently stable).

    • allowed_gates string. Comma delimited gate names (instruction set) to use. Default is u3,cx.

    • max_diff float. Default is 0.001 (1e-3).

    • diff_method string. Can be one of: distance (exact match), ignorephase (match up to a global phase) and abs (match absolute values). Default is ignorephase.

    • max_duration integer. Timeout in seconds. Solver will stop after specified number of seconds and error will be returned. Default is 0 which means "maximum allowed by your subscription plan". Free plan has limit of a few seconds (subject to change).

Request Body schema: application/json
required
object

JSON description of the circuit synthesis job.

Responses

Request samples

Content type
application/json
{ }

Response samples

Content type
application/json
{
  • "_id": "string"
}

Start a synthesis job

Start previously created synthesis job in draft status (including previously stopped or canceled jobs).

Request Body schema: application/json
required
_id
required
string

The unique identifier of the job to start.

Responses

Request samples

Content type
application/json
{
  • "_id": "string"
}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "message": "OK"
}

Stop a synthesis job

Stop running or cancel queued job. Job will be set into draft state.

Request Body schema: application/json
required
_id
required
string

The unique identifier of the job to stop.

Responses

Request samples

Content type
application/json
{
  • "_id": "string"
}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "message": "OK"
}

Stop running and queued synthesis jobs

Stop running synthesis job and cancel all queued jobs. Optionally filter by status to stop only the running job or stop all queued jobs.

Request Body schema: application/json
optional
status
string
Enum: "running" "queued"

Optional filter to stop only jobs with a specific status. If omitted, both running and queued jobs are stopped.

Responses

Request samples

Content type
application/json
{
  • "status": "running"
}

Response samples

Content type
application/json
{
  • "stopped": [
    ]
}

Reset a synthesis job

Reset finished job or job in error state into draft state.

Request Body schema: application/json
required
_id
required
string

The unique identifier of the job to reset.

Responses

Request samples

Content type
application/json
{
  • "_id": "string"
}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "message": "OK"
}

Get job data (and results if job is finished)

If status is done then the job will contain output object with list of circuits in three formats: Quantastica's json circuit format, standard OpenQASM 2.0, and OpenQASM 2.0 with extended instruction set.

Example output:

{
    "_id": "r9LskFoLPQW5w7HTp",
    "name": "Bell",
    "type": "vectors",
    "source": {
        "vectors": {
            "text1": "[ 1, 0, 0, 0 ]",
            "text2": "[ 1/sqrt(2), 0, 0, 1/sqrt(2) ]",
            "endianness1": "little",
            "endianness2": "little"
        }
    },
    "problem": [
        {
            "input": [ 1, 0, 0, 0 ],
            "output": [ 0.7071067811865475, 0, 0, 0.7071067811865475 ]
        }
    ],
    "settings": {
        "max_duration": 0,
        "allowed_gates": "u3,cx",
        "coupling_map": [],
        "min_gates": 0,
        "max_gates": 0,
        "pre_processing": "",
        "strategy": "strategy_a",
        "max_diff": 0.001,
        "diff_method": "distance",
        "single_solution": False
    },
    "status": "done",
    "output": {
        "circuits": [
            {
                "qubits": 2,
                "cregs": [],
                "diff": 0,
                "program": [
                    {
                        "name": "u3",
                        "wires": [ 0 ],
                        "options": {
                            "params": {
                                "theta": -1.570796370506287,
                                "phi": -3.141592741012573,
                                "lambda": -5.327113628387451
                            }
                        }
                    },
                    {
                        "name": "cx",
                        "wires": [ 0, 1 ],
                        "options": {}
                    }
                ],
                "index": 0,
                "qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[0];\ncx q[0], q[1];\n",
                "qasmExt": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[0];\ncx q[0], q[1];\n"
            },
            {
                "qubits": 2,
                "cregs": [],
                "diff": 0,
                "program": [
                    {
                        "name": "u3",
                        "wires": [ 1 ],
                        "options": {
                            "params": {
                                "theta": -1.570796370506287,
                                "phi": -3.141592741012573,
                                "lambda": -5.327113628387451
                            }
                        }
                    },
                    {
                        "name": "cx",
                        "wires": [ 1, 0 ],
                        "options": {}
                    }
                ],
                "index": 1,
                "qasm": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[1];\ncx q[1], q[0];\n",
                "qasmExt": "OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\nu3 (-1.570796370506287, -3.141592741012573, -5.327113628387451) q[1];\ncx q[1], q[0];\n"                
            }
        ],
        "error_code": 0,
        "message": "",
        "time_taken": 0.002,
        "version": "0.1.0"
    },
    "queuedAt": "2021-02-06T23:39:29.676Z",
    "startedAt": "2021-02-06T23:39:29.926Z",
    "finishedAt": "2021-02-06T23:39:30.383Z"
}
Request Body schema: application/json
required
_id
required
string

The unique identifier of the job to retrieve.

Responses

Request samples

Content type
application/json
{
  • "_id": "string"
}

Response samples

Content type
application/json
{ }

List synthesis jobs

List all jobs, optionally filtered by status.

Request Body schema: application/json
optional
status
string
Enum: "draft" "queued" "running" "error" "done"

Optional filter to return only jobs with a specific status.

Responses

Request samples

Content type
application/json
{
  • "status": "draft"
}

Response samples

Content type
application/json
{
  • "list": [
    ]
}

Get status of a synthesis job

Get status of a synthesis job.

Request Body schema: application/json
required
_id
required
string

The unique identifier of the job.

Responses

Request samples

Content type
application/json
{
  • "_id": "string"
}

Response samples

Content type
application/json
{
  • "_id": "string",
  • "name": "string",
  • "type": "string",
  • "status": "string"
}

Conversion Utilities

Convert quantum program to different format

Converts an input quantum program given as a string from a source format into a destination format.

Request Body schema: application/json
required
input
required
string

Source code to convert.

source
required
string
Enum: "qasm" "quil" "qobj" "ionq" "quantum-circuit" "toaster"

Input format of the provided source code.

dest
required
string
Enum: "qiskit" "qasm" "qasm-ext" "qobj" "quil" "pyquil" "cudaq" "braket" "cirq" "tfq" "qsharp" "quest" "js" "quantum-circuit" "toaster" "svg" "svg-inline"

Desired output format.

Responses

Request samples

Content type
application/json
{
  • "input": "string",
  • "source": "qasm",
  • "dest": "qiskit"
}

Response samples

Content type
{ }

Circuit Utilities

Generate a random quantum circuit

Creates a random quantum circuit with specified parameters. Output format adapts based on the format argument.

Request Body schema: application/json
optional
num_qubits
integer
Default: 5

Number of qubits.

format
string
Default: "quantum-circuit"
Enum: "qiskit" "qasm" "qasm-ext" "qobj" "quil" "pyquil" "cudaq" "braket" "cirq" "tfq" "qsharp" "quest" "js" "quantum-circuit" "toaster" "svg" "svg-inline"

Output format of the generated circuit.

instruction_set
Array of strings
Default: ["u3","rx","ry","rz","cx","cz"]

List of quantum gates to use in generation.

num_gates
integer

Number of gates in the circuit. Default is num_qubits * 8.

mid_circuit_measurement
boolean
Default: false

Enable mid-circuit measurements.

mid_circuit_reset
boolean
Default: false

Enable mid-circuit resets.

classic_control
boolean
Default: false

Enable classical control operations.

Responses

Request samples

Content type
application/json
{
  • "num_qubits": 5,
  • "format": "qiskit",
  • "instruction_set": [
    ],
  • "num_gates": 0,
  • "mid_circuit_measurement": false,
  • "mid_circuit_reset": false,
  • "classic_control": false
}

Response samples

Content type
{ }