Skip to main contentIBM Quantum Documentation

Qiskit Code Assistant

Qiskit Code Assistant aims to make quantum computing more accessible to new Qiskit adopters and to improve the coding experience for current users. It is a generative AI code assistant powered by watsonx. It is trained using millions of text tokens from Qiskit SDK v1.x, years of Qiskit code examples and IBM Quantum™ features. Qiskit Code Assistant can help your quantum development workflow by offering LLM-generated suggestions based on IBM Granite 8B Code, which incorporate the latest features and functionalities from IBM®.

Notes
  • This is an experimental feature available only to IBM Quantum Premium Plan users.
  • Qiskit Code Assistant is in preview release status and is subject to change.
  • If you have feedback or want to contact the developer team, use the Qiskit Slack Workspace channel or the related public GitHub repositories.

Features

The following features are included in the Visual Studio Code (VS Code) and JupyterLab. extensions:

  • Accelerates Qiskit code generation by leveraging generative AI based on the granite-8b-qiskit model.
  • Allows abstract and specific prompts to generate recommendations.
  • Presents suggestions that you can review, accept, or reject.
  • Supports Python code and Jupyter notebook files.
  • Includes guardrails to avoid answering questions that represent a potential risk for users, such as hateful speech.

For instructions to integrate Qiskit Code Assistant directly into your development environment, follow the instructions in the appropriate topic:


The Large Language Model (LLM) behind Qiskit Code Assistant

To provide code suggestions, Qiskit Code Assistant uses a Large Language Model (LLM). In this case, Qiskit Code Assistant relies on the model granite-8b-qiskit, built on the IBM granite-8b-code model. The granite-8b-qiskit model improves the granite-8b-code model's code generation capabilities for Qiskit through extended pretraining and fine-tuning it on high-quality Qiskit data, as well as Python commits and chat. For more information about the IBM Granite models family, refer to Granite Code Models: A Family of Open Foundation Models for Code Intelligence. For more details about the granite-.*-qiskit models, see Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code.

The model granite-8b-qiskit model is expected to be open source soon.


The Qiskit HumanEval benchmark

To test the granite-8b-qiskit model, we are creating, in collaboration with Qiskit Advocates and experts, a new execution-based benchmark called Qiskit HumanEval (QHE). This benchmark is similar to HumanEval, including multiple challenging code problems to solve, all based on the official Qiskit libraries.

The benchmark is composed of approximately 150 tests, each one made from a function definition, followed by a docstring that details the task the model is required to solve. Each example also includes a reference canonical solution, as well as unit tests, to evaluate the correctness of the generated solutions. There are three levels of difficulty for tests: basic, intermediate, and difficult.

The dataset for the Qiskit HumanEval is expected to be open source soon.


More information and citations

To learn more about Qiskit Code Assistant or the Qiskit HumanEval and cite it in your scientific publications, review these recommended citations:

@misc{2405.19495,
Author = {Nicolas Dupuis and Luca Buratti and Sanjay Vishwakarma and Aitana Viudes Forrat and David Kremer and Ismael Faro and Ruchir Puri and Juan Cruz-Benito},
Title = {Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code},
Year = {2024},
Eprint = {arXiv:2405.19495},
}
@misc{2406.14712,
Author = {Sanjay Vishwakarma and Francis Harkins and Siddharth Golecha and Vishal Sharathchandra Bajpe and Nicolas Dupuis and Luca Buratti and David Kremer and Ismael Faro and Ruchir Puri and Juan Cruz-Benito},
Title = {Qiskit HumanEval: An Evaluation Benchmark For Quantum Code Generative Models},
Year = {2024},
Eprint = {arXiv:2406.14712},
}

Next steps

Recommendations
Was this page helpful?
Report a bug or request content on GitHub.