Qiskit Code Assistant
Qiskit Code Assistant прагне зробити квантові обчислення доступнішими для нових користувачів Qiskit і покращити досвід написання коду для поточних користувачів. Це генеративний AI-асистент для написання коду, побудований на основі watsonx. Він навчений на мільйонах текстових токенів з Qiskit SDK, роках прикладів коду Qiskit та можливостей IBM Quantum®. Qiskit Code Assistant може допомогти у твоєму робочому процесі квантової розробки, пропонуючи підказки, згенеровані LLM на основі моделей IBM Granite, які включають найновіші функції та можливості від IBM®.
- Це експериментальна функція, доступна для користувачів IBM Quantum Premium Plan, зареєстрованих на новій IBM Quantum Platform.
- Qiskit Code Assistant перебуває у статусі попереднього випуску і може змінюватися.
- Якщо ти маєш відгуки або хочеш зв'язатися з командою розробників, скористайся каналом Qiskit Slack Workspace або відповідними публічними репозиторіями GitHub.
Функції
Такі функції включено до розширень для Visual Studio Code (VS Code) і сумісних редакторів, а також для JupyterLab:
- Прискорює генерацію коду Qiskit завдяки генеративному AI на основі моделей, спеціалізованих на генерації коду Qiskit.
- Дозволяє використовувати абстрактні та конкретні запити для генерації рекомендацій.
- Надає підказки, які ти можеш переглянути, прийняти або відхилити.
- Підтримує ф айли Python і Jupyter notebook.
- Включає захисні механізми для уникнення відповідей на питання, що становлять потенційний ризик для користувачів, наприклад мова ненависті.
Для отримання інструкцій з інтеграції Qiskit Code Assistant безпосередньо у своє середовище розробки дотримуйся інструкцій у відповідній темі:
Велика мовна модель (LLM), що стоїть за Qiskit Code Assistant
Для надання підказок коду Qiskit Code Assistant використовує велику мовну модель (LLM). У цьому випадку Qiskit Code Assistant наразі покладається на модель mistral-small-3.2-24b-qiskit, побудовану на основі моделі Mistral-Small-3.2-24B-Qiskit. Модель mistral-small-3.2-24b-qiskit покращує можливості генерації коду моделі Mistral-Small-3.2-24B-Instruct-2506 для Qiskit завдяки розширеному попередньому навчанню та тонкому налаштуванню на якісних даних Qiskit, а також комітах Python і чатах. Для отримання додаткової інформації про сімейство моделей Mistral AI зверни увагу на документацію Mistral AI. Для отримання більше деталей про моделі .*-qiskit дивись Qiskit Code Assistant: Training LLMs for generating Quantum Computing Code.
Наші LLM, спеціалізовані для Qiskit, також доступні як моделі з відкритим кодом. Переглянь всі доступні моделі на https://huggingface.co/Qiskit.
Бенчмарки Qiskit HumanEval і Qiskit HumanEval Hard
Щоб протестувати mistral-small-3.2-24b-qiskit та інші моделі, ми співпрацювали з адвокатами та експертами Qiskit для створення бенчмарків на основі виконання коду, що називаються Qiskit HumanEval (QHE) і Qiskit HumanEval Hard (QHE Hard), та запустили їх на мо делях. Ці бенчмарки схожі на HumanEval і містять кілька складних завдань з програмування, всі засновані на офіційних бібліотеках Qiskit.
Бенчмарки складаються приблизно з 150 тестів, кожен з яких побудований із визначення функції, за яким іде рядок документації, що детально описує завдання, яке модель має вирішити. Кожен приклад також включає еталонне канонічне рішення та модульні тести для оцінки правильності згенерованих рішень. Є три рівні складності тестів: базовий, середній і складний. Бенчмарк Qiskit HumanEval Hard є варіацією Qiskit HumanEval, але без інформації про імпорт коду, тому LLM потрібно самостійно визначати правильні імпорти методів або класів. Ця зміна робить датасет значно складнішим для LLM, згідно з нашими тестами та початковими результатами.
Датасети Qiskit HumanEval і Qiskit HumanEval Hard доступні на цих сайтах: Qiskit HumanEval і Qiskit HumanEval Hard. Ти можеш зробити внесок у розробку цих бенчмарків у репозиторії GitHub.
Додаткова інформація та цитування
Щоб дізнатися більше про Qiskit Code Assistant, бенчмарки Qiskit HumanEval або Qiskit HumanEval Hard і процитувати їх у наукових публікаціях, ознайомся з рекомендованими цитатами:
@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},
}
Використання Qiskit Code Assistant у локальному режимі
Дізнайся, як встановити, налаштувати та використовувати будь-яку з моделей Qiskit Code Assistant на своєму локальному комп'ютері.
- Qiskit Code Assistant перебуває у статусі попереднього випуску і може змінюватися.
- Якщо ти маєш відгуки або хочеш зв'язатися з командою розробників, скористайся каналом Qiskit Slack Workspace або відповідними публічними репозиторіями GitHub.
Швидкий старт (рекомендовано)
Найпростіший спосіб почати роботу з Qiskit Code Assistant у локальному режимі — скористатися автоматизованими скриптами налаштування для розширень VS Code або JupyterLab. Ці скрипти автоматично встановлять Ollama для запуску LLM, завантажать рекомендовану модель і налаштують розширення.
Налаштування розширення VS Code
Виконай наступну команду у терміналі:
bash <(curl -fsSL https://raw.githubusercontent.com/Qiskit/qiskit-code-assistant-vscode/main/setup_local.sh)
Цей скрипт виконує такі кроки:
- Встановлює Ollama (якщо ще не встановлено)
- Завантажує та налаштовує рекомендовану модель Qiskit Code Assistant
- Налаштовує розширення VS Code для роботи з твоїм локальним розгортанням
Налаштування розширення JupyterLab
Виконай наступну команду у терміналі:
bash <(curl -fsSL https://raw.githubusercontent.com/Qiskit/qiskit-code-assistant-jupyterlab/main/setup_local.sh)
Цей скрипт:
- Встановлює Ollama (якщо ще не встановлено)
- Завантажує та налаштовує рекомендовану модель Qiskit Code Assistant
- Налаштовує розширення JupyterLab для роботи з твоїм локальним розгортанням
Доступні моделі
Поточні моделі
Це найновіші рекомендовані моделі для використання з Qiskit Code Assistant:
- Qiskit/mistral-small-3.2-24b-qiskit - Released October 2025
- qiskit/qwen2.5-coder-14b-qiskit - Released June 2025
- qiskit/granite-3.3-8b-qiskit - Released June 2025
- qiskit/granite-3.2-8b-qiskit - Released June 2025
Моделі GGUF (рекомендовано для особистих середовищ/ноутбуків)
Моделі у форматі GGUF оптимізовані для локального використання та потребують менше обчислювальних ресурсів:
-
mistral-small-3.2-24b-qiskit-GGUF – Released October 2025
Trained with Qiskit data up to version 2.1 -
qiskit/qwen2.5-coder-14b-qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0 -
qiskit/granite-3.3-8b-qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0 -
qiskit/granite-3.2-8b-qiskit-GGUF – Released June 2025
Trained with Qiskit data up to version 2.0
Моделі Qiskit Code Assistant з відкритим кодом доступні у форматі safetensors або GGUF file format та можуть бути завантажені з Hugging Face, як описано нижче.
Версії Qiskit, використані для навчання
| Model | Benchmark Metrics | Release date | Trained on Qiskit version | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| QiskitHumanEval-Hard | QiskitHumanEval | HumanEval | ASDiv | MathQA | SciQ | MBPP | IFEval | CrowsPairs (English) | TruthfulQA (MC1 acc) | |||
| mistral-small-3.2-24b-qiskit | 32.45 | 47.02 | 77.49 | 3.77 | 49.68 | 97.50 | 64.00 | 48.44 | 67.08 | 39.41 | January 2026 | 2.2 |
| qwen2.5-coder-14b-qiskit | 25.17 | 49.01 | 91.46 | 4.21 | 53.90 | 97.00 | 77.60 | 49.64 | 65.18 | 37.82 | June 2025 | 2.0 |
| granite-3.3-8b-qiskit | 14.57 | 27.15 | 62.80 | 0.48 | 38.66 | 93.30 | 52.40 | 59.71 | 59.75 | 39.05 | June 2025 | 2.0 |
| granite-3.2-8b-qiskit | 9.93 | 24.50 | 57.32 | 0.09 | 41.41 | 96.30 | 51.80 | 60.79 | 66.79 | 40.51 | June 2025 | 2.0 |
| granite-8b-qiskit-rc-0.10 | 15.89 | 38.41 | 59.76 | — | — | — | — | — | — | — | February 2025 | 1.3 |
| granite-8b-qiskit | 17.88 | 44.37 | 53.66 | — | — | — | — | — | — | — | November 2024 | 1.2 |
Примітка: Усі моделі, перелічені у таблиці бенчмарків, оцінювалися з використанням відповідного системного промпту, визначеного у їхній моделі на Hugging Face.
Застарілі моделі
Ці моделі більше не підтримуються активно, але залишаються доступними:
- qiskit/granite-8b-qiskit-rc-0.10 - Released February 2025 (deprecated)
- qiskit/granite-8b-qiskit - Released November 2024 (deprecated)
Розширене налаштування
Якщо ти хочеш налаштувати локальне середовище вручну або потребуєш більшого контролю над процесом інсталяції, розгорни розділи нижче.
Download from the Hugging Face website
Follow these steps to download any Qiskit Code Assistant-related model from the Hugging Face website:
- Navigate to the desired Qiskit model page on Hugging Face.
- Go to the Files and Versions tab and download the safetensors or GGUF model files.
Download using the Hugging Face CLI
To download any of the available Qiskit Code Assistant models using the Hugging Face CLI, follow these steps:
-
Install the Hugging Face CLI
-
Log in to your Hugging Face account
huggingface-cli login -
Download the model you prefer from the previous list
huggingface-cli download <HF REPO NAME> <MODEL PATH> --local-dir <LOCAL PATH>
Manually deploy the Qiskit Code Assistant models in local through Ollama
There are multiple ways to deploy and interact with the downloaded Qiskit Code Assistant model. This guide demonstrates using Ollama as follows: either with the Ollama application by using the Hugging Face Hub integration or local model, or with the llama-cpp-python package.
Using the Ollama application
The Ollama application provides a simple solution to run the LLMs locally. It is easy to use, with a CLI that makes the whole setup process, model management, and interaction fairly straightforward. It's ideal for quick experimentation and for users that want fewer technical details to handle.
Install Ollama
-
Download the Ollama application
-
Install the downloaded file
-
Launch the installed Ollama application
інформаціяThe application is running successfully when the Ollama icon appears in the desktop menu bar. You can also verify the service is running by going to
http://localhost:11434/. -
Try Ollama in your terminal and start running models. For example:
ollama run hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit
Set up Ollama using the Hugging Face Hub integration
The Ollama/Hugging Face Hub integration provides a way to interact with models hosted on the Hugging Face Hub without needing to create a new modelfile nor manually downloading the GGUF or safetensors files. The default template and params files are already included for the model on the Hugging Face Hub.
-
Make sure the Ollama application is running.
-
Go the desired model page, and copy the URL. For example, https://huggingface.co/Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF.
-
From your terminal, run the command:
ollama run hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit
You can use the hf.co/Qiskit/Qwen2.5-Coder-14B-Qiskit model or any of the other currently recommended GGUF official models hf.co/Qiskit/mistral-small-3.2-24b-qiskit-GGUF or hf.co/Qiskit/granite-3.3-8b-qiskit-GGUF.
Set up Ollama with a manually downloaded Qiskit Code Assistant GGUF model
If you have manually downloaded a GGUF model such as https://huggingface.co/Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF and you want to experiment with different templates and parameters, you can follow these steps to load it into your local Ollama application.
-
Create a
Modelfileentering the following content and be sure to update<PATH-TO-GGUF-FILE>to the actual path of your downloaded model.FROM <PATH-TO-GGUF-FILE>
TEMPLATE """{{ if .System }}
System:
{{ .System }}
{{ end }}{{ if .Prompt }}Question:
{{ .Prompt }}
{{ end }}Answer:
```python{{ .Response }}
"""
PARAMETER stop "Question:"
PARAMETER stop "Answer:"
PARAMETER stop "System:"
PARAMETER stop "```"
PARAMETER temperature 0
PARAMETER top_k 1 -
Run the following command to create a custom model instance based on the
Modelfile.ollama create Qwen2.5-Coder-14B-Qiskit -f ./path-to-model-fileприміткаThis process may take some time for Ollama to read the model file, initialize the model instance, and configure it according to the specifications provided.
Run the Qiskit Code Assistant model manually downloaded in Ollama
After the Qwen2.5-Coder-14B-Qiskit model has been set up in Ollama, run the following command to launch the model and interact with it in the terminal (in chat mode).
ollama run Qwen2.5-Coder-14B-Qiskit
Some useful commands:
ollama list- List models on your computerollama rm Qwen2.5-Coder-14B-Qiskit- Delete the modelollama show Qwen2.5-Coder-14B-Qiskit- Show model informationollama stop Qwen2.5-Coder-14B-Qiskit- Stop a model that is currently runningollama ps- List which models are currently loaded
Manually deploy the Qiskit Code Assistant models in local through the llama-cpp-python package
An alternative to the Ollama application is the llama-cpp-python package, which is a Python binding for llama.cpp. It gives you more control and flexibility to run the GGUF model locally, and is ideal for users who wish to integrate the local model in their workflows and Python applications.
- Install
llama-cpp-python - Interact with the model from within your application using
llama_cpp. For example:
from llama_cpp import Llama
model_path = <PATH-TO-GGUF-FILE>
model = Llama(
model_path,
seed=17,
n_ctx=10000,
n_gpu_layers=37, # to offload in gpu, but put 0 if all in cpu
)
input = 'Generate a quantum circuit with 2 qubits'
raw_pred = model(input)["choices"][0]["text"]
You can also add text generation parameters to the model to customize the inference:
generation_kwargs = {
"max_tokens": 512,
"echo": False, # Echo the prompt in the output
"top_k": 1
}
raw_pred = model(input, **generation_kwargs)["choices"][0]["text"]
Manually deploy the Qiskit Code Assistant models in local through llama.cpp
Use the llama.cpp library
Another alternative is to use llama.cpp, an open-source library for performing LLM inference on a CPU with minimal setup.
It provides low-level control over the model execution and is typically run from the command line, pointing to a local GGUF model file.
There are several ways to install llama.cpp on your machine:
- Install llama.cpp using brew, nix, or winget
- Run with Docker: See out the Docker documentation by
llama.cppteam - Download pre-built binaries from the releases page
- Build from source by cloning this repository
Once installed, you can use llama.cpp to interact with GGUF models in conversation mode as follows:
# Use a local model file
llama-cli -m my_model.gguf -cnv
# Or download and run a model directly from Hugging Face
llama-cli -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF -cnv
You can also launch an OpenAI-compatible API server for the model in the following way:
llama-server -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF
Advanced parameters
With the llama-cli program, you can control the model generation using command-line options. For example, you can provide an initial “system” prompt using the -p/--prompt flag. In conversation mode (-cnv), this initial prompt acts as the system message. Otherwise, you can simply prepend any desired instruction to your prompt text. You can also adjust sampling parameters - for instance: temperature (--temp), top-k (--top-k), top-p (--top-p), repetition penalty (--repeat-penalty), and the seed to use (--seed). The following is an example invocation using these options:
llama-cli -hf Qiskit/Qwen2.5-Coder-14B-Qiskit-GGUF \
-p "You are a friendly assistant." -cnv \
--temp 0.7 \
--top-k 50 \
--top-p 0.95 \
--repeat-penalty 1.1 \
--seed 42
To ensure proper functionality of our Qiskit models, we recommend using the system prompt provided in our HF GGUF repositories: system prompt for mistral-small-3.2-24b-qiskit-GGUF, Qwen2.5-Coder-14B-Qiskit-GGUF, granite-3.3-8b-qiskit-GGUF, and granite-3.2-8b-qiskit-GGUF.
Manually connect extensions to local deployment
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, you can configure the extensions to connect to the local service.
Connect with the Qiskit Code Assistant VS Code extension
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.
- Install the Qiskit Code Assistant VS Code extension.
- 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). - Reload VS Code by going to View > Command Palette... and selecting Developer: Reload Window.
The Qiskit Code Assistant model configured in Ollama should appear in the status bar and is then ready to use.
Connect with the Qiskit Code Assistant JupyterLab extension
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.
- Install the Qiskit Code Assistant JupyterLab extension.
- 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).
The Qiskit Code Assistant model configured in Ollama should appear in the status bar and is then ready to use.
Наступні кроки
- Встанови та використовуй офіційне розширення для JupyterLab або VS Code.
- Дивись приклади використання Qiskit Code Assistant для схем, налаштування придушення помилок і транспіляції з менеджерами проходів.