Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Quantum Prompt Translator

This project is a proof-of-concept that demonstrates how a user prompt can be "translated" into a quantum computing task. It uses the Qiskit library to execute a quantum circuit on an IBM Quantum simulator.

Current Functionality

This initial version translates two specific prompts:

  • "create_bell_state": This creates a 2-qubit Bell state, which is a fundamental example of quantum entanglement.
  • "generate_random_number": This creates an 8-bit truly random number using quantum measurement.

Setup Instructions

1. Install Dependencies

First, it is recommended to create a virtual environment to keep the dependencies for this project isolated.

python3 -m venv venv
source venv/bin/activate

Then, install the required Python packages:

pip install -r requirements.txt

2. Get Your IBM Quantum API Token

To run circuits on IBM's quantum systems (even simulators), you need an API token.

  1. Create a free account on the IBM Quantum platform.
  2. Log in to your account.
  3. On the main dashboard, you will find your API token listed under the "Qiskit in local environment" section on the right-hand side. It will be a long string of random characters. Click the "Copy token" button to copy it to your clipboard.

3. Configure Your Environment

Create a file named .env in the root of the quantum-translator directory. This file will hold your API token securely.

Add the following line to your .env file, replacing YOUR_API_TOKEN_HERE with the token you copied from the IBM Quantum website:

IBM_QUANTUM_TOKEN="YOUR_API_TOKEN_HERE"

The .gitignore file is already configured to prevent this file from being committed to version control.

How to Run the Program

Once your environment is set up, you can run the program from the command line.

Pass the desired prompt as an argument.

  • To create a Bell state:
    python3 main.py "create_bell_state"
  • To generate a random number:
    python3 main.py "generate_random_number"

Expected Output

The program will execute the quantum circuit on a simulator and print a JSON object with the results.

For "create_bell_state":

You should see something similar to the following:

{
    "prompt": "create_bell_state",
    "backend": "generic_backend_8q",
    "shots": 1024,
    "results": {
        "00": 512,
        "11": 512
    },
    "explanation": "The results are counts of the 2-qubit states. For an ideal Bell state, you'd expect to see roughly 50% '00' and 50% '11', indicating entanglement."
}

The results dictionary shows the measurement outcomes. In an ideal Bell state (|Φ+⟩), the two qubits are perfectly correlated. When measured, they will both be 0 or both be 1, with a 50% probability for each outcome. The simulation reflects this by showing approximately half the shots resulting in 00 and half resulting in 11.

For "generate_random_number":

You should see something similar to the following (the binary_string and random_number will vary):

{
    "prompt": "generate_random_number",
    "backend": "generic_backend_8q",
    "shots": 1,
    "binary_string": "10110111",
    "random_number": 183,
    "explanation": "A Hadamard gate is applied to each qubit to put it in a superposition. When measured, each qubit collapses to 0 or 1 with equal probability, generating a truly random bit."
}

About

calls IBM qiskit and enables user to prompt for random output

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages