Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage bit (register) variables #155

Merged
merged 30 commits into from
Aug 13, 2024

Conversation

rturrado
Copy link
Contributor

@rturrado rturrado commented Jun 11, 2024

QX simulator now parses bit (register) variables from the libqasm AST.
Apart from that, this PR includes a lot of refactorings.

The RegisterManager now manages a qubit and a bit register.
The SimulationResultAccumulator now has a state and bitMeasurements (temporarily also measurements).
A SimulationResult has a state and a bitRegisterMeasurement (temporarily also measurements).
A SimulationResult also has a qubit and a bit register.

State is a vector of SuperposedState.
Measurements is a vector of Measurement.
SuperposedState is a struct containing a state string and an amplitude.
Measurement is a struct containing a state string and a count.

Add Core/BitMeasurementRegister alias.
Add Core/isNull(complex) function.
Add Core/fmt::formatter for BitMeasurementRegister.
Add Measure.bitIndex member.
Add QuantumState.numberOfBits member.
Add QuantumState.bitRegisterMeasurement member.
Add QuantumState constructor receiving an initializer list.
Add QuantumState.checkQuantumState and isNormalized methods.
Add QuantumState/QuantumStateError struct.
Add SimulationResult/Result and State structs.
Add SparseArray constructor receiving an initializer list.
Add SparseArray.accumulate method.
Add SparseArray.norm method.
Add SparseArray/SparseComplex struct and SparseElement alias.
Add SparseArray/MapBasisVectorToSparseComplex and VectorOfSparseElements aliases.
Add SparseArray/SparseArrayError struct.
Add SimulationResultAccumulator.bitMeasurementRegister member.
Add boost/1.85.0 to conanfile.py.

Change RegisterManager to support a qubit and a bit register.
Change OperandsHelper.get_register_operand to work with bit operands.
Change GateConvertor.addGates to accept bit indices in a Measure instruction.
Change SimulationResult::operator<< to use fmt::print.
Change OUTPUT_DECIMALS to uint8_t.
Change CMakeLists.txt to work with Boost.
Change CHANGELOG.md with minor aesthetic changes.
Extract DensityUnitaryMatrix, QuantumState, and SparseArray to separate files.
Extract InstructionExecutor and Instructions to separate files.
Move Complex to Core.
Refactor QuantumState.measure method.
Rename SimulationResult.results to measurements.
Rename SimulationResult.states to state.

Remove include/qx/Common.hpp.
Remove src/qx/Core.cpp.
Remove InstructionExecutor.{MeasureAll, PrepZ}.
Remove QuantumState.{measureAll, prep} methods.
Remove QuantumState.testInitialize method.
Remove QuantumState.apply<1,2,3> explicit instantiations.

TODO:

  • SimulationResult operator<< doesn't output any information regarding the bit register measurements.
  • Python side's SimulationResult contains no QubitRegister, BitRegister, and BitRegisterMeasurement.
    Adding this has to be previously agreed with QX simulator clients.

Issue #154: [Code] Manage bit (register) variables.

@rturrado rturrado requested a review from elenbaasc June 11, 2024 22:10
@rturrado rturrado linked an issue Jun 11, 2024 that may be closed by this pull request
rturrado and others added 9 commits June 12, 2024 00:23
Add bitIndex to Measure instruction.
Add bit register size to QuantumState.
Add bit measurement register to QuantumState.
Add SparseArray.accumulate.
Add boost/1.85.0 to conanfile.py.

Change OperandsHelper.get_register_operand to work with bit operands.
Change GateConvertor.addGates to accept bit indices in a Measure instruction.
Refactor QuantumState.measure.
Change CMakeLists.txt to work with Boost.
Update CHANGELOG.md with minor aesthetic changes.

Remove QuantumState.{measureAll, prep}.
Remove InstructionExecutor.{MeasureAll, PrepZ}.
…mporarily also measurements).

A SimulationResult has a state and a bitRegisterMeasurement (temporarily also measurements).
A SimulationResult also has a qubit and a bit register.

State is a vector of SuperposedState.
Measurements is a vector of Measurement.
SuperposedState is a state string and an amplitude.
Measurement is a state string and a count.

Add SimulationResultAccumulator bitMeasurementRegister member.
Add QuantumState constructor receiving an initializer list.
Add QuantumState checkQuantumState and isNormalized methods.
Add SparseArray constructor receiving an initializer list.
Add SparseArray norm method.
Add Core isNull(complex) method.
Add Core fmt::formatter for BitMeasurementRegister.

Rename SimulationResult.results to measurements.
Rename SimulationResult.states to state.
Extract InstructionExecutor and Instructions to separate files.

Remove QuantumState::testInitialize.
Remove explicit instantiations of QuantumState::apply<1,2,3>.

TODO: bit_measurement_register test.
@rturrado rturrado changed the title Manage bit register variables Manage bit (register) variables Jun 18, 2024
Add conan/profiles/base.
Add boost/*:header_only=True to conan/profiles/base.
…mplitude_t.

Change SimulationResult.bitRegisterMeasuremnents to bitMeasurements.
Change SimulationResult.operator<< to print bit measurements, qubit register, and bit register.
@rturrado rturrado merged commit e7dc38d into develop Aug 13, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Code] Manage bit (register) variables
1 participant