linear-combination

Computes analytic quantum circuit gradients and Quantum Geometric Tensors via linear combination of unitaries in Qiskit.

18|3|Updated Aug 14, 2026
One-click install
npx skills add https://github.com/unitarylab/quantum-practices --skill linear-combination-unitarylab
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: linear-combination
Source: https://github.com/unitarylab/quantum-practices/tree/main/algorithms/gradients/linear-combination
Command: npx skills add https://github.com/unitarylab/quantum-practices --skill linear-combination-unitarylab

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, qiskit, qiskit_algorithms, and includes scripts (resource) components.

What problem does it solve? Computing exact parameter gradients of parameterized quantum circuits without finite-difference approximation error is difficult, and many variational algorithms also need the Quantum Geometric Tensor for natural gradient optimization. This Skill provides guidance and reference implementations for analytic gradient and QGT estimation using the linear combination of unitaries (LCU) method in Qiskit. ## Core Features & Use Cases - Estimator Gradients: Compute exact expectation-value gradients with LinCombEstimatorGradient, supporting REAL, IMAG, and COMPLEX derivative types. - Sampler Gradients: Differentiate probability distributions from measured circuits using LinCombSamplerGradient. - Quantum Geometric Tensor: Build QGT matrices with LinCombQGT, including the phase-fix term required by quantum natural gradient methods. - Use Case: A researcher training a variational quantum eigensolver needs exact gradients of a 3-parameter RY/RZ circuit with respect to a ZZZ observable, plus the QGT matrix for natural gradient descent, all without numerical approximation error. ## Quick Start Ask the assistant to compute the analytic gradient of a parameterized Qiskit circuit with respect to a Pauli observable using the LCU estimator gradient method.

Frequently Asked Questions about linear-combination

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I compute analytic gradients of a parameterized quantum circuit in Qiskit?

Use LinCombEstimatorGradient from qiskit_algorithms.gradients with an Estimator primitive such as StatevectorEstimator. Pass your circuit, observable, and parameter values to its run method, and it returns exact gradients without finite-difference error.

What is the difference between LCU gradients and parameter-shift gradients?

LCU gradients use ancilla-augmented circuits with controlled derivative operators and support a broader gate set including ccx, swap, and iswap. Parameter-shift uses shifted evaluations of the original circuit and supports a narrower gate set.

Which gates are supported by the Qiskit LCU gradient method?

The supported gates are rx, ry, rz, rzx, rzz, ryy, rxx, cx, cy, cz, ccx, swap, iswap, h, t, s, sdg, x, y, and z. Circuits containing other gates fail during preprocessing unless they can be decomposed into this set.

How do I compute the Quantum Geometric Tensor in Qiskit?

Use LinCombQGT with an Estimator primitive and call run with your circuit and parameter values. Keep phase_fix set to True, the default, to obtain the standard QGT used by quantum natural gradient algorithms.

Why does my LCU gradient job use twice as many circuit evaluations?

When derivative_type is set to COMPLEX, each augmented circuit is evaluated twice, once for the real and once for the imaginary observable part. This doubles the PUB count from n to 2n for n parameters.

What are the limitations of the LCU gradient method?

LCU requires one extra ancilla qubit per augmented circuit, which can exceed hardware qubit capacity. It also only works with gates from its supported set, and cached circuits can become stale if the circuit is modified between runs.