ProductBlogAlgorithmsAboutSign inSign up

Quick Example

GHZ State: Quantum Circuit Example

3-qubit entanglement

What this example teaches

Prepare a three-qubit GHZ state.

Expected result

Ideal browser outcomes are 000 and 111, each with probability 1/2. Phase-sensitive checks are needed to distinguish this state from a mixture.

Browser bit strings list physical wires q0 first, including auxiliary wires. Native classical-register strings can use another order; inspect the declared measurements.

These are ideal probabilities. Sampled frequencies fluctuate when more than one outcome is possible; they need not match percentages exactly. An ideal outcome with probability 100% has no finite-shot variation. Hardware noise is a separate effect.

Try the example

Open Run in Marqov →

The link opens the editor. Save existing work, then choose Examples → GHZ State → framework. Click Run, choose an available browser simulator, then click Run in browser. The link does not preselect or execute the example.

Scope and limitations

  • Computational-basis counts alone do not verify the relative phase or genuine multipartite entanglement.

These expected answers describe the fixed circuit. This page does not establish a completed hosted or hardware run. Read the user guide for this example.

Inspect and download the circuit

Inspect the same fixed circuit in five frameworks. Browser execution translates supported circuit definitions into OpenQASM; it does not run general Python. Outside Marqov, Qiskit, Cirq, and Marqov snippets need a separate simulator invocation. PennyLane invokes its QNode and stores sampled counts in result.

OpenQASM
// GHZ State — 3-qubit entanglement (|000> + |111>)/sqrt(2)
OPENQASM 2.0;
include "qelib1.inc";
qreg q[3];
creg c[3];
h q[0];
cx q[0],q[1];
cx q[0],q[2];
measure q -> c;
Download OpenQASM circuit
Qiskit
# GHZ State — 3-qubit entanglement (|000> + |111>)/sqrt(2)
from qiskit import QuantumCircuit

qc = QuantumCircuit(3, 3)
qc.h(0)
qc.cx(0, 1)
qc.cx(0, 2)
qc.measure([0, 1, 2], [0, 1, 2])
Download Qiskit circuit
Cirq
# GHZ State — 3-qubit entanglement (|000> + |111>)/sqrt(2)
import cirq

q0, q1, q2 = cirq.LineQubit.range(3)
circuit = cirq.Circuit([
    cirq.H(q0),
    cirq.CNOT(q0, q1),
    cirq.CNOT(q0, q2),
    cirq.measure(q0, q1, q2, key="result"),
])
Download Cirq circuit
PennyLane
# GHZ State — 3-qubit entanglement (|000> + |111>)/sqrt(2)
import pennylane as qml

dev = qml.device("default.qubit", wires=3, shots=1000)

@qml.qnode(dev)
def ghz_state():
    qml.Hadamard(wires=0)
    qml.CNOT(wires=[0, 1])
    qml.CNOT(wires=[0, 2])
    return qml.counts()

result = ghz_state()
Download PennyLane circuit
Marqov
# GHZ State — 3-qubit entanglement (|000> + |111>)/sqrt(2)
from marqov import Circuit

circuit = Circuit().h(0).cnot(0, 1).cnot(0, 2)
Download Marqov circuit

Sources and provenance

These references explain the concept and gate conventions. The snippets originate in Marqov's internal example collection; an upstream code attribution has not been established.

Snapshot identity
Source revision
df5a80cd474144684bf69dbda237b28ce40cc48c
Example version
fa166dcc734b47e444bb2964fb8ce76f0de64531b923668f39685a93b31a9e39

The source revision identifies the editor collection used for this snapshot. The example version identifies its five exact code variants; neither is evidence of a hosted run.

Go deeper

For a paper-based experiment with scientific comparisons and execution evidence, read Research Replications. Its published scope and availability are separate from this small teaching circuit.

Explore all twelve Quick Examples →