Agent skill

Mindquantum

by mindspore-ai in mindspore-ai/mindquantum

Build, simulate, and analyze quantum circuits with MindQuantum.

Apache-2.0Auto-check passedResearch & Science

Install Mindquantum

skills CLI
$ npx skills add mindspore-ai/mindquantum --skill mindquantum -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mindspore-ai/mindquantum mindquantum --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mindspore-ai/mindquantum.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/mindquantum .claude/skills/mindquantum && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
mindquantum
GitHub stars
101
Token cost
~2.3k tokens
SKILL.md length
698 words
Files
6
Skills in repo
6
Repo updated
First seen
Licence
Apache-2.0

At a glance

Build, simulate, and analyze quantum circuits with MindQuantum.

  • Works in 6 steps: Endianness: MindQuantum uses… → get_expectation_with_grad requires… → MindSpore context: mindquantum.framework… → …
  • Code imports mindquantum
  • SKILL.md covers Environment Setup, Quick Start Pattern, Module Map and Simulator Backends, plus 4 more sections
  • Calls pip and python

What it does

Mindquantum is an agent skill from mindspore-ai/mindquantum. Build, simulate, and analyze quantum circuits with MindQuantum. Provides API patterns, simulator selection, circuit construction, operator algebra, and common pitfalls. Use whenever code imports mindquantum, the user mentions MindQuantum, quantum circuits in Python with MindSpore, or asks about quantum simulation, parameterized quantum circuits, quantum gates, Hamiltonians, or quantum computing in the MindQuantum/MindSpore ecosystem.

Its SKILL.md is about 2.3k tokens, which your agent loads only when the skill is triggered. The skill folder holds 6 other files (for example `reference/circuit-and-gates.md`, `reference/io-and-visualization.md` and `reference/operators-hamiltonian.md`).

It sits in Research & Science, covering Quantum computing. It works with Python and CUDA. The repository describes itself as: MindQuantum is a quantum machine learning library that can be used to build and train different quantum neural networks. The licence is Apache-2.0.

When your agent uses it

  • Code imports mindquantum
  • The user mentions MindQuantum
  • Quantum circuits in Python with MindSpore
  • Asks about quantum simulation

Example prompts

  • “/mindquantum”

Requirements

  • Python 3

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Endianness: MindQuantum uses little-endian — qubit 0 is the rightmost (least significant) bit in state vectors and measurement results.
  2. get_expectation_with_grad requires encoder+ansatz split: If your circuit has no as_encoder() call, all params are treated as ansatz…
  3. MindSpore context: mindquantum.framework operations are documented as PYNATIVE_MODE only. Use ms.set_device("CPU") with…
  4. Simulator state persistence: apply_circuit and apply_gate modify the simulator state. Use sim.reset() to return to |0⟩. sampling does not…
  5. Noise via Monte Carlo: When using noise channels with mqvector, each call to sampling runs Monte Carlo trajectories. Results are…
  6. UN requires a list: UN(H, 5) is wrong — use UN(H, range(5)) or UN(H, [0,1,2,3,4]).

What it can do on your machine

Read from SKILL.md and the folder at commit 2a0ca08. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • pip
    • python

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Mindquantum loads about 2.3k tokens when it runs. Until then it costs about 112 tokens; SKILL.md has 698 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~112
When it runs · the whole SKILL.md, loaded when a task matches
~2.3k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mindspore-ai/mindquantum at commit 2a0ca08, republished under its Apache-2.0 licence (© mindspore-ai). 698 words, ~2,279 tokens.

Download SKILL.mdSave it as .claude/skills/mindquantum/SKILL.md (or your agent's skills folder). This skill also uses 5 other files; get the full folder from GitHub.
name
mindquantum
description
Build, simulate, and analyze quantum circuits with MindQuantum. Provides API patterns, simulator selection, circuit construction, operator algebra, and common pitfalls. Use whenever code imports mindquantum, the user mentions MindQuantum, quantum circuits in Python with MindSpore, or asks about quantum simulation, parameterized quantum circuits, quantum gates, Hamiltonians, or quantum computing in the MindQuantum/MindSpore ecosystem.

MindQuantum — Core API Skill

MindQuantum is a quantum computing framework in the MindSpore ecosystem. Its core circuit, operator, and simulator APIs can be used without MindSpore; the mindquantum.framework module provides MindSpore integration for hybrid quantum-classical models.

Environment Setup

Before writing any MindQuantum code, check whether MindQuantum is installed. If the user hits ModuleNotFoundError: No module named 'mindquantum' or asks to set up their environment, follow this guide.

Check Installation
bash
python -c "import mindquantum; print(mindquantum.__version__)"
Install MindQuantum
bash
# Python 3.9-3.12 is required by this package.
pip install mindquantum

MindQuantum's core (circuits, gates, operators, simulators) works standalone — no MindSpore required. MindSpore is only needed for the mindquantum.framework module (MQLayer, hybrid training).

Optional Dependencies
PackageWhen NeededInstall
MindSporeMQLayer hybrid quantum-classical trainingpip install mindspore
OpenFermion + PySCFQuantum chemistry (generate_uccsd, molecular data)pip install openfermion openfermionpyscf
PyTorch + CUDAQAIA gpu-float32 backendpip install torch (with CUDA)
torch-npuQAIA npu-float32 backendFollow the torch-npu installation matching the Ascend environment
Verify Installation
python
# Minimal verification
import mindquantum as mq
from mindquantum.core.circuit import Circuit
from mindquantum.core.gates import H, CNOT
from mindquantum.simulator import Simulator

circ = Circuit().h(0).x(1, 0)
sim = Simulator("mqvector", 2)
sim.apply_circuit(circ)
print(sim.get_qs(ket=True))
# Expected: √2/2¦00⟩ + √2/2¦11⟩
Backend Availability

Use get_supported_simulator() to check the backends available in the current installation. GPU state-vector backends only appear when the package is built with the required NVIDIA CUDA support; mqvector_cq additionally requires NVIDIA cuQuantum SDK support.

For source builds, follow the repository build scripts and options rather than assuming a platform-specific backend is present.

Quick Start Pattern

python
from mindquantum.core.circuit import Circuit
from mindquantum.core.gates import H, RX, RY, CNOT, Measure
from mindquantum.core.operators import QubitOperator, Hamiltonian
from mindquantum.simulator import Simulator

# Build circuit
circ = Circuit()
circ += H.on(0)
circ += CNOT.on(1, 0)  # target=1, control=0
circ += RX("theta").on(0)  # parameterized gate

# Simulate
sim = Simulator("mqvector", 2)
sim.apply_circuit(circ, pr={"theta": 0.5})
print(sim.get_qs(ket=True))

# Sample
circ += Measure().on(0)
circ += Measure().on(1)
sim.reset()
result = sim.sampling(circ, pr={"theta": 0.5}, shots=1000)

Module Map

ModulePurposeKey Classes
core.circuitCircuit constructionCircuit, UN, apply, dagger
core.gates50+ quantum gatesH, X, RX, RY, RZ, CNOT, SWAP, U3, FSim, Measure
core.operatorsOperator algebraQubitOperator, FermionOperator, Hamiltonian, TimeEvolution
core.parameterresolverSymbolic parametersParameterResolver
simulatorSimulation backendsSimulator, get_supported_simulator()
algorithm.nisqNISQ ansatz catalogHardwareEfficientAnsatz, UCCAnsatz, QAOAAnsatz, StronglyEntangling
algorithm.compilerCircuit decomposition / DAG toolsDAGCircuit, decompose submodule, compiler rules
algorithm.mappingQubit mappingSABRE, MQSABRE
algorithm.libraryCircuit/state helpersqft, general_ghz_state, general_w_state
algorithm.qaiaQuantum-inspired optimizationSimCIM, ASB, BSB, DSB, LQA
frameworkMindSpore integrationMQLayer, MQAnsatzOnlyLayer, MQN2Ops
ioImport/exportOpenQASM, HiQASM, QCIS

Simulator Backends

BackendState representationMemory scalingSource-documented notes
mqvectorPure state vectorO(2^n)Supports gates, gradients, and noise-channel workflows through sampling / parameter-shift paths
mqvector_gpuPure state vectorO(2^n)Same backend family as mqvector; requires CUDA support in the installation
mqvector_cqPure state vectorO(2^n)cuQuantum-backed state-vector backend when CUDA and cuQuantum support are available
mqmatrixDensity matrixO(4^n)Native mixed-state operations such as entropy, purity, partial trace; no circ_left / simulator_left in get_expectation_with_grad
mqmpsMatrix product stateO(n chi^2)Tensor-network backend; approximation depends on bond-dimension settings
stabilizerClifford tableauO(n^2)Clifford-gate backend; no parameterized gates or gradient computation

Simulator(..., dtype=...) accepts MindQuantum dtypes such as mindquantum.complex64 and mindquantum.complex128; if dtype is None, the simulator uses complex128.

Use sim.reset() when you need to return an existing simulator to the zero state.

Show full SKILL.md (278 more words)Show less

Critical Patterns

Gate Placement: .on(target, control)
python
X.on(1, 0)  # CNOT: target=1, control=0
X.on(0, [1, 2])  # Toffoli: target=0, controls=[1,2]
H.on(0)  # Single-qubit gate on qubit 0
Parameterized Gates
python
RX("alpha").on(0)  # named parameter
RX({"alpha": 2}).on(0)  # scaled: rotation = 2*alpha
RX(1.5).on(0)  # fixed value (not trainable)
Circuit Composition
python
circ1 + circ2  # concatenate
circ * 3  # repeat 3 times
circ.hermitian()  # adjoint / inverse
dagger(circ)  # same as hermitian()
UN(H, range(5))  # apply H to qubits 0-4
Encoder vs Ansatz

This is MindQuantum's key pattern for hybrid quantum-classical models:

python
encoder = Circuit().rx("x0", 0).ry("x1", 1)
encoder.as_encoder()  # marks params as data-encoding (not trainable)

ansatz = Circuit().ry("w0", 0).x(1, 0).ry("w1", 1)
ansatz.as_ansatz()  # marks params as trainable (default)

full_circuit = encoder + ansatz

When to Use Other Skills

If your task involves...Use skill
VQE, QAOA, QML, gradient-based training, MindSpore MQLayermq-variational-training
Noise channels, noisy circuits, density matrix, ChannelAddermq-noisy-simulation
QAIA solvers (SimCIM, SB), Ising/Max-Cut optimizationmq-qaia-solver
Compiling to hardware, qubit mapping, gate decompositionmq-circuit-compiler
Molecular Hamiltonians, fermion transforms, UCCSD, mqchemmq-quantum-chemistry

Reference Files

Read these on demand when you need deeper API detail:

FileWhen to Read
reference/circuit-and-gates.mdBuilding circuits, gate catalog, controlled gates, circuit operations
reference/parameter-resolver.mdParameterResolver algebra, encoder/ansatz marking, parameter manipulation
reference/operators-hamiltonian.mdQubitOperator, FermionOperator, Hamiltonian, TimeEvolution, commutator
reference/simulator-backends.mdSimulator API, state operations, sampling, expectation, gradient ops
reference/io-and-visualization.mdOpenQASM import/export, SVG rendering, circuit printing

Common Pitfalls

  1. Endianness: MindQuantum uses little-endian — qubit 0 is the rightmost (least significant) bit in state vectors and measurement results.

  2. get_expectation_with_grad requires encoder+ansatz split: If your circuit has no as_encoder() call, all params are treated as ansatz params. Encoder data must be a 2D array [batch_size, n_encoder_params].

  3. MindSpore context: mindquantum.framework operations are documented as PYNATIVE_MODE only. Use ms.set_device("CPU") with ms.set_context(mode=ms.PYNATIVE_MODE) for CPU examples.

  4. Simulator state persistence: apply_circuit and apply_gate modify the simulator state. Use sim.reset() to return to |0⟩. sampling does not change state, but it samples by applying the provided circuit to the simulator's current state.

  5. Noise via Monte Carlo: When using noise channels with mqvector, each call to sampling runs Monte Carlo trajectories. Results are statistical — use enough shots. For exact noise simulation, use mqmatrix (density matrix) but note O(4ⁿ) memory.

  6. UN requires a list: UN(H, 5) is wrong — use UN(H, range(5)) or UN(H, [0,1,2,3,4]).

© mindspore-ai, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 5 other files in skills/mindquantum of mindspore-ai/mindquantum.

  • SKILL.md
  • reference/circuit-and-gates.md
  • reference/io-and-visualization.md
  • reference/operators-hamiltonian.md
  • reference/parameter-resolver.md
  • reference/simulator-backends.md

Open the folder on GitHubat commit 2a0ca08

Compare with similar skills

Mindquantum next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Mindquantum compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mindquantum this skillmindspore-ai/mindquantum101—~2.3kAutomated safety check: PassApache-2.0
Cudaq ImportingNVIDIA/skills3.5k—~1.9kAutomated safety check: PassApache-2.0
Qiskit 2.x Quantum ML Referenceaiming-lab/AutoResearchClaw15k—~4.7kAutomated safety check: PassMIT
DiffDock Molecular DockingK-Dense-AI/scientific-agent-skills48k1 repos~3kAutomated safety check: NotesMIT
Pennylanedavila7/claude-code-templates32k8 repos~1.9kAutomated safety check: PassMIT
Light Experiment CodingLight0305/Light-skills641—~2.3kAutomated safety check: PassMIT

Similar skills

  • Cudaq Importing

    NVIDIA/skills

    Official

    A skill your agent uses when porting circuits from another framework (e.g.

    3.5k GitHub stars~1.9k tokensUpdated yesterday
    Research & ScienceAuto-check passed
  • Qiskit 2.x Quantum ML Reference

    aiming-lab/AutoResearchClaw

    Reference patterns for writing qiskit 2.x code for variational quantum machine learning: feature maps, VQC training, VQE for chemistry, MPS circuits and noise models.

    15k GitHub stars~4.7k tokensUpdated 1 mo ago
    Research & ScienceAuto-check passed
  • DiffDock Molecular Docking

    K-Dense-AI/scientific-agent-skills

    Predicts how small molecules bind to a protein with DiffDock, covering batch docking, pose ranking by confidence and checks on the results; not for binding affinity.

    48k GitHub starsUsed in 1 repo~3k tokens
    Research & ScienceAuto-check: notes
  • Pennylane

    davila7/claude-code-templates

    Cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry.

    32k GitHub starsUsed in 8 repos~1.9k tokens
    Research & ScienceAuto-check passed
  • Light Experiment Coding

    Light0305/Light-skills

    Builds the code for a frozen research experiment test-first, with leakage controls, seed handling and saved evidence so results can be rerun and audited.

    641 GitHub stars~2.3k tokensUpdated 3 mo ago
    Research & ScienceAuto-check passed
  • Torchdrug

    K-Dense-AI/scientific-agent-skills

    Builds and troubleshoots TorchDrug 0.2.1 workflows for molecular graphs, property prediction, self-supervised pretraining, molecule generation, retrosynthesis, protein representation learning, and…

    48k GitHub starsUsed in 1 repo~3k tokens
    Research & ScienceAuto-check: notes

More from mindspore-ai/mindquantum

  • Mq Circuit Compiler

    mindspore-ai/mindquantum

    Compile and optimize quantum circuits for hardware execution using MindQuantum's compiler pipeline.

    101 GitHub stars~1.7k tokensUpdated 17 days ago
    Auto-check passed
  • Mq Noisy Simulation

    mindspore-ai/mindquantum

    Simulate noisy quantum circuits with MindQuantum. An agent skill from mindspore-ai/mindquantum.

    101 GitHub stars~2.2k tokensUpdated 17 days ago
    Auto-check passed
  • Mq Qaia Solver

    mindspore-ai/mindquantum

    Solve Ising/QUBO-style combinatorial optimization problems using MindQuantum's Quantum Annealing-Inspired Algorithms (QAIA).

    101 GitHub stars~2.2k tokensUpdated 17 days ago
    Auto-check passed
  • Mq Quantum Chemistry

    mindspore-ai/mindquantum

    Run quantum chemistry simulations with MindQuantum. An agent skill from mindspore-ai/mindquantum.

    101 GitHub stars~2.2k tokensUpdated 17 days ago
    Auto-check passed
  • Mq Variational Training

    mindspore-ai/mindquantum

    Build and train variational quantum algorithms (VQE, QAOA, QML, QNN) with MindQuantum.

    101 GitHub stars~2.5k tokensUpdated 17 days ago
    Auto-check passed

Works with

Questions about Mindquantum

What does Mindquantum do?

Build, simulate, and analyze quantum circuits with MindQuantum. Mindquantum is an agent skill from mindspore-ai/mindquantum. Build, simulate, and analyze quantum circuits with MindQuantum.

When should I use Mindquantum?

Mindquantum fits situations like: code imports mindquantum; the user mentions MindQuantum; quantum circuits in Python with MindSpore; asks about quantum simulation.

How do I install Mindquantum in Claude Code?

Run `npx skills add mindspore-ai/mindquantum --skill mindquantum -a claude-code`. Or copy the skill folder (skills/mindquantum in mindspore-ai/mindquantum) into .claude/skills/mindquantum in your project. Claude Code loads it when a task matches its description.

How do I install Mindquantum in Codex?

Run `npx skills add mindspore-ai/mindquantum --skill mindquantum -a codex`. Or copy the skill folder (skills/mindquantum in mindspore-ai/mindquantum) into .agents/skills/mindquantum in your project. Codex loads it when a task matches its description.

Can I use Mindquantum in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mindspore-ai/mindquantum --skill mindquantum -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mindquantum, .gemini/skills/mindquantum, .github/skills/mindquantum and .opencode/skills/mindquantum in your project.

What does Mindquantum need to run?

Going by SKILL.md and its folder, Mindquantum needs the command-line tools its instructions call (pip and python). Our summary lists: Python 3.

Does Mindquantum access the network?

SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Mindquantum safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Mindquantum use?

Mindquantum is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Mindquantum use?

About 2.3k tokens (SKILL.md is roughly 9.1k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Mindquantum?

Skills that share tags, products or a category with Mindquantum: Cudaq Importing (NVIDIA/skills, 3.5k stars), Qiskit 2.x Quantum ML Reference (aiming-lab/AutoResearchClaw, 15k stars), DiffDock Molecular Docking (K-Dense-AI/scientific-agent-skills, 48k stars) and Pennylane (davila7/claude-code-templates, 32k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mindquantum?

mindspore-ai (a GitHub organization) maintains it in mindspore-ai/mindquantum, which has 101 GitHub stars. The repository holds 6 skills in this directory. The repository was last updated on September 21, 2026.

Source: mindspore-ai/mindquantum on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.