78 lines
5.9 KiB
Plaintext
78 lines
5.9 KiB
Plaintext
---
|
|
title: Qiskit Code Assistant
|
|
description: Learn how to use Qiskit Code Assistant, a generative AI code assistant.
|
|
---
|
|
|
|
# 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](https://www.ibm.com/products/watsonx-ai). 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,](https://www.ibm.com/products/watsonx-ai/foundation-models) which incorporate the latest features and functionalities from IBM®.
|
|
|
|
<Admonition type="note" title="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](https://qiskit.enterprise.slack.com/archives/C07LYA6PL83) or the related public GitHub repositories.
|
|
</Admonition>
|
|
|
|
<video title="A user uses Qiskit Code Assistant in JupyterLab. The user has a comment in the code to get the available backends for their account in IBM Quantum. Qiskit Code Assistant gives a code suggestion to get the available backends. The user executes the code, gets the available backends in IBM Quantum Platform for the current account. The user asks Qiskit Code Assistant to generate the code to get the T1, T2 and other properties for the qubit 1 in the device ibm_brisbane. The assistant gives a code suggestion. The user runs the suggested code and gets the desired output." className="max-w-auto h-auto" controls>
|
|
<source src="/videos/guides/qiskit-code-assistant/demo-JupyterLab-t1t2-granite-8b-qiskit-short.mp4" type="video/mp4"></source>
|
|
</video>
|
|
|
|
## Features
|
|
|
|
The following features are included in the [Visual Studio Code](https://code.visualstudio.com/) (VS Code) and [JupyterLab.](https://jupyterlab.readthedocs.io/en/latest/) 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:
|
|
- [JupyterLab](/guides/qiskit-code-assistant-jupyterlab)
|
|
- [VS Code](/guides/qiskit-code-assistant-vscode)
|
|
|
|
## 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.](https://github.com/ibm-granite/granite-code-models) 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.](https://arxiv.org/abs/2405.04324) For more details about the `granite-.*-qiskit` models, see [Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code.](https://arxiv.org/abs/2405.19495)
|
|
|
|
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](https://arxiv.org/abs/2107.03374), 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
|
|
|
|
<Admonition type="tip" title="Recommendations">
|
|
- Install and use the official [JupyterLab](/guides/qiskit-code-assistant-jupyterlab) or [VS Code](/guides/qiskit-code-assistant-vscode) extensions.
|
|
- See examples to use Qiskit Code Assistant for [circuits](/guides/circuit-library), [configuring error suppression](/guides/configure-error-suppression), and [transpiling with pass managers.](/guides/transpile-with-pass-managers)
|
|
</Admonition>
|