Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Checks: |
-clang-analyzer-core.NullDereference,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-pro-bounds-avoid-unchecked-container-access,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-special-member-functions,
-cppcoreguidelines-avoid-magic-numbers,
Expand All @@ -22,6 +23,7 @@ Checks: |
-modernize-use-trailing-return-type,
performance-*,
portability-*,
-portability-avoid-pragma-once,
readability-*,
-readability-identifier-length,
-readability-magic-numbers,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions: {}
jobs:
build-sdist:
name: 🐍 Packaging
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
permissions:
contents: read

Expand All @@ -31,7 +31,7 @@ jobs:
windows-2022,
windows-11-arm,
]
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
permissions:
Expand Down
25 changes: 14 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ permissions: {}
jobs:
change-detection:
name: 🔍 Change
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
permissions:
contents: read

Expand All @@ -39,7 +39,7 @@ jobs:
compiler: gcc
preset: debug
run-on-draft: true
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
compiler: ${{ matrix.compiler }}
Expand All @@ -64,7 +64,7 @@ jobs:
compiler: clang
preset: debug
run-on-draft: true
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
compiler: ${{ matrix.compiler }}
Expand All @@ -89,7 +89,7 @@ jobs:
compiler: msvc
preset: debug
run-on-draft: true
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
compiler: ${{ matrix.compiler }}
Expand All @@ -102,10 +102,10 @@ jobs:
name: 🇨 Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cpp-linter)
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
build-project: true
clang-version: 20
clang-version: 23
files-changed-only: true
install-pkgs: "nanobind==3.0.1"
setup-python: true
Expand All @@ -122,7 +122,7 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-26.04, ubuntu-26.04-arm, macos-26, windows-2022]
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
permissions:
Expand All @@ -132,7 +132,7 @@ jobs:
name: 🐍 Coverage
needs: [change-detection, python-tests]
if: fromJSON(needs.change-detection.outputs.run-python-tests)
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
permissions:
contents: read
id-token: write
Expand All @@ -141,19 +141,22 @@ jobs:
name: 🐍 Lint
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-python-linter)
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
check-stubs: true
enable-ty: true
enable-mypy: false
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
permissions:
contents: read

build-sdist:
name: 🚀 CD
needs: change-detection
if: fromJSON(needs.change-detection.outputs.run-cd)
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
permissions:
contents: read

Expand All @@ -172,7 +175,7 @@ jobs:
windows-2022,
windows-11-arm,
]
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-mqt-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ permissions: {}
jobs:
update-mqt-core:
name: ⬆️ Update MQT Core
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-mqt-core-update.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-mqt-core-update.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
max-major-version: "3"
secrets:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fail-fast: false
matrix:
runs-on: [ubuntu-26.04, macos-26, windows-2022]
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
runs-on: ${{ matrix.runs-on }}
setup-z3: true
Expand All @@ -32,7 +32,7 @@ jobs:
name: Create issue on failure
needs: qiskit-upstream-tests
if: ${{ always() }}
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@ace7363a2a8e036e5efc6717be67f1eda29a120e # v2.4.2
uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@17f5c58e46c51027501e7d8d38dc182654ed035c # v2.5.0
with:
tests-result: ${{ needs.qiskit-upstream-tests.result }}
permissions:
Expand Down
46 changes: 27 additions & 19 deletions bindings/InterfaceBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ void checkOrThrow(Result result) {
}
}

} // namespace

/**
* @brief A representation of statevectors in C++ style, using std::vector
* instead of a raw pointer.
Expand All @@ -68,8 +66,10 @@ struct StatevectorCPP {
std::vector<Complex> amplitudes;
};

} // namespace

// NOLINTNEXTLINE(misc-use-internal-linkage)
void bindFramework(nb::module_& m) {
void bindFramework(const nb::module_& m) {
// Bind the Result enum
nb::enum_<Result>(m, "Result", "Represents the result of an operation.")
.value("OK", OK, "Indicates that the operation was successful.")
Expand Down Expand Up @@ -555,13 +555,17 @@ index of the register.
"get_state_vector_full",
[](SimulationState* self) {
const size_t numQubits = self->getNumQubits(self);
const std::vector<Complex> amplitudes(1 << numQubits);
StatevectorCPP result{.numQubits = numQubits,
.numStates = 1ULL << numQubits,
.amplitudes = amplitudes};
Statevector output{.numQubits = numQubits,
.numStates = result.numStates,
.amplitudes = result.amplitudes.data()};
const std::vector<Complex> amplitudes(1ULL << numQubits);
StatevectorCPP result{
.numQubits = numQubits,
.numStates = 1ULL << numQubits,
.amplitudes = amplitudes,
};
const Statevector output{
.numQubits = numQubits,
.numStates = result.numStates,
.amplitudes = result.amplitudes.data(),
};
checkOrThrow(self->getStateVectorFull(self, &output));
return result;
},
Expand All @@ -573,13 +577,17 @@ index of the register.
"get_state_vector_sub",
[](SimulationState* self, std::vector<size_t> qubits) {
const size_t numQubits = qubits.size();
const std::vector<Complex> amplitudes(1 << numQubits);
StatevectorCPP result{.numQubits = numQubits,
.numStates = 1ULL << numQubits,
.amplitudes = amplitudes};
Statevector output{.numQubits = numQubits,
.numStates = result.numStates,
.amplitudes = result.amplitudes.data()};
const std::vector<Complex> amplitudes(1ULL << numQubits);
StatevectorCPP result{
.numQubits = numQubits,
.numStates = 1ULL << numQubits,
.amplitudes = amplitudes,
};
const Statevector output{
.numQubits = numQubits,
.numStates = result.numStates,
.amplitudes = result.amplitudes.data(),
};
checkOrThrow(self->getStateVectorSub(self, numQubits, qubits.data(),
&output));
return result;
Expand Down Expand Up @@ -690,7 +698,7 @@ This is the main class of the `mqt-debugger` library, allowing developers to ste
}

// NOLINTNEXTLINE(misc-use-internal-linkage)
void bindDiagnostics(nb::module_& m) {
void bindDiagnostics(const nb::module_& m) {
// Bind the ErrorCauseType enum
nb::enum_<ErrorCauseType>(m, "ErrorCauseType",
"The type of a potential error cause.")
Expand Down Expand Up @@ -882,7 +890,7 @@ suggested position.
.def(
"suggest_new_assertions",
[](Diagnostics* self) {
const size_t stringSize = 2 << 17;
const size_t stringSize = 2U << 17U;
const size_t count =
self->suggestNewAssertions(self, nullptr, nullptr, 0);
std::vector<size_t> positions(count);
Expand Down
4 changes: 2 additions & 2 deletions bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace nb = nanobind;
using namespace nb::literals;

// forward declarations
void bindFramework(nb::module_& m);
void bindDiagnostics(nb::module_& m);
void bindFramework(const nb::module_& m);
void bindDiagnostics(const nb::module_& m);
void bindBackend(nb::module_& m);

NB_MODULE(MQT_DEBUGGER_MODULE_NAME, m) {
Expand Down
2 changes: 1 addition & 1 deletion bindings/dd/DDSimDebugBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace mqt::debugger;
void bindBackend(nb::module_& m) {
m.def(
"create_ddsim_simulation_state",
[]() {
[] {
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
auto* state = new DDSimulationState();
createDDSimulationState(state);
Expand Down
11 changes: 7 additions & 4 deletions include/backend/dd/DDSimDebug.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,21 @@ Result ddsimGetQuantumVariableName(SimulationState* self, size_t variableIndex,
*
* The state vector is expected to be initialized with the correct number of
* qubits and allocated space for the amplitudes before calling this method.
* Only the amplitude buffer is modified.
* @param self The instance to query.
* @param output A reference to a `Statevector` instance to store the state
* vector.
* @return The result of the operation.
*/
Result ddsimGetStateVectorFull(SimulationState* self, Statevector* output);
Result ddsimGetStateVectorFull(SimulationState* self,
const Statevector* output);
/**
* @brief Gets a sub-state of the state vector of the simulation at the current
* time.
*
* The state vector is expected to be initialized with the correct number of
* qubits and allocated space for the amplitudes before calling this method.
* Only the amplitude buffer is modified.
* \n\n
*
* This method also supports the re-ordering of qubits, but does not allow
Expand All @@ -578,7 +581,7 @@ Result ddsimGetStateVectorFull(SimulationState* self, Statevector* output);
* @return The result of the operation.
*/
Result ddsimGetStateVectorSub(SimulationState* self, size_t subStateSize,
const size_t* qubits, Statevector* output);
const size_t* qubits, const Statevector* output);

/**
* @brief Sets a breakpoint at the desired position in the code.
Expand Down Expand Up @@ -688,15 +691,15 @@ bool checkAssertion(DDSimulationState* ddsim,
* @param index The index of the classical bit.
* @return The name of the classical bit.
*/
std::string getClassicalBitName(DDSimulationState* ddsim, size_t index);
std::string getClassicalBitName(const DDSimulationState* ddsim, size_t index);

/**
* @brief Gets the name of a qubit variable by its index.
* @param ddsim The simulation state to query.
* @param index The index of the qubit variable.
* @return The name of the qubit variable.
*/
std::string getQuantumBitName(DDSimulationState* ddsim, size_t index);
std::string getQuantumBitName(const DDSimulationState* ddsim, size_t index);

/**
* @brief Gets the qubit index from a variable name.
Expand Down
7 changes: 5 additions & 2 deletions include/backend/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,22 @@ struct SimulationStateStruct {
*
* The state vector is expected to be initialized with the correct number of
* qubits and allocated space for the amplitudes before calling this method.
* Only the amplitude buffer is modified.
* @param self The instance to query.
* @param output A reference to a `Statevector` instance to store the state
* vector.
* @return The result of the operation.
*/
Result (*getStateVectorFull)(SimulationState* self, Statevector* output);
Result (*getStateVectorFull)(SimulationState* self,
const Statevector* output);

/**
* @brief Gets a sub-state of the state vector of the simulation at the
* current time.
*
* The state vector is expected to be initialized with the correct number of
* qubits and allocated space for the amplitudes before calling this method.
* Only the amplitude buffer is modified.
* \n\n
*
* This method also supports the re-ordering of qubits, but does not allow
Expand All @@ -372,7 +375,7 @@ struct SimulationStateStruct {
* @return The result of the operation.
*/
Result (*getStateVectorSub)(SimulationState* self, size_t subStateSize,
const size_t* qubits, Statevector* output);
const size_t* qubits, const Statevector* output);

/**
* @brief Sets a breakpoint at the desired position in the code.
Expand Down
4 changes: 2 additions & 2 deletions include/common/ComplexMathematics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace mqt::debugger {
* @param c The complex number.
* @return The computed magnitude.
*/
double complexMagnitude(Complex& c);
double complexMagnitude(const Complex& c);

/**
* @brief Add two complex numbers.
Expand Down Expand Up @@ -64,7 +64,7 @@ Complex complexConjugate(const Complex& c);
* @param qubit2 The second qubit to check.
* @return True if the qubits are entangled, false otherwise.
*/
bool areQubitsEntangled(std::vector<std::vector<Complex>>& densityMatrix,
bool areQubitsEntangled(const std::vector<std::vector<Complex>>& densityMatrix,
size_t qubit1, size_t qubit2);

/**
Expand Down
Loading
Loading