ブログ
8
November
,
2021

Circuit of the month Nov 21: Fun with State Preparations

Share the article
Our library

State preparations are often an important first step in many quantum algorithms. This month, we explore a circuit designed to load probability mass functions into five groups of three qubits each.

The unique angle here is how the Classiq platform generates the circuit when given a different number of qubits to work with.

In the first instance, we ask the synthesis platform to achieve this goal with 20 qubits. After automatically exploring many options, the engine decides that a good solution would be to split the 20 qubits into five groups of four qubits each. In each group, three qubits are initialized and the fourth qubit is used as an ancilla/auxiliary qubit.

Things get more interesting when the Classiq engine is asked to find a solution with 16 qubits. In this case, five groups of four qubits each is not possible. What the engine generates is a solution using the following steps:

  • First, four groups of three qubits are initialized (each using an ancilla qubit)
  • Then, the four ancialla qubits (one from each group) are cleaned up
  • Now, to take care of the last group of three qubits, not yet initialized, three of these four qubits (previously used as ancilla qubits for the previous groups) are initialized using the fourth qubit as ancilla

Here is the Classiq code for the 20-qubit case. This is the textual model, which one could run in the VSCode environment:


{
    "qubit_count":  20,
    "max_depth":1000,
    "draw_as_functions": false,
    "output_format": ["qasm"],
    "logic_flow": [{
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.3, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.0, 0.3, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.0, 0.05, 0.3, 0.0, 0.2, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.0, 0.2, 0.05, 0.3, 0.0, 0.0, 0.05]
            },
            "error_metric": {"KL": {"upper_bound": 0.34}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.0, 0.35, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    }
]
}

and here is the resulting circuit. You can see that all the five groups (three qubits each) are initialized in parallel

20-qubit circuit

To explore the 16-qubit solution, a single line needs to change:


{
    "qubit_count":  16, // <-- this is the only line that has changed
    "max_depth":1000,
    "draw_as_functions": false,
    "output_format": ["qasm"],
    "logic_flow": [{
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.3, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.0, 0.3, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.0, 0.05, 0.3, 0.0, 0.2, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.0, 0.2, 0.05, 0.3, 0.0, 0.0, 0.05]
            },
            "error_metric": {"KL": {"upper_bound": 0.34}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.0, 0.35, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    }
]
}

And here is the resulting circuit. You can see that qubits 3, 7, 11 and 15 are used after finishing the state preparation of qubits 0-2, 4-6, 8-10 and 12-14:

16-qubit solution

The Classiq platform not only allows designers to explore various options, but finds innovative solutions automatically.

State preparations are often an important first step in many quantum algorithms. This month, we explore a circuit designed to load probability mass functions into five groups of three qubits each.

The unique angle here is how the Classiq platform generates the circuit when given a different number of qubits to work with.

In the first instance, we ask the synthesis platform to achieve this goal with 20 qubits. After automatically exploring many options, the engine decides that a good solution would be to split the 20 qubits into five groups of four qubits each. In each group, three qubits are initialized and the fourth qubit is used as an ancilla/auxiliary qubit.

Things get more interesting when the Classiq engine is asked to find a solution with 16 qubits. In this case, five groups of four qubits each is not possible. What the engine generates is a solution using the following steps:

  • First, four groups of three qubits are initialized (each using an ancilla qubit)
  • Then, the four ancialla qubits (one from each group) are cleaned up
  • Now, to take care of the last group of three qubits, not yet initialized, three of these four qubits (previously used as ancilla qubits for the previous groups) are initialized using the fourth qubit as ancilla

Here is the Classiq code for the 20-qubit case. This is the textual model, which one could run in the VSCode environment:


{
    "qubit_count":  20,
    "max_depth":1000,
    "draw_as_functions": false,
    "output_format": ["qasm"],
    "logic_flow": [{
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.3, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.0, 0.3, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.0, 0.05, 0.3, 0.0, 0.2, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.0, 0.2, 0.05, 0.3, 0.0, 0.0, 0.05]
            },
            "error_metric": {"KL": {"upper_bound": 0.34}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.0, 0.35, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    }
]
}

and here is the resulting circuit. You can see that all the five groups (three qubits each) are initialized in parallel

20-qubit circuit

To explore the 16-qubit solution, a single line needs to change:


{
    "qubit_count":  16, // <-- this is the only line that has changed
    "max_depth":1000,
    "draw_as_functions": false,
    "output_format": ["qasm"],
    "logic_flow": [{
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.3, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.05, 0.0, 0.3, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.0, 0.05, 0.3, 0.0, 0.2, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.32}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.0, 0.2, 0.05, 0.3, 0.0, 0.0, 0.05]
            },
            "error_metric": {"KL": {"upper_bound": 0.34}}
        },
        "add_as_single_gate": true
    },
    {
        "function": "StatePreparation",
        "function_params": {
            "num_qubits": 4,
            "probabilities": {
                "pmf": [0.4, 0.05, 0.2, 0.0, 0.35, 0.0, 0.0, 0.0]
            },
            "error_metric": {"KL": {"upper_bound": 0.3}}
        },
        "add_as_single_gate": true
    }
]
}

And here is the resulting circuit. You can see that qubits 3, 7, 11 and 15 are used after finishing the state preparation of qubits 0-2, 4-6, 8-10 and 12-14:

16-qubit solution

The Classiq platform not only allows designers to explore various options, but finds innovative solutions automatically.

About "The Qubit Guy's Podcast"

Hosted by The Qubit Guy (Yuval Boger, our Chief Marketing Officer), the podcast hosts thought leaders in quantum computing to discuss business and technical questions that impact the quantum computing ecosystem. Our guests provide interesting insights about quantum computer software and algorithm, quantum computer hardware, key applications for quantum computing, market studies of the quantum industry and more.

If you would like to suggest a guest for the podcast, please contact us.

See Also

No items found.

量子ソフトウェア開発を開始

お問い合わせ