This preview release of Qualtran contains many improvements and new bloqs.
This is the last planned release before the 1.0 release of Qualtran. 1.0 will bring stronger stability guarantees to the core Qualtran framework: namely everything in the qualtran
namespace outside of qualtran.bloqs
. The library of bloqs
will continue to be extended and edited for greater breadth and accuracy. This development release contains some backwards-incompatible changes to prepare for 1.0. Read on for more information
Bartiq and QREF integration
This release includes interoperability with Bartiq via the QREF format implemented by @mstechly in #1194. Interoperability between quantum algorithms tooling is crucial to accelerate progress in the field.
Qualtran software paper
We've authored a manuscript describing the design of Qualtran, some important algorithmic primitives contained in qualtran.bloqs
, and case studies on problems of interest. If you use Qualtran in your own work, please cite:
Expressing and Analyzing Quantum Algorithms with Qualtran. arXiv:2409.04643.
Gate counting and leaf bloqs
We've unified the gate counting framework under the qualtran.resource_counting
framework.
- The
_t_complexity_
annotation is deprecated. Please continue to annotate callees withbuild_call_graph
or usemy_static_costs
to provide a static override. - The
cirq_interop.t_complexity
function no longer uses any custom logic. Rather, it goes viaqualtran.resource.estimation
tools; specifically theQECGatesCost
cost key. There should be no observable change to the computed costs. #1313 #1359 #1323 #1333 Toffoli
is now an atomic, leaf bloq #1388CSwap
is now an atomic leaf bloq #1393And
will become an atomic leaf bloq #1347- The
GraphvizCallGraph.from_bloq
helper method can draw call graphs with costs #1254
Tensor simulation overhaul
The tensor simulation protocol was changed to support efficient simulation of a larger class of circuits, including shallow-but-wide circuits. Qualtran can simulate a 2x32-qubit adder using only 6 qubit's worth of RAM for a specific input/output ket following the changes.
- Overhaul implemented in #1070. Tensor simulation will always try to flatten as much as possible before starting the contraction. The semantics of
my_tensors
have changed. If you are overriding this method to support tensor simulation, consider relying directly on the decomposition or read the documentation for full details on how to implement the new method. - Changes to
.flatten
in #1061. Flattening will no longer raise an error if a bloq doesn't have a decomposition..flatten()
with no arguments will flatten as much as possible.
Physical cost models
The qualtran.surface_code
module has been refactored so both Beverland- and Gidney-derived models follow the same interface.
- Code changes in #1141 #1154 #1157 #1183 #1185
qualtran.resource_estimation.GateCounts
is used directly.AlgorithmSummary
andMagicCount
dataclasses have been removed as redundant.
Other framework changes
- The
bit_tools
module has been removed and replaced withQDType
features by @charlesyuan314 in #1041. Please migrate your code to useQDType
methods to convert between bits. New, vectorizedfrom_bits
andto_bits
by @anurudhp in #1199 - Greedy topological sort of the binst graph to minimize qubit allocations / deallocations by @tanujkhattar in #1099
- Cirq interop overhaul/bugfixes @tanujkhattar in #1100
- QFxp: use integer values for classical sim instead of
fxpmath.Fxp
by @anurudhp in #1204 - Change return type of build_call_graph to set | dict by @dstrain115 in #1356 #1392
pretty_name
is deprecated #1340. Use__str__
.Bloq.supports_decompose_bloq
has been removed in #1382. Usetry/except
.BoundedQUInt
has been renamed toBQUInt
by @fdmalone in #1363- Better support for symbolics in
Signature
by @anurudhp in #1353 and @mpharrigan in #1301 - param
ctrl_spec
ofget_ctrl_system
will always be non-None by @anurudhp in #1209 - Zero-bitsize connections are explicitly not allowed by @mpharrigan in #1105
New and updated bloqs
- Implement decomposition for
BitonicSort
by @anurudhp in #1089 - Add
AutoPartition
andBloqBuilder.add_and_partition
to fit bloqs together whose registers don't quite match by @charlesyuan314 in #1086 - Implement classical action of Cast bloq by @NoureldinYosri in #1093
- Add
Unitary
andTensorProduct
block encodings by @charlesyuan314 in #1094 - GlobalPhase: use
exponent
, and implement controlled (ZPowGate) by @anurudhp in #1117 - Create
ApplyLthBloq
as a simple SELECT oracle by @charlesyuan314 in #1107 - Add
Product
block encoding by @charlesyuan314 in #1106 - Add
Phase
block encoding by @charlesyuan314 in #1129 - Add
LinearCombination
block encoding by @charlesyuan314 in #1133 - Permutation Bloq by @anurudhp in #1110
- Sparse state preparation via alias sampling by @anurudhp in #1067
- Implement
Negate
(two's complement) by @anurudhp in #1144 - Add
Xor
bloq by @charlesyuan314 in #1149 - Add
InvertRealNumber
bloq by @charlesyuan314 in #1151 - Add
BitwiseNot
by @anurudhp in #1161 - Add
SubtractFrom
to subtract from a register in place by @charlesyuan314 in #1158 - Switch
SubtractFrom
to useBitwiseNot
by @charlesyuan314 in #1164 - Create
SparseMatrix
block encoding by @charlesyuan314 in #1143 - Optimize gate count of Subtract to n-1 Toffolis by @NoureldinYosri in #1057
- CHadamard by @mpharrigan in #1114
- CYGate by @mpharrigan in #1115
- CZ by @mpharrigan in #1116
- Disallow zero sized registers in QROMs and PRGAViaPhaseGradient by @tanujkhattar in #1160
- Add
ExplicitEntryOracle
to block encode a matrix by @charlesyuan314 in #1166 ControlledAddOrSubtract
Bloq by @anurudhp in #1145- Update classical action of addition gates and fix classical action bug in Join by @NoureldinYosri in #1174
- Implement generic
MultiControlledBloq
using single-controlled subbloq + And ladder. by @anurudhp in #1155 ControlledViaAnd
tests and bloq examples by @anurudhp in #1182- Add
SignExtend
for two's complement sign extension by @anurudhp in #1162 - Add
SymmetricBanded
matrix block encoding by @charlesyuan314 in #1177 - Add
ArcSin
bloq by @charlesyuan314 in #1188 - Add symbolic call graph for
SparseMatrix
by @charlesyuan314 in #1193 - Revamp
ChebyshevPolynomial
by @charlesyuan314 in #1213 - Bitwise bloqs are self adjoint by @anurudhp in #1220
- Update QROAM in chemistry prepare bloqs to use clean ancilla by @fdmalone in #1226
- Add
ScaledChebyshevPolynomial
bloq by @charlesyuan314 in #1231 - Add an optimizer for
LinearCombination
s by @charlesyuan314 in #1232 - Add FFT QSP by @Epsilon1024 in #1078
- RzViaPhaseGradient by @anurudhp in #1147
- Add notebook tests for block encodings by @charlesyuan314 in #1235
- Make QubitizationWalkOperator expect a BlockEncoding instead of Select and Prepare by @fdmalone in #1132
- Controlled-Addition implementation by @skushnir123 in #864
- Improve support for CAdd by @NoureldinYosri in #1277
- Support symbolic decomposition for state prep via alias sampling by @tanujkhattar in #1084
- Rewrite
SelectSwapQROM
usingbuild_composite_bloq
by @tanujkhattar in #1276 - Add shim for measurement gate by @anurudhp in #1287
- Add explicit adjoint for
SwapWithZero
and classical simulation tests for decomposition ofSelectSwapQROM
by @tanujkhattar in #1285 - Sparse state preparation via Dense + Permute by @anurudhp in #1205
- Add
QROAMClean
andQROAMCleanAdjoint
bloqs for data loading by @tanujkhattar in #1291 - Create controlled greater than bloq by @NoureldinYosri in #1283
- Create CModAdd by @NoureldinYosri in #1295
- Add
QROAMCleanAdjointWrapper
to match signature ofQROAMClean
and delegate implementation toQROAMCleanAdjoint
by @tanujkhattar in #1324 - Refactor QPE bloqs by @tanujkhattar in #1297
- ZPow (known angle) using phase gradient by @anurudhp in #1275
- Add
ProgrammableAncillaRotation
with costs by @anurudhp in #1136 - Make
Identity
ann
qubit bloq by @anurudhp in #1327 - Create ModNeg and CModNeg by @NoureldinYosri in #1300
- Add
KaiserWindowState
bloq to prepare initial state for high confidence QPE by @tanujkhattar in #1331 - Use XorK bloq instead of CNOTs to load data in QROM by @tanujkhattar in #1335
- Create ModSub and CModSub by @NoureldinYosri in #1332
- Remove
factoring/mod_sub
to reduce code duplication by @NoureldinYosri in #1338 - Use QROAMClean in Chemistry Sparse Prepare bloq by @fdmalone in #1316
- Add a test util for classical action and refactor
factoring/mod_mul
by @NoureldinYosri in #1339 - HammingWeightCompute: replace ArbitraryClifford with CNOT, support symbolic bitsizes by @anurudhp in #1355
- Make symbolic call graph and costs of
ZPowUsingProgrammedAncilla
more accurate by @tanujkhattar in #1389
Full Changelog
Can be found on GitHub: v0.4.1...v0.5.0