मुख्य सामग्री पर जाएँ
Skillpedia
मशीन लर्निंग15k · #11069

quantum-qiskit

यह क्या करती है

यह स्किल qiskit 2.x के लिए कोड के पैटर्न और सुधार देती है। यह उन डेवलपर्स और रिसर्चरों के लिए है जो वेरिएशनल क्वांटम मशीन लर्निंग कोड लिखते हैं।

कब इस्तेमाल करें

  • ✓जब आप Python कोड लिखते हैं जो qiskit या उसके मशीन लर्निंग या केमिस्ट्री पैकेज इम्पोर्ट करता है।
  • ✓जब आप वेरिएशनल क्वांटम क्लासिफ़ायर या VQE केमिस्ट्री गणना बनाते हैं।
  • ✓जब आपको qiskit 2.x माइग्रेशन एरर मिले या नॉइज़ मॉडल जोड़ना हो।

Skill का लिंक

https://github.com/aiming-lab/AutoResearchClaw/blob/main/researchclaw/skills/builtin/domain/quantum-qiskit/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/aiming-lab/AutoResearchClaw/blob/main/researchclaw/skills/builtin/domain/quantum-qiskit/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“qiskit 2.x में ZZ फ़ीचर मैप वाला एक वेरिएशनल क्वांटम क्लासिफ़ायर लिखिए, और मेरी स्क्रिप्ट की इम्पोर्ट एरर ठीक कीजिए।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

एजेंट फ़ीचर मैप, एन्सैट्ज़ सर्किट, ट्रेनिंग और नॉइज़ मॉडल के लिए मौजूदा qiskit 2.x पैटर्न इस्तेमाल करता है। वह पुराने संस्करणों के वे बदलाव भी बताता है जो आम तौर पर कोड तोड़ते हैं, और उनके सुधार भी।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Qiskit 2.x reference for variational quantum machine learning

This skill is a canonical reference for writing Python code that uses qiskit 2.x and its ecosystem (qiskit_aer, qiskit_algorithms, qiskit_machine_learning, qiskit_nature). It documents the API shapes that work in qiskit 2.x today, the qiskit-1.x → 2.x migration breaks that affect VQE and chemistry code, and a small number of common mistakes with concrete fixes.

Section overview:

  1. Imports
  2. Data-encoding feature maps
  3. Variational ansatz construction
  4. VQC training (qiskit_machine_learning)
  5. VQE for chemistry (qiskit 2.x compatible)
  6. MPS-structured circuits
  7. Noise model integration
  8. qiskit 2.x compatibility notes
  9. Common errors and fixes
  10. Autoclaw integration: metric logging convention

1. Imports

import numpy as np
from qiskit import QuantumCircuit
from qiskit.circuit import ParameterVector
from qiskit.circuit.library import (
    ZFeatureMap,
    ZZFeatureMap,
    StatePreparation,
    EfficientSU2,
)
from qiskit.primitives import StatevectorSampler, StatevectorEstimator  # V2 primitives
from qiskit.quantum_info import Statevector, SparsePauliOp
from qiskit_aer import AerSimulator
from qiskit_algorithms.optimizers import SPSA, COBYLA, L_BFGS_B, ADAM
from qiskit_algorithms.utils import algorithm_globals
from qiskit_machine_learning.algorithms.classifiers import VQC

For chemistry:

from qiskit_nature.units import DistanceUnit
from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.mappers import ParityMapper, JordanWignerMapper

Do not import from qiskit_nature.second_q.algorithms or qiskit_algorithms.VQE under qiskit 2.x (they fail at import time, see section 8).


2. Data-encoding feature maps

Three standard families. Each builder returns a parameterized circuit suitable for use as the feature_map argument of VQC or for direct contraction with a variational ansatz.

def build_angle_encoding(num_features: int) -> QuantumCircuit:
    """Hadamard plus single-qubit Z-rotation per feature.

    Mathematically equivalent to ZFeatureMap(reps=1).
    """
    return ZFeatureMap(feature_dimension=num_features, reps=1)


def build_amplitude_encoding(num_features: int):
    """Load an L2-normalized, zero-padded input as the amplitudes of a
    quantum state. The encoding uses ceil(log2(num_features)) qubits.

    Returns (circuit, parameter_vector, num_qubits). The caller binds
    parameters per-sample via the helper below.
    """
    num_qubits = int(np.ceil(np.log2(max(num_features, 2))))
    full_dim = 2 ** num_qubits
    params = ParameterVector("x_amp", full_dim)
    qc = QuantumCircuit(num_qubits)
    qc.append(StatePreparation(list(params)), range(num_qubits))
    return qc, params, num_qubits


def amplitude_binding(x: np.ndarray, params, num_qubits: int) -> dict:
    """Build the parameter-value dict for a single input sample."""
    x_norm = x / max(float(np.linalg.norm(x)), 1e-12)
    padded = np.zeros(2 ** num_qubits, dtype=np.float64)
    padded[: len(x_norm)] = x_norm
    padded = padded / max(float(np.linalg.norm(padded)), 1e-12)
    return {params[i]: float(padded[i]) for i in range(len(padded))}


def build_zz_feature_map(num_features: int) -> QuantumCircuit:
    """Two repetitions of Hadamard plus pairwise ZZ entangling rotations."""
    return ZZFeatureMap(
        feature_dimension=num_features, reps=2, entanglement="linear"
    )

To verify that two encoders produce distinguishable output for a fixed input (catches dispatch bugs in code that constructs multiple encoders in a loop):

def assert_different_output_states(qc_a, qc_b, x, tol: float = 1e-6):
    sv_a = Statevector(qc_a.assign_parameters(x))
    sv_b = Statevector(qc_b.assign_parameters(x))
    diff = float(np.linalg.norm(sv_a.data - sv_b.data))
    assert diff > tol, f"encoders produced identical states (diff={diff})"

3. Variational ansatz construction

def build_ansatz(num_qubits: int, reps: int = 2) -> QuantumCircuit:
    """Hardware-efficient ansatz with alternating Pauli rotations
    and a linear chain of CNOT entanglers. Trainable parameter count
    is (reps + 1) * num_qubits for the default su2_gates = ['ry']."""
    return EfficientSU2(
        num_qubits=num_qubits, reps=reps, entanglement="linear"
    )

ansatz.num_parameters gives the trainable parameter count, useful for matching parameter budgets against clas

अक्सर पूछे जाने वाले सवाल

क्या यह qiskit 1.x कोड को भी कवर करती है?

संदर्भ मुख्य रूप से qiskit 2.x API पर केंद्रित है, और 1.x से टूटने वाले बदलाव भी बताता है।

फ़ीचर मैप क्या है?

एक सर्किट जो ट्रेनिंग से पहले क्लासिकल डेटा को क्वांटम स्टेट में बदलता है।

VQE क्या है?

एक वेरिएशनल तरीका जो पैरामीटराइज़्ड सर्किट से किसी अणु की ग्राउंड-स्टेट ऊर्जा का अनुमान लगाता है।

जानकारी

लेखक का मूल विवरण

Reference qiskit 2.x patterns for variational quantum machine learning. Covers data-encoding feature maps, variational quantum classifier (VQC) training, variational quantum eigensolver (VQE) for chemistry, matrix-product-state circuits, and noise model integration. Use when writing Python code that imports `qiskit`, `qiskit_aer`, `qiskit_algorithms`, `qiskit_machine_learning`, or `qiskit_nature`.

repo: aiming-lab/AutoResearchClaw

लोकप्रियता

GitHub स्टार
15k
रैंकिंग में स्थान
#11069
लाइसेंस
MIT
अपडेट की गई
19/8/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

a-evolve

15k

बार-बार चलने पर विफलताओं का निदान करके, दोहराती त्रुटियों से लक्षित स्किल बनाकर, और आगे के लिए सबक दर्ज करके आपके एजेंट को बेहतर बनने में मदद करती है।

AI और एजेंटएजेंट

biology-biopython

15k

Biopython से DNA, RNA और प्रोटीन अनुक्रमों के साथ काम करने में आपके एजेंट की मदद करती है, जिसमें फ़ाइल पार्सिंग, अनुक्रम गणनाएँ, BLAST खोजें और डेटाबेस तक पहुँच शामिल है।

डेटाएनालिसिस और स्प्रेडशीट

chemistry-rdkit

15k

RDKit से SMILES स्ट्रिंग में लिखे अणुओं का विश्लेषण करने में आपके एजेंट की मदद करती है, जिसमें descriptors, fingerprints, समानता और substructure खोज शामिल हैं।

डेटाएनालिसिस और स्प्रेडशीट

hypothesis-formulation

15k

एक अवलोकन को परखने योग्य परिकल्पनाओं में बदलने में आपके एजेंट की मदद करती है, जिनमें प्रतिस्पर्धी व्याख्याएँ और स्पष्ट भविष्यवाणियाँ हों जो उन्हें गलत साबित कर सकें।

लेखन और डॉक्यूमेंटरिसर्च

मिलती-जुलती skills