Skip to content

qiskit-community/Quantum-Challenge-Grader

Repository files navigation

Quantum Challenge Grader

Grading client for the IBM Quantum Challenge grading service.

Run locally

Pre-requisites:

To install the grader locally:

  1. In the Python environment, install the grading client

    pip install git+https://github.com/qiskit-community/Quantum-Challenge-Grader.git
    

    Alternatively, if you also need to install JupyterLab and Qiskit along with the grader you can instead run:

    pip install 'qc-grader[qiskit,jupyter] @ git+https://github.com/qiskit-community/Quantum-Challenge-Grader.git'
    
  2. Configure the QXToken environment variables

    From a terminal (before launching your JupyterLab environment), enter

    export QXToken=your_quantum_api_token
    

    where your_quantum_api_token is your IBM Quantum API Token found in your Account Profile.

    Alternatively, if you prefer you can instead run the following at the top cell of a notebook cell (whenever you start/restart the kernel)

    %set_env QXToken=your_quantum_api_token
    

    Note1: you can check if the environment variable has been set by running the following in a notebook cell:

    import os
    print(os.getenv('QXToken'))

    Note2: If you already installed qiskit-ibm-runtime and saved your token by using QiskitRuntimeService by following this instruction once, you don't need to set-up the env variable. You can save your token by using QiskitRuntimeService like below:

    from qiskit_ibm_runtime import QiskitRuntimeService
    QiskitRuntimeService.save_account(
        channel="ibm_quantum",
        token="<YOUR_TOKEN>",
        set_as_default=True,
        overwrite=True,
    )

Usage

  1. Open an exercise notebook

    • In IBM Quantum Lab, the notebooks can be found in the quantum-challenge folder in the Lab files panel
    • For local install, download the notebooks (from IBM Quantum Lab or specific challenge repo) and import into local Jupyter environment
  2. Run the notebook cells, answering the exercises and submitting solution for grading. For example

    from qc_grader.challenges.challenge_2021 import grade_lab1_ex1 
    
    grade_lab1_ex1(qc_1)
    from qc_grader.challenges.challenge_2021 import grade_lab1_ex2 
    
    grade_lab1_ex2(qc_2)