Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHSH inequality #58

Open
cosenal opened this issue Dec 3, 2024 · 5 comments
Open

CHSH inequality #58

cosenal opened this issue Dec 3, 2024 · 5 comments
Assignees

Comments

@cosenal
Copy link
Contributor

cosenal commented Dec 3, 2024

Understand how the CHSH inequality test can be leveraged for a benchmark test
Acceptance criteria:

  • Find a paper reference for the CHSH inequality benchmark in qiskit_device_benchmarking/bench_code/bell/bell_experiment.py
  • Run it against an IBM device
  • Understand if we want our own implementation
@vprusso
Copy link
Contributor

vprusso commented Dec 5, 2024

@cosenal we can speak more about this tomorrow evening, but here are some answers to these questions:

Find a paper reference for the CHSH inequality benchmark in qiskit_device_benchmarking/bench_code/bell/bell_experiment.py

I wasn't able to find specific papers using this as a benchmark, but it's obvious from some of the papers I did find that the benchmark in this case is just "run the circuit on a device and see how close you get to $2 \sqrt{2}$".

Run it against an IBM device

Here is a minimal example of running this benchmark:

from metriq_gym.hardware.bell_experiment import CHSHExperiment, ExperimentData
from qiskit_aer import Aer

qset = [0, 1]
backend_real = Aer.get_backend("qasm_simulator")
chsh_exp = CHSHExperiment(physical_qubits=qset,backend=backend_real)

experiment_data: ExperimentData = chsh_exp.run()
experiment_data.block_for_results()

# Access the analysis results
results = experiment_data.analysis_results()
for result in results:
    print(f"{result.name}: {result.value}")

Since we are running on "qasm_simulator", the result is S: 2.82421875. You can change to a hardware backend as well.

Understand if we want our own implementation

I would say let's not reinvent the wheel and opt to use the one here. The only thing I would say is that we track using git submodules ala #49

@cosenal
Copy link
Contributor Author

cosenal commented Dec 5, 2024

Thanks, @vprusso.
How does one pick the pair of qubits to use? Is the final benchmark an average over all the pairs? 🤔
Can we run it on a couple of IBM hardware devices and observe differences with the simulator results?

@vprusso
Copy link
Contributor

vprusso commented Dec 6, 2024

How does one pick the pair of qubits to use?

Discussed today, but for posterity, one picks two qubits that map to components on the device coupling map. One would typically opt to choose two neighboring nodes with minimal cross-talk noise. Much of this choice would be contingent about the device topology and noise-specific properties.

Is the final benchmark an average over all the pairs?

I think the benchmark shouldn't be the average but rather "What is the best choice of qubits on the device that gets as close as possible to the theoretical violation?"

Can we run it on several IBM hardware devices and observe differences with the simulator results?

I ran it on several IBM hardware devices using several qubit configurations. Here is an updated script that supports both simulator and hardware (if you want also to run it):

from metriq_gym.hardware.bell_experiment import CHSHExperiment, ExperimentData
from qiskit_aer import Aer
from qiskit_ibm_runtime import QiskitRuntimeService

use_sim = False
service = QiskitRuntimeService(instance="<INSTANCE_NAME>")

qset = [0, 1]
if use_sim:
    backend = Aer.get_backend("qasm_simulator")
else:
    backend = service.backend("<IBM_BACKEND_NAME>")

chsh_exp = CHSHExperiment(physical_qubits=qset,backend=backend)

experiment_data: ExperimentData = chsh_exp.run()
experiment_data.block_for_results()

# Access the analysis results
results = experiment_data.analysis_results()
for result in results:
    print(f"{result.name}: {result.value}")

For instance, running on "ibm_strasbourg" yielded 2.599609375 on qubits 0 and 1. While I didn't check every single pair of neighboring qubits (which, maybe we want to in general) I did add this to the wiki here.

@vprusso
Copy link
Contributor

vprusso commented Dec 12, 2024

There is now a standalone CHSH implementation. Integrating directly into metriq-gym is currently blocked by:
#52 and and #65

@cosenal
Copy link
Contributor Author

cosenal commented Jan 21, 2025

#52 and #65 are resolved now. Let's crack with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants