diff --git a/docs/guides/_toc.json b/docs/guides/_toc.json index 8af74660f2d..9b43762aff3 100644 --- a/docs/guides/_toc.json +++ b/docs/guides/_toc.json @@ -317,24 +317,7 @@ }, { "title": "Qiskit code assistant", - "children": [ - { - "title": "Qiskit Code Assistant overview", - "url": "/docs/guides/qiskit-code-assistant" - }, - { - "title": "Use Qiskit Code Assistant in JupyterLab", - "url": "/docs/guides/qiskit-code-assistant-jupyterlab" - }, - { - "title": "Use Qiskit Code Assistant in VS Code", - "url": "/docs/guides/qiskit-code-assistant-vscode" - }, - { - "title": "Qiskit Code Assistant - OpenAI API compatibility", - "url": "/docs/guides/qiskit-code-assistant-openai-api" - } - ] + "url": "/docs/guides/qiskit-code-assistant" } ], "collapsible": false diff --git a/docs/guides/circuit-library.ipynb b/docs/guides/circuit-library.ipynb index 93715e78f85..3940ff90c2d 100644 --- a/docs/guides/circuit-library.ipynb +++ b/docs/guides/circuit-library.ipynb @@ -107,16 +107,7 @@ "id": "e5066595", "metadata": {}, "source": [ - "See [Standard gates](/docs/api/qiskit/circuit_library#standard-gates) in the circuit library API documentation.\n", - "\n", - "" + "See [Standard gates](/docs/api/qiskit/circuit_library#standard-gates) in the circuit library API documentation." ] }, { diff --git a/docs/guides/construct-circuits.ipynb b/docs/guides/construct-circuits.ipynb index 867672eab48..73d0e62385d 100644 --- a/docs/guides/construct-circuits.ipynb +++ b/docs/guides/construct-circuits.ipynb @@ -671,19 +671,6 @@ "circuit = circuit.assign_parameters(parameters=training_params)" ] }, - { - "cell_type": "markdown", - "id": "ae19e48d", - "metadata": {}, - "source": [ - "" - ] - }, { "cell_type": "markdown", "id": "5af44bc3", diff --git a/docs/guides/install-qiskit.mdx b/docs/guides/install-qiskit.mdx index e41d31a475d..56e2c18a824 100644 --- a/docs/guides/install-qiskit.mdx +++ b/docs/guides/install-qiskit.mdx @@ -131,15 +131,6 @@ If you are planning to work locally and use simulators built into Qiskit, then y Periodically check the [Qiskit release notes](/docs/api/qiskit/release-notes) to see new releases. We recommend frequently updating your requirements for `qiskit` by running `pip install -U qiskit`. - - ## Troubleshooting diff --git a/docs/guides/plot-quantum-states.ipynb b/docs/guides/plot-quantum-states.ipynb index c5097e13ab3..d42a9384265 100644 --- a/docs/guides/plot-quantum-states.ipynb +++ b/docs/guides/plot-quantum-states.ipynb @@ -473,15 +473,7 @@ "- **title** (str): a string for the plot title, displayed at the top of the plot\n", "- **figsize** (tuple): figure size in inches (width, height)\n", "\n", - "The `plot_state_city` and `plot_state_paulivec` functions also accept a **color** argument (list of strings) specifying the colors of the bars. See the [API documentation](/docs/api/qiskit/visualization) for more information.\n", - "\n", - "" + "The `plot_state_city` and `plot_state_paulivec` functions also accept a **color** argument (list of strings) specifying the colors of the bars. See the [API documentation](/docs/api/qiskit/visualization) for more information." ] }, { diff --git a/docs/guides/qiskit-code-assistant-jupyterlab.mdx b/docs/guides/qiskit-code-assistant-jupyterlab.mdx deleted file mode 100644 index 28555ca1cf3..00000000000 --- a/docs/guides/qiskit-code-assistant-jupyterlab.mdx +++ /dev/null @@ -1,133 +0,0 @@ ---- -title: Use Qiskit Code Assistant in JupyterLab -description: How to install, use, and configure Qiskit Code Assistant in JupyterLab. ---- -{/* cspell:ignore labextension */} - -# Use Qiskit Code Assistant in JupyterLab - -Learn how to install, use, configure, and uninstall the official Qiskit Code Assistant extension in JupyterLab. - - - -## Install the JupyterLab extension -To install the [JupyterLab extension](https://github.com/Qiskit/qiskit-code-assistant-jupyterlab), run the following command from a terminal: - -```sh -pip install qiskit-code-assistant-jupyterlab -``` - -After installing the extension, start JupyterLab: - -```sh -jupyter lab -``` - -The extension loads automatically and is listed on the bottom of the JupyterLab window. Refer to the [JupyterLab documentation](https://jupyterlab.readthedocs.io/en/latest/) for help working with JupyterLab. - -## Configure extension settings - -It is recommended that you edit the following JupyterLab settings by going to Settings -> Settings Editor: - -- Click **Inline Completer**, find "Show widget" and choose **Always**. This means that the inline completer widget will always be shown so you can cycle through and select a completion item. - -- Click **Code Completion** and increase the value for "Default timeout for a provider." to `10000` or 10 seconds. The default value is 1 second, but the Qiskit Code Assistant API might take longer than this to find a suggestion. This setting only applies to the standard context menu that is invoked with `Tab`. The inline completer has a default of 10 seconds. - -Other settings you might want to change: - -- Keyboard shortcuts can be changed from Settings > Settings Editor > Keyboard Shortcuts. - -- You can change the IBM Quantum API token to use in the JupyterLab command palette. To do that, type `Alt` + `Shift` + `C`, search for `qiskit`, select the **Qiskit Code Assistant: Set IBM Quantum API token** command, and paste in your key. - -- [Advanced] To change the instance of the Qiskit Code Assistant service that the extension should use, edit Qiskit Code Assistant `serviceUrl` setting. - -- [Advanced] Keyboard shortcuts can be changed by searching for `completer` in the Keyboard Shortcuts settings (Settings -> Settings Editor -> Keyboard Shortcuts) and adding new shortcuts for the relevant commands. - -## Get started using the Qiskit Code Assistant extension for JupyterLab - -### Authentication and setup - -After installing the extension, it tries to authenticate you. By default, the package tries to authenticate to IBM Quantum services with the defined API key, and uses your key from the `QISKIT_IBM_TOKEN` environment variable or from the file `~/.qiskit/qiskit-ibm.json` (under the section `default-ibm-quantum`). If you need help configuring your account, follow the instructions in [Set up your IBM Cloud account](/docs/guides/cloud-setup). - -By default, the extension uses the `mistral-small-3.2-24b-qiskit` model, which is listed in the Model Picker in the bottom status bar. - -The first time you use the `mistral-small-3.2-24b-qiskit` model, a window opens that lists some major restrictions that you should be aware of when using the model. Click `Accept` to enable the model for code generation. - -### Generate code - -While you develop your code using Qiskit, you can ask to Qiskit Code Assistant to help you. In general, the assistant suggests better code as response to Python comments or docstrings, but you can use the assistant anywhere in your file. - -To get a code suggestion, type a prompt, then type `Alt` + `.` or `Alt` + `\`. There are two types of prompts you can use: - - - Enter partial code and get a suggestion to finish the code. Example: - ```python - from qiskit.circuit import QuantumCircuit - from qiskit.transpiler import generate_preset_pass_manager - from qiskit_ibm_runtime import SamplerV2 as Sampler - from qiskit_ibm_runtime.fake_provider import FakeManilaV2 - - # Bell Circuit - qc = QuantumCircuit(2) - qc.h(0) - qc.cx(0, 1) - - qc.mea # Type Ctrl + . for a code suggestion. - ``` - - Type a pound (#) sign, then type your prompt. Example: `# Give me a random circuit of 5 qubits and a depth of 4.` - -### Work with code suggestions - -Use the following to accept, reject, and cycle through suggestions: - -- `Alt` + `[` and `Alt` + `]` can be used to cycle through the list of suggestions (if there are - more than one). -- `Alt` + `Tab` or `Alt` + `END` accepts the suggested code and inserts it at the current - cursor location. - -Additionally, after the assistant runs, you can use the buttons on the widget to cycle or accept the suggestion: - -![The popup pane with buttons is shown.](/docs/images/guides/qiskit-code-assistant/jupyterlab-inline-complete.avif) - - -The service can sometimes take a few seconds to return a suggestion, you can see when the service is working by checking the status bar. - - -Jupyterlab also includes a traditional suggestion context menu. Use the `Tab` key to run and display the context menu. - -The context menu includes suggestions from JupyterLab in addition to suggestions made by Qiskit Code Assistant. The context menu also sanitizes and trims the suggestions, making it less useful for reviewing the code suggestion before inserting it. - -## Uninstall the JupyterLab extension - - -To remove the Qiskit Code Assistant extension from JupyterLab, run: - -```bash -pip uninstall qiskit_code_assistant_jupyterlab -``` - -## Troubleshooting - -If you see the frontend extension but it is not working, check that the server -extension is enabled: - -```bash -jupyter server extension list -``` - -If the server extension is installed and enabled, but you don't see the frontend -extension, check that the frontend extension is installed: - -```bash -jupyter labextension list -``` - - -## Contribute to the JupyterLab extension - -The code for this extension is publicly available and open source. Check it out in [GitHub](https://github.com/Qiskit/qiskit-code-assistant-jupyterlab). - -## Next steps - - -See examples to use Qiskit Code Assistant for [circuits](/docs/guides/circuit-library), [configuring error suppression](/docs/guides/error-mitigation-and-suppression-techniques), and [transpiling with pass managers](/docs/guides/transpile-with-pass-managers). - diff --git a/docs/guides/qiskit-code-assistant-openai-api.mdx b/docs/guides/qiskit-code-assistant-openai-api.mdx deleted file mode 100644 index a4ceff20200..00000000000 --- a/docs/guides/qiskit-code-assistant-openai-api.mdx +++ /dev/null @@ -1,114 +0,0 @@ ---- -title: Qiskit Code Assistant - OpenAI API compatibility -description: Learn how to integrate Qiskit Code Assistant with other applications through the OpenAI completions API. ---- - -{/* cspell:ignore Groq */} - - - - Qiskit Code Assistant's OpenAI API compatibility 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. - - -# Qiskit Code Assistant - OpenAI API compatibility - -Qiskit Code Assistant offers compatibility with a subset of the OpenAI API specification, specifically with the [completions](https://platform.openai.com/docs/api-reference/completions) and [chat/completions](https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create) API endpoints. The goal of this compatibility is to allow third-party packages to connect to Qiskit Code Assistant seamlessly by using well-known AI-related libraries and methods such as [OpenAI](https://github.com/openai/openai-python), [LiteLLM](https://github.com/BerriAI/litellm), or others. - -## OpenAI API endpoints supported - -| Method | Path | Comment | -|--|--|---| -| **GET** | `/v1/models` | List all models | -| **GET** | `/v1/models/{model}` | Get model detail | -| **POST** | `/v1/completions` | Send prompt to model for completion | -| **POST** | `/v1/chat/completions` | Send messages to model for completion | - - -The `/v1/completions` and `/v1/chat/completions` endpoints fails with a `403` error if the model disclaimer has been accepted. See the following for how to view and accept the model disclaimer. - - -Additional endpoints (not part of OpenAI schema, provided for convenience) include: - -| Method | Path | Comment | -|--|--|---| -| **GET** | `/v1/models/{model}/disclaimer` | Get model's disclaimer | -| **POST** | `/v1/models/{model}/disclaimer` | Accept model's disclaimer | -| **POST** | `/v1/completions/accept` | Accept or reject completion | - -To retrieve/view the model disclaimer, make a **GET** request to the disclaimer endpoint. For example: - -``` -curl -X 'GET' \ - 'https://qiskit-code-assistant.quantum.ibm.com/v1/models/mistral-small-3.2-24b-qiskit/disclaimer' \ - -H 'accept: application/json' \ - -H 'Authorization: Bearer ' -``` - -If you agree with the model disclaimer, to accept it, **POST** to the disclaimer endpoint providing the disclaimer's ID and whether it is accepted or rejected. For example: - -``` -curl -X 'POST' \ - 'https://qiskit-code-assistant.quantum.ibm.com/v1/models/mistral-small-3.2-24b-qiskit/disclaimer' \ - -H 'accept: application/json' \ - -H 'Authorization: Bearer ' \ - -H 'Content-Type: application/json' \ - -d '{ - "disclaimer": "", - "accepted": true -}' -``` - - -## Examples - -### Use the official OpenAI Python library - -The OpenAI Python library provides convenient access to the OpenAI REST API (such as the one provided by Qiskit Code Assistant) from any Python 3.8+ application. See more details in the [Installation section](https://github.com/openai/openai-python?tab=readme-ov-file#installation) of the OpenAI Python API library Readme. - - -``` -from openai import OpenAI - -# Initialize the client with your API token -client = OpenAI( - api_key="", - base_url="https://qiskit-code-assistant.quantum.ibm.com/v1", -) - -# Make a request to the completions API -try: - response = client.completions.create( - model="mistral-small-3.2-24b-qiskit", - prompt="#Transpile a random circuit using the Qiskit Transpiler Service", - ) - - # Print the generated text - print(response.choices[0].text) - -except Exception as e: - print(f"An error occurred: {e}") - -``` - -### Use LiteLLM - -LiteLLM is a convenient Python library to access multiple LLM APIs using the OpenAI format (Bedrock, Huggingface, VertexAI, TogetherAI, Azure, OpenAI, Groq, and so on). See the [LiteLLM docs](https://github.com/BerriAI/litellm?tab=readme-ov-file#usage-docs) for more details. - -``` -from litellm import completion - -response = completion( - model=f"text-completion-openai/mistral-small-3.2-24b-qiskit", - base_url="https://qiskit-code-assistant.quantum.ibm.com/v1", - messages=[ - { - "role": "user", - "content": "#Transpile a random circuit using the Qiskit Transpiler Service", - } - ], - api_key="", -) - -completion_response = response.json() -print(completion_response) -``` diff --git a/docs/guides/qiskit-code-assistant-vscode.mdx b/docs/guides/qiskit-code-assistant-vscode.mdx deleted file mode 100644 index f8054fc3d67..00000000000 --- a/docs/guides/qiskit-code-assistant-vscode.mdx +++ /dev/null @@ -1,115 +0,0 @@ ---- -title: Use Qiskit Code Assistant in VS Code -description: How to install, use, and configure Qiskit Code Assistant in Visual Studio Code (VS Code) and compatible editors. ---- - -# Use Qiskit Code Assistant in Visual Studio Code and compatible editors - -Learn how to install, use, configure, and uninstall the official Qiskit Code Assistant extension in Visual Studio Code (VS Code) and compatible editors. - - - - This is an experimental feature available to IBM Quantum® Premium Plan users with an account on the new [IBM Quantum Platform](https://quantum.cloud.ibm.com/). - - 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. - - - - -## Install the VS Code extension - -To install the [VS Code extension](https://github.com/Qiskit/qiskit-code-assistant-vscode), follow these steps: - -Install directly from VS Code: - -1. Launch VS Code. -1. Click the Extensions icon in the left toolbar. -1. Search for `qiskit` -1. Find "Qiskit Code Assistant (Beta)" and click **Install**. - -Alternatively, the extension is also available through the [VS Code Marketplace](https://marketplace.visualstudio.com/items?itemName=qiskit.qiskit-vscode). - -The extension is also published on [Open VSX](https://open-vsx.org/extension/qiskit/qiskit-vscode) for users of VS Code forks such as VSCodium, Cursor, IBM Bob, and others. - -The extension loads automatically and is listed on the bottom of the VS Code window. If it is not listed, reload the extension or application. - -## Configure extension settings - -The following settings can be configured: - -- To change keyboard shortcuts, open the Keyboard Shortcuts settings (`Cmd/Ctrl`+`Shift`+`P` -> `Preferences: Open Keyboard Shortcuts (JSON)`) and search for `qiskit-vscode`. - -- You can change the IBM Quantum API token to use in the VS Code command palette. To do that, type `Cmd/Ctrl`+`Shift`+`P`, search for `qiskit`, select the **Qiskit Code Assistant: Set IBM Quantum API token** command, and paste your IBM Quantum API token. - -- [Advanced] To change the instance of the Qiskit Code Assistant Service that the extension should use, go to File -> Preferences -> Settings. On the User tab, search for Qiskit, and edit the `Qiskit Code Assistant: Url`. - -## Get started using the Qiskit Code Assistant extension for VS Code - - -### Authentication and setup - - -After installing the extension, it tries to authenticate you. By default, the package tries to authenticate to IBM Quantum services with the defined API key, and uses your key from the `QISKIT_IBM_TOKEN` environment variable or from the file `~/.qiskit/qiskit-ibm.json` (under the section `default-ibm-quantum`). If you need help configuring your account, follow the instructions in [Set up to use IBM Cloud](/docs/guides/cloud-setup#cloud). - -By default, the extension uses the `mistral-small-3.2-24b-qiskit` model, which is listed in the Model Picker in the bottom status bar. - -The first time you use the `mistral-small-3.2-24b-qiskit` model, a modal opens listing some major restrictions that you should be aware of when using the model. Click **Accept** to enable the model for code generation. - -### Generate code - -While you develop your code using Qiskit, you can ask Qiskit Code Assistant to help you. In general, the Assistant suggests better code in response to Python comments or docstrings, but you can use the Assistant anywhere in your file. - -To get a code suggestion, type a prompt, then `Ctrl`+`.`. There are two types of prompts you can use: - - - Enter partial code and get a suggestion to finish the code. Example: - ```python - from qiskit.circuit import QuantumCircuit - from qiskit.transpiler import generate_preset_pass_manager - from qiskit_ibm_runtime import SamplerV2 as Sampler - from qiskit_ibm_runtime.fake_provider import FakeManilaV2 - - # Bell Circuit - qc = QuantumCircuit(2) - qc.h(0) - qc.cx(0, 1) - - qc.mea # Type Ctrl + . for a code suggestion. - ``` - - Type a pound (#) sign, then type your prompt. Example: `# Give me a random circuit of 5 qubits and a depth of 4.` - -![A code suggestion is shown, and is greyed out.](/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion.avif) - -### Work with code suggestions - -Use the following to accept, reject, and cycle through suggestions: - -- Press `Tab` to accept the suggestion or press `ESC` to reject it. -- After getting a suggestion, type `Ctrl` + `.` again to generate additional suggestions. -- When a suggestion is shown, use `Option/Alt` + `]` and `Option/Alt` + `[` to cycle forward and backward, respectively, through the suggestions (if available). -- Hover the cursor over the suggestion to use the pop-up toolbar to cycle through the suggestions, as shown: - ![The toolbar that pops up if you hover over suggested code is shown.](/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion-toolbar.avif) - -## Uninstall the VS Code extension - -To remove Qiskit Code Assistant from VS Code, follow these steps: - -1. Launch Visual Studio Code. -1. Click the Extensions icon. -1. Search for `qiskit` and open Qiskit Code Assistant. -1. Click **Uninstall**. - - -## Troubleshooting - -If you don't see the extension status bar in VS Code, check that the extension is installed and enabled under the extensions tab. - -If the extension is installed and enabled, but it cannot select a model, verify that your current API key has been added and the `Qiskit Code Assistant: Url` is properly set. - -## Contribute to the VS Code extension - -The code for this official extension is publicly available and open source. Check it out in [GitHub](https://github.com/Qiskit/qiskit-code-assistant-vscode). - -## Next steps - - -See examples to use Qiskit Code Assistant for [circuits](/docs/guides/circuit-library), [configuring error suppression](/docs/guides/error-mitigation-and-suppression-techniques), and [transpiling with pass managers](/docs/guides/transpile-with-pass-managers). - diff --git a/docs/guides/qiskit-code-assistant.mdx b/docs/guides/qiskit-code-assistant.mdx index fe86cc767e1..ee0a5044202 100644 --- a/docs/guides/qiskit-code-assistant.mdx +++ b/docs/guides/qiskit-code-assistant.mdx @@ -3,34 +3,18 @@ title: Qiskit Code Assistant description: Learn how to use Qiskit Code Assistant, a generative AI code assistant. --- -{/* cspell:ignore ollama, gguf, modelfile, safetensors, winget, MBPP */} +{/* cspell:ignore ollama, gguf, modelfile, safetensors, winget, MBPP, opencode */} # 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, 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 models](https://www.ibm.com/products/watsonx-ai/foundation-models), which incorporate the latest features and functionalities from IBM®. +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 trained using millions of text tokens from Qiskit SDK, 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 models](https://www.ibm.com/products/watsonx-ai/foundation-models), which incorporate the latest features and functionalities from IBM®. - - - This is an experimental feature available to IBM Quantum Premium Plan users registered on the new [IBM Quantum Platform](https://quantum.cloud.ibm.com/). - - Qiskit Code Assistant is in preview release status and is subject to change. +To skip to the installation instructions, go to the [Install Qiskit Code Assistant](#install) section. + + - 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. - - -## Features - -The following features are included in the [Visual Studio Code](https://code.visualstudio.com/) (VS Code) and compatible editors, as well as [JupyterLab](https://jupyterlab.readthedocs.io/en/latest/) extensions: - -* Accelerates Qiskit code generation by leveraging generative AI based on models specialized in generating Qiskit code. -* 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](/docs/guides/qiskit-code-assistant-jupyterlab) -- [VS Code](/docs/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 currently relies on the model `mistral-small-3.2-24b-qiskit`, built on the [Mistral-Small-3.2-24B-Qiskit model](https://huggingface.co/Qiskit/mistral-small-3.2-24b-qiskit). The `mistral-small-3.2-24b-qiskit` model improves the `Mistral-Small-3.2-24B-Instruct-2506` 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 Mistral AI models family, refer to [Mistral AI documentation](https://docs.mistral.ai/getting-started/models). For more details about the `.*-qiskit` models, see [Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code](https://arxiv.org/abs/2405.19495). @@ -46,77 +30,11 @@ The benchmarks are composed of approximately 150 tests, each one made from a fun The datasets for Qiskit HumanEval and Qiskit HumanEval Hard are available at these websites: [Qiskit HumanEval](https://huggingface.co/datasets/Qiskit/qiskit_humaneval) and [Qiskit HumanEval](https://huggingface.co/datasets/Qiskit/qiskit_humaneval_hard). You can contribute to the development of these benchmarks at the [GitHub repository](https://github.com/qiskit-community/qiskit-human-eval). - -## More information and citations - -To learn more about Qiskit Code Assistant, the Qiskit HumanEval, or Qiskit HumanEval Hard benchmarks, and cite them 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}, -} -``` - -``` -@misc{2508.20907, -Author = {Nicolas Dupuis and Adarsh Tiwari and Youssef Mroueh and David Kremer and Ismael Faro and Juan Cruz-Benito}, -Title = {Quantum Verifiable Rewards for Post-Training Qiskit Code Assistant}, -Year = {2025}, -Eprint = {arXiv:2508.20907}, -} -``` - -## Use Qiskit Code Assistant in local mode + +## Install Qiskit Code Assistant Learn how to install, configure, and use any of Qiskit Code Assistant models on your local machine. - - - 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. - - -### Quick start (recommended) - -The easiest way to get started with Qiskit Code Assistant in local mode is to use the automated setup scripts for either the VS Code or JupyterLab extension. These scripts will automatically install [Ollama](https://ollama.com/) to run the LLMs, download the recommended model, and configure the extension for you. - -#### VS Code extension setup - -Run the following command in your terminal: - -```bash -bash <(curl -fsSL https://raw.githubusercontent.com/Qiskit/qiskit-code-assistant-vscode/main/setup_local.sh) -``` - -This script performs the following steps: -- Install Ollama (if not already installed) -- Download and configure the recommended Qiskit Code Assistant model -- Set up the VS Code extension to work with your local deployment - -#### JupyterLab extension setup - -Run the following command in your terminal: - -```bash -bash <(curl -fsSL https://raw.githubusercontent.com/Qiskit/qiskit-code-assistant-jupyterlab/main/setup_local.sh) -``` - -This script will: -- Install Ollama (if not already installed) -- Download and configure the recommended Qiskit Code Assistant model -- Set up the JupyterLab extension to work with your local deployment - ### Available models #### Current models @@ -124,7 +42,7 @@ This script will: These are the latest recommended models for use with Qiskit Code Assistant: 1. [Qiskit/mistral-small-3.2-24b-qiskit](https://huggingface.co/Qiskit/mistral-small-3.2-24b-qiskit) - Released October 2025 -2. [qiskit/qwen2.5-coder-14b-qiskit](https://huggingface.co/Qiskit/qwen2.5-coder-14b-qiskit) - Released June 2025 +2. [Qiskit/Qwen2.5-Coder-14B-Qiskit](https://huggingface.co/Qiskit/Qwen2.5-Coder-14B-Qiskit) - Released June 2025 3. [qiskit/granite-3.3-8b-qiskit](https://huggingface.co/Qiskit/granite-3.3-8b-qiskit) - Released June 2025 4. [qiskit/granite-3.2-8b-qiskit](https://huggingface.co/Qiskit/granite-3.2-8b-qiskit) - Released June 2025 @@ -152,7 +70,7 @@ The Open Source Qiskit Code Assistant models are available in @@ -380,36 +297,171 @@ To ensure proper functionality of our Qiskit models, we recommend using the syst - + + +#### [Continue](https://marketplace.visualstudio.com/items?itemName=Continue.continue) (VS Code) -Use the VS Code extension and JupyterLab extension for the Qiskit Code Assistant to prompt the locally deployed Qiskit Code Assistant model. Once you have the Ollama application [set up with the model](#using-the-ollama-application), you can configure the extensions to connect to the local service. +##### 1. Install the extension +Open VS Code, go to Extensions (`Cmd+Shift+X`), search **Continue**, install it. -#### Connect with the Qiskit Code Assistant VS Code extension +##### 2. Open the config -With the Qiskit Code Assistant VS Code extension, you can interact with the model and perform code completion while writing your code. This can work well for users looking for assistance writing Qiskit code for their Python applications. +Click the Continue icon in the sidebar, then click the gear icon, or open the command palette (`Cmd+Shift+P`) and run **Continue: Open Config File**. -1. Install the [Qiskit Code Assistant VS Code extension](/docs/guides/qiskit-code-assistant-vscode). -1. In VS Code, go to the **User Settings** and set the **Qiskit Code Assistant: Url** to the URL of your local Ollama deployment (for example, `http://localhost:11434`). -1. Reload VS Code by going to **View > Command Palette...** and selecting **Developer: Reload Window**. +This opens `~/.continue/config.yaml` (or `config.json` in older versions). -The Qiskit Code Assistant model configured in Ollama should appear in the status bar and is then ready to use. +##### 3. Configure the model -#### Connect with the Qiskit Code Assistant JupyterLab extension +Add the following to `config.yaml`: -With the Qiskit Code Assistant JupyterLab extension, you can interact with the model and perform code completion directly in your Jupyter Notebook. Users who predominantly work with Jupyter Notebooks can take advantage of this extension to further enhance their experience writing Qiskit code. +```yaml +models: + - name: Qiskit Code Assistant + provider: ollama + model: mistral-small-3.2-24b-qiskit + apiBase: http://localhost:11434 +``` -1. Install the [Qiskit Code Assistant JupyterLab extension](/docs/guides/qiskit-code-assistant-jupyterlab). -1. In JupyterLab, go to the **Settings Editor** and set the **Qiskit Code Assistant Service API** to the URL of your local Ollama deployment (for example, `http://localhost:11434`). +This makes the Qiskit model available in the **chat panel** (sidebar conversations, inline Q&A) and for **inline edit** commands. -The Qiskit Code Assistant model configured in Ollama should appear in the status bar and is then ready to use. +##### 4. Test it +- **Chat:** Open the Continue panel in the sidebar and ask a question (e.g., "How do I create a parameterized circuit in Qiskit?") +- **Inline edit:** Select a block of code, press `Cmd+I` (Mac) or `Ctrl+I` (Linux/Windows) + + + + + + + + + +#### [Jupyter AI](https://jupyter-ai.readthedocs.io/en/v3/index.html) (JupyterLab) + +**Note:** These instructions cover Jupyter AI v2.x. + +##### 1. Install Jupyter AI and the Ollama provider + +```bash +pip install "jupyter-ai<3" langchain-ollama +``` + +The `"jupyter-ai<3"` pin ensures you get v2.x. The `langchain-ollama` package is required for Jupyter AI to detect Ollama as a provider. Without it, Ollama will not appear in the settings panel. + +Then restart JupyterLab. + +##### 2. Configure the chat model + +Open JupyterLab and click the **chat icon** in the left sidebar. In the settings panel: + +1. Under **Language model**, select **Ollama** as the provider. +2. Enter `mistral-small-3.2-24b-qiskit` as the model name. +3. No API key is needed for Ollama (leave the field empty). +4. Click the back arrow to start chatting. + +##### 3. Use the `%%ai` magic command + +The `%%ai` magic lets you query the model directly in notebook cells. + +```python +%load_ext jupyter_ai_magics +``` + +Then in a cell: + +```python +%%ai ollama:mistral-small-3.2-24b-qiskit +Write a function that implements Grover's algorithm using Qiskit +``` + +##### 4. Custom Ollama host (optional) + +By default, Jupyter AI connects to `http://127.0.0.1:11434`. If your Ollama server runs on a different address or port: + +**In the chat UI:** Set the "Base API URL" field in the AI settings panel. + + + + + +#### [OpenCode](https://opencode.ai/) (Terminal) + +##### 1. Install OpenCode + +```bash +curl -fsSL https://opencode.ai/install | bash +``` + +##### 2. Configure the Qiskit model + +Create an `opencode.json` file in your project root (or `~/.config/opencode/opencode.json` for a global config): + +```json +{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "name": "Ollama (local)", + "options": { + "baseURL": "http://localhost:11434/v1" + }, + "models": { + "mistral-small-3.2-24b-qiskit": { + "name": "Qiskit Code Assistant" + } + } + } + } +} +``` + +##### 3. Select the model + +Launch OpenCode in your project directory: + +```bash +opencode +``` + +Inside the TUI, run the `/models` command and select **Qiskit Code Assistant** from the list. + +##### 4. Test it + +Ask a question directly in the chat, for example: "Define a Bell circuit and run it using QiskitRuntimeService" + -## Next steps +## More information and citations - - - Install and use the official [JupyterLab](/docs/guides/qiskit-code-assistant-jupyterlab) or [VS Code](/docs/guides/qiskit-code-assistant-vscode) extensions. - - See examples to use Qiskit Code Assistant for [circuits](/docs/guides/circuit-library), [configuring error suppression](/docs/guides/error-mitigation-and-suppression-techniques), and [transpiling with pass managers](/docs/guides/transpile-with-pass-managers). - +To learn more about Qiskit Code Assistant, the Qiskit HumanEval, or Qiskit HumanEval Hard benchmarks, and cite them 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}, +} +``` + +``` +@misc{2508.20907, +Author = {Nicolas Dupuis and Adarsh Tiwari and Youssef Mroueh and David Kremer and Ismael Faro and Juan Cruz-Benito}, +Title = {Quantum Verifiable Rewards for Post-Training Qiskit Code Assistant}, +Year = {2025}, +Eprint = {arXiv:2508.20907}, +} +``` diff --git a/docs/guides/qiskit-mcp-servers.mdx b/docs/guides/qiskit-mcp-servers.mdx index b240646293d..f52d0fc903f 100644 --- a/docs/guides/qiskit-mcp-servers.mdx +++ b/docs/guides/qiskit-mcp-servers.mdx @@ -37,8 +37,6 @@ Provides core quantum computing capabilities for local development. This server Provides intelligent quantum code completion and assistance through the [Qiskit Code Assistant](/docs/guides/qiskit-code-assistant). This server integrates the Qiskit Code Assistant capabilities directly into MCP-compatible AI tools. -As with any other feature from Qiskit Code Assistant, this MCP server only works for IBM Quantum Premium Plan users registered on [IBM Quantum Platform](https://quantum.cloud.ibm.com/). - ### Qiskit Runtime MCP Server Provides access to IBM Quantum cloud services through Qiskit Runtime. This enables AI assistants to interact with quantum backends, submit jobs, and retrieve results. diff --git a/docs/guides/sampler-noise-management.ipynb b/docs/guides/sampler-noise-management.ipynb index 7cd773b8e41..ffa148bf268 100644 --- a/docs/guides/sampler-noise-management.ipynb +++ b/docs/guides/sampler-noise-management.ipynb @@ -105,13 +105,6 @@ "id": "db285d76-0e96-4ae4-a65c-3fdae1407bee", "metadata": {}, "source": [ - "\n", - "\n", "## Next steps\n", "\n", "\n", diff --git a/docs/guides/save-jobs.ipynb b/docs/guides/save-jobs.ipynb index 395869b390b..aa3ad3db862 100644 --- a/docs/guides/save-jobs.ipynb +++ b/docs/guides/save-jobs.ipynb @@ -153,19 +153,6 @@ "retrieved_job.result()" ] }, - { - "cell_type": "markdown", - "id": "1163070d-7f16-42dc-9951-4cbff79cabf6", - "metadata": {}, - "source": [ - "" - ] - }, { "cell_type": "markdown", "id": "f3bccdba-29c5-405b-96e2-65f4fe4ffadd", diff --git a/docs/guides/transpile-with-pass-managers.ipynb b/docs/guides/transpile-with-pass-managers.ipynb index f045feb3a38..d4cc3914399 100644 --- a/docs/guides/transpile-with-pass-managers.ipynb +++ b/docs/guides/transpile-with-pass-managers.ipynb @@ -146,15 +146,6 @@ "source": [ "See [Transpilation defaults and configuration options](defaults-and-configuration-options) for a description of the possible arguments to the `generate_preset_pass_manager` function. The arguments to `generate_preset_pass_manager` match the arguments to the [`transpile`](/docs/api/qiskit/compiler#qiskit.compiler.transpile) function.\n", "\n", - "\n", - "\n", - "\n", "If the preset pass managers don't fulfill your needs, customize transpilation by creating (staged) pass managers or even transpilation passes. The rest of this page describes how to create pass managers. For instructions on how to create transpilation passes, see [Write your own transpiler pass](custom-transpiler-pass)." ] }, diff --git a/mdx-guide.md b/mdx-guide.md index db67bfa524f..d1ce4473b24 100644 --- a/mdx-guide.md +++ b/mdx-guide.md @@ -184,19 +184,6 @@ By default, the title is the `type` capitalized. You can customize it by setting ``` -We also have a specialized admonition for Qiskit Code Assistant prompt suggestions. Warning: avoid a trailing comma on the last entry in `prompts`! - -```mdx - -``` - ### Accordions Sometimes called "twisties", accordions contain hidden content that is uncovered when a user clicks them. There are two parts to this component: diff --git a/public/docs/images/guides/qiskit-code-assistant/jupyterlab-inline-complete.avif b/public/docs/images/guides/qiskit-code-assistant/jupyterlab-inline-complete.avif deleted file mode 100644 index 090de90d25a..00000000000 Binary files a/public/docs/images/guides/qiskit-code-assistant/jupyterlab-inline-complete.avif and /dev/null differ diff --git a/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion-toolbar.avif b/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion-toolbar.avif deleted file mode 100644 index 5c98df02ee6..00000000000 Binary files a/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion-toolbar.avif and /dev/null differ diff --git a/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion.avif b/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion.avif deleted file mode 100644 index 2e4b2ebd991..00000000000 Binary files a/public/docs/images/guides/qiskit-code-assistant/vscode-inline-suggestion.avif and /dev/null differ diff --git a/qiskit_bot.yaml b/qiskit_bot.yaml index e8512e14205..1a14834f56a 100644 --- a/qiskit_bot.yaml +++ b/qiskit_bot.yaml @@ -423,14 +423,6 @@ notifications: - "cbjuan" - "`@abbycross`" - "`@beckykd`" - "docs/guides/qiskit-code-assistant-jupyterlab": - - "cbjuan" - - "`@abbycross`" - - "`@beckykd`" - "docs/guides/qiskit-code-assistant-vscode": - - "cbjuan" - - "`@abbycross`" - - "`@beckykd`" "docs/guides/qasm-feature-table": - "@taalexander" - "`@kitbarton`" @@ -651,8 +643,6 @@ notifications: - "@kaelynj" "docs/guides/qiskit-addons-sqd-get-started": - "@kaelynj" - "docs/guides/qiskit-code-assistant-openai-api": - - "@cbjuan" "docs/guides/qiskit-function-templates": - "@kaelynj" "docs/guides/function-template-chemistry-workflow":