Agent skill

Mq Qaia Solver

by mindspore-ai in mindspore-ai/mindquantum

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

Apache-2.0Auto-check passedResearch & Science

Install Mq Qaia Solver

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

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

GitHub CLI
$ gh skill install mindspore-ai/mindquantum mq-qaia-solver --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/mq-qaia-solver .claude/skills/mq-qaia-solver && 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
mq-qaia-solver
GitHub stars
102
Token cost
~2.2k tokens
SKILL.md length
604 words
Files
1
Skills in repo
6
Repo updated
First seen
Licence
Apache-2.0

At a glance

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

  • Works in 4 steps: In-place modification: solver.x is… → Sparse matrices: Use scipy.sparse for… → Symmetry: $J$ must be symmetric. If your… → …
  • The user mentions QAIA
  • SKILL.md covers The Ising Model, Quick Start, Available Solvers and Core API, plus 5 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Mq Qaia Solver is an agent skill from mindspore-ai/mindquantum. Solve Ising/QUBO-style combinatorial optimization problems using MindQuantum's Quantum Annealing-Inspired Algorithms (QAIA). Covers SimCIM, ASB/BSB/DSB, TSB/USB/LSB, LQA, CFC, CAC, SFC, and NMFA, with solver-specific CPU/GPU/NPU backend support. This is not circuit-based QAOA: QAIA solvers operate directly on an Ising coupling matrix J and optional field h. Use when the user mentions QAIA, SimCIM, simulated bifurcation, Ising solver, Max-Cut solver, QUBO, or a combinatorial problem already encoded as Ising/QUBO.

Its SKILL.md is about 2.2k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Research & Science, covering Quantum computing. 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

  • The user mentions QAIA
  • Simulated bifurcation
  • A combinatorial problem already encoded as Ising/QUBO

Example prompts

  • “/mq-qaia-solver”

Requirements

  • Python 3

Workflow steps

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

  1. In-place modification: solver.x is modified during update(). Pass x.copy() if you need the original.
  2. Sparse matrices: Use scipy.sparse for large graphs — solvers accept both dense and sparse formats.
  3. Symmetry: $J$ must be symmetric. If your adjacency matrix is asymmetric, symmetrize: J = (J + J.T) / 2.
  4. Sign convention: QAIA energy uses $H = -\frac{1}{2}\sum_{i,j} J_{ij}s_is_j - \sum_i h_i s_i$. For Max-Cut examples in this repository…

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

    No scripts in the folder and no shell commands in SKILL.md (its code samples are python).

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

  • Network

    No URLs in SKILL.md.

    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

Mq Qaia Solver loads about 2.2k tokens when it runs. Until then it costs about 133 tokens; SKILL.md has 604 words of instructions outside code blocks.

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

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). 604 words, ~2,231 tokens.

Download SKILL.mdSave it as .claude/skills/mq-qaia-solver/SKILL.md (or your agent's skills folder).
name
mq-qaia-solver
description
Solve Ising/QUBO-style combinatorial optimization problems using MindQuantum's Quantum Annealing-Inspired Algorithms (QAIA). Covers SimCIM, ASB/BSB/DSB, TSB/USB/LSB, LQA, CFC, CAC, SFC, and NMFA, with solver-specific CPU/GPU/NPU backend support. This is not circuit-based QAOA: QAIA solvers operate directly on an Ising coupling matrix J and optional field h. Use when the user mentions QAIA, SimCIM, simulated bifurcation, Ising solver, Max-Cut solver, QUBO, or a combinatorial problem already encoded as Ising/QUBO.

QAIA: Quantum Annealing-Inspired Algorithms

MindQuantum's QAIA module provides quantum annealing-inspired solvers for combinatorial optimization problems encoded as Ising models. These solvers do not build quantum circuits; they evolve solver-specific state variables from a coupling matrix.

Key distinction: QAIA solvers are NOT circuit-based QAOA. They solve Ising/QUBO problems directly using physics-inspired dynamics. For circuit-based QAOA, use the mq-variational-training skill.

The Ising Model

QAIA's calc_energy() uses this Ising energy convention for a symmetric coupling matrix:

$$H(\mathbf{s}) = -\frac{1}{2}\sum_{i,j} J_{ij} s_i s_j - \sum_i h_i s_i$$

where $s_i \in {-1, +1}$ are spin variables, $J$ is the coupling matrix, and $h$ is the external field.

Quick Start

python
import numpy as np
from scipy.sparse import coo_matrix
from mindquantum.algorithm.qaia import BSB

# Define coupling matrix J (symmetric, from graph edges)
edges = [(0, 1), (1, 2), (2, 3), (3, 0), (0, 2)]
n_nodes = 4
row = [e[0] for e in edges] + [e[1] for e in edges]
col = [e[1] for e in edges] + [e[0] for e in edges]
data = [-1] * len(row)
J = coo_matrix((data, (row, col)), shape=(n_nodes, n_nodes))

# Solve
solver = BSB(J, batch_size=100, n_iter=500)
solver.update()

# Results
cuts = solver.calc_cut()
print(f"Best cut value: {max(cuts)}")
spins = np.sign(solver.x)  # Final spin configuration

Available Solvers

SolverImportName in source docstringDocumented / implemented backends
SimCIMfrom mindquantum.algorithm.qaia import SimCIMSimulated Coherent Ising Machinecpu-float32, gpu-float32, npu-float32
ASBfrom mindquantum.algorithm.qaia import ASBAdiabatic SB algorithmcpu-float32, gpu-float32, npu-float32
BSBfrom mindquantum.algorithm.qaia import BSBBallistic SB algorithmcpu-float32, gpu-float32, gpu-float16, gpu-int8, npu-float32
DSBfrom mindquantum.algorithm.qaia import DSBDiscrete SB algorithmcpu-float32, gpu-float32, gpu-float16, gpu-int8, npu-float32
LQAfrom mindquantum.algorithm.qaia import LQALocal quantum annealing algorithmcpu-float32, gpu-float32, npu-float32
CACfrom mindquantum.algorithm.qaia import CACCoherent Ising Machine with chaotic amplitude controlcpu-float32, gpu-float32, npu-float32
CFCfrom mindquantum.algorithm.qaia import CFCCoherent Ising Machine with chaotic feedback controlcpu-float32, gpu-float32, npu-float32
SFCfrom mindquantum.algorithm.qaia import SFCCoherent Ising Machine with separated feedback controlcpu-float32, gpu-float32, npu-float32
NMFAfrom mindquantum.algorithm.qaia import NMFANoisy Mean-field Annealing algorithmcpu-float32, gpu-float32, npu-float32
TSBfrom mindquantum.algorithm.qaia import TSBTernary Simulated Bifurcation algorithmcpu-float32, gpu-float32
USBfrom mindquantum.algorithm.qaia import USBUniformly Quantized Simulated Bifurcationcpu-float32, gpu-float32
LSBfrom mindquantum.algorithm.qaia import LSBLogarithmic Quantized Simulated Bifurcationcpu-float32, gpu-float32

Core API

QAIA solvers share this core constructor and method pattern; individual classes may expose additional parameters such as dt, xi, threshold, or strategy:

python
solver = SolverClass(
    J,  # Coupling matrix: numpy.array or scipy.sparse
    h=None,  # External field: numpy.array [N, 1] (optional)
    x=None,  # Initial spins: numpy.array [N, batch_size] (optional)
    n_iter=1000,  # Number of iterations
    batch_size=1,  # Parallel samples
    backend="cpu-float32",  # Compute backend; supported values are solver-specific
)

solver.update()  # Run the optimization dynamics
solver.calc_cut()  # Max-Cut value for each batch (returns array)
solver.calc_energy()  # Ising energy for each batch
spins = np.sign(solver.x)  # Extract discrete spin assignments

Backend Notes

Backends are not uniform across all QAIA classes.

  • gpu-float32 uses PyTorch CUDA in the Python implementations.
  • npu-float32 uses torch_npu and is only implemented by the non-quantized solvers listed above.
  • gpu-float16 and gpu-int8 are only implemented in BSB and DSB; their source note warns that gpu-int8 may not perform well on dense graphs or graphs with continuous coefficients.
  • TSB, USB, and LSB explicitly validate only cpu-float32 and gpu-float32.
python
solver = BSB(J, batch_size=1000, n_iter=2000, backend="gpu-float32")
solver.update()

Max-Cut Workflow (Complete)

python
import numpy as np
from scipy.sparse import coo_matrix
from mindquantum.algorithm.qaia import BSB, DSB, SimCIM


# 1. Load graph (e.g., GSet format)
def load_gset(filepath):
    """Load GSet benchmark graph as sparse coupling matrix."""
    import pandas as pd

    data = pd.read_csv(filepath, sep=" ", header=0)
    n = int(data.columns[0])
    rows = np.concatenate([data.iloc[:, 0] - 1, data.iloc[:, 1] - 1])
    cols = np.concatenate([data.iloc[:, 1] - 1, data.iloc[:, 0] - 1])
    vals = np.concatenate([data.iloc[:, 2], data.iloc[:, 2]])
    return coo_matrix((-vals, (rows, cols)), shape=(n, n))


# 2. Try multiple solvers
J = load_gset("G22.txt")  # 2000-node graph

results = {}
for name, Solver in [("BSB", BSB), ("DSB", DSB), ("SimCIM", SimCIM)]:
    solver = Solver(J, batch_size=100, n_iter=1000)
    solver.update()
    best_cut = max(solver.calc_cut())
    results[name] = best_cut
    print(f"{name}: MaxCut = {best_cut}")

# 3. Top result in this run
top = max(results, key=results.get)
print(f"Top solver in this run: {top} with cut = {results[top]}")

Problem Formulation Guide

Show full SKILL.md (241 more words)Show less
Max-Cut → Ising

For Max-Cut, negate the adjacency matrix:

python
# J[i,j] = -weight(i,j) for edges, 0 otherwise
# h = None (no external field)
QUBO → Ising

Convert Quadratic Unconstrained Binary Optimization. This helper assumes the common upper-triangular convention E(x) = sum_i Q[i,i] x_i + sum_{i<j} Q[i,j] x_i x_j and returns (J, h, constant) for the QAIA energy H(s) = -sum_{i<j} J[i,j] s_i s_j - sum_i h[i] s_i + constant.

python
def qubo_to_ising(Q):
    """Convert upper-triangular QUBO matrix Q to QAIA Ising (J, h, constant)."""
    n = Q.shape[0]
    J = np.zeros((n, n))
    h = np.zeros(n)
    constant = 0.0
    for i in range(n):
        h[i] -= Q[i, i] / 2
        constant += Q[i, i] / 2
        for j in range(i + 1, n):
            qij = Q[i, j]
            J[i, j] = -qij / 4
            J[j, i] = -qij / 4
            h[i] -= qij / 4
            h[j] -= qij / 4
            constant += qij / 4
    return J, h.reshape(-1, 1), constant
Graph Coloring, SAT, TSP

Encode constraints as penalty terms in the Ising Hamiltonian. The coupling matrix $J$ and field $h$ encode both the objective and constraints.

Parameter Notes

ParameterEffectGuidance
batch_sizeNumber of parallel samplesIncreases the number of independent candidates returned by one solver run.
n_iterEvolution stepsControls how many update steps update() performs.
backendCompute device / precisionMust be chosen from the backends supported by that solver class.
Comparing Solvers

The source tree documents multiple algorithms but does not provide a universal ranking by graph size, density, or hardness. When solution quality matters, run the candidate solvers with the same J, h, batch_size, n_iter, and random seed policy, then compare calc_energy() or the problem-specific objective.

Important Notes

  1. In-place modification: solver.x is modified during update(). Pass x.copy() if you need the original.
  2. Sparse matrices: Use scipy.sparse for large graphs — solvers accept both dense and sparse formats.
  3. Symmetry: $J$ must be symmetric. If your adjacency matrix is asymmetric, symmetrize: J = (J + J.T) / 2.
  4. Sign convention: QAIA energy uses $H = -\frac{1}{2}\sum_{i,j} J_{ij}s_is_j - \sum_i h_i s_i$. For Max-Cut examples in this repository, edge weights are negated before constructing J.

© 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

Just SKILL.md in skills/mq-qaia-solver of mindspore-ai/mindquantum.

Open the folder on GitHubat commit 2a0ca08

Compare with similar skills

Mq Qaia Solver 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.

Mq Qaia Solver compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Mq Qaia Solver this skillmindspore-ai/mindquantum102—~2.2kAutomated safety check: PassApache-2.0
Qiskit 2.x Quantum ML Referenceaiming-lab/AutoResearchClaw15k—~4.7kAutomated safety check: PassMIT
QutipzLanqing/codex-claude-academic-skills4.7k8 repos~2.3kAutomated safety check: PassBSD-3-Clause
Cirqdavila7/claude-code-templates33k11 repos~2.7kAutomated safety check: PassMIT
Qiskitdavila7/claude-code-templates33k9 repos~2.2kAutomated safety check: PassMIT
Pennylanedavila7/claude-code-templates33k7 repos~1.9kAutomated safety check: PassMIT

Similar skills

  • 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
  • Qutip

    zLanqing/codex-claude-academic-skills

    Quantum physics simulation library for open quantum systems.

    4.7k GitHub starsUsed in 8 repos~2.3k tokens
    Research & ScienceAuto-check passed
  • Cirq

    davila7/claude-code-templates

    Quantum computing framework for building, simulating, optimizing, and executing quantum circuits.

    33k GitHub starsUsed in 11 repos~2.7k tokens
    Research & ScienceAuto-check passed
  • Qiskit

    davila7/claude-code-templates

    Comprehensive quantum computing toolkit for building, optimizing, and executing quantum circuits.

    33k GitHub starsUsed in 9 repos~2.2k tokens
    Research & ScienceAuto-check passed
  • Pennylane

    davila7/claude-code-templates

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

    33k GitHub starsUsed in 7 repos~1.9k tokens
    Research & ScienceAuto-check passed
  • Qiskit

    K-Dense-AI/scientific-agent-skills

    Builds, simulates, transpiles, and executes quantum circuits with Qiskit and IBM Quantum Runtime.

    48k GitHub starsUsed in 1 repo~3.3k tokens
    Research & ScienceAuto-check passed

More from mindspore-ai/mindquantum

  • Mindquantum

    mindspore-ai/mindquantum

    Build, simulate, and analyze quantum circuits with MindQuantum.

    102 GitHub stars~2.3k tokensUpdated 19 days ago
    Auto-check passed
  • Mq Circuit Compiler

    mindspore-ai/mindquantum

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

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

    mindspore-ai/mindquantum

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

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

    mindspore-ai/mindquantum

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

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

    mindspore-ai/mindquantum

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

    102 GitHub stars~2.5k tokensUpdated 19 days ago
    Auto-check passed

Questions about Mq Qaia Solver

What does Mq Qaia Solver do?

Solve Ising/QUBO-style combinatorial optimization problems using MindQuantum's Quantum Annealing-Inspired Algorithms (QAIA). Mq Qaia Solver is an agent skill from mindspore-ai/mindquantum. Solve Ising/QUBO-style combinatorial optimization problems using MindQuantum's Quantum Annealing-Inspired Algorithms (QAIA).

When should I use Mq Qaia Solver?

Mq Qaia Solver fits situations like: the user mentions QAIA; simulated bifurcation; A combinatorial problem already encoded as Ising/QUBO.

How do I install Mq Qaia Solver in Claude Code?

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

How do I install Mq Qaia Solver in Codex?

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

Can I use Mq Qaia Solver 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 mq-qaia-solver -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/mq-qaia-solver, .gemini/skills/mq-qaia-solver, .github/skills/mq-qaia-solver and .opencode/skills/mq-qaia-solver in your project.

What does Mq Qaia Solver need to run?

SKILL.md names no scripts, command-line tools or credentials: Mq Qaia Solver is instructions for the agent only. Our summary lists: Python 3.

Does Mq Qaia Solver access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Mq Qaia Solver 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 Mq Qaia Solver use?

Mq Qaia Solver 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 Mq Qaia Solver use?

About 2.2k tokens (SKILL.md is roughly 8.9k 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 Mq Qaia Solver?

Skills that share tags, products or a category with Mq Qaia Solver: Qiskit 2.x Quantum ML Reference (aiming-lab/AutoResearchClaw, 15k stars), Qutip (zLanqing/codex-claude-academic-skills, 4.7k stars), Cirq (davila7/claude-code-templates, 33k stars) and Qiskit (davila7/claude-code-templates, 33k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Mq Qaia Solver?

mindspore-ai (a GitHub organization) maintains it in mindspore-ai/mindquantum, which has 102 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.