Skip to content

Commit

Permalink
Fix realloc after free
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Jul 12, 2024
1 parent a25da8d commit 8de9edc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pennylane_qrack/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
Version number (major.minor.patch[-label])
"""

__version__ = "0.7.0"
__version__ = "0.7.1"
7 changes: 4 additions & 3 deletions pennylane_qrack/qrack_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
}
}

qsim = QSIM_CONFIG(mapped_qubits);
qsim = QSIM_CONFIG(0U);
}

QrackDevice &operator=(const QuantumDevice &) = delete;
Expand All @@ -516,6 +516,7 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
+ std::to_string(allocated_qubits) + " allocated qubits. "
+ "(Set your wires count high enough, for the device.)");
}
qsim->Allocate(1U);
auto it = qubit_map.begin();
std::advance(it, allocated_qubits);
const QubitIdType label = it->first;
Expand Down Expand Up @@ -589,13 +590,13 @@ struct QrackDevice final : public Catalyst::Runtime::QuantumDevice {
qsim->M(id);
// Deallocate
qsim->Dispose(id, 1U);
qubit_map.erase(label);
--allocated_qubits;
}
void ReleaseAllQubits() override
{
// State vector is left empty
qsim = QSIM_CONFIG(0U);
qubit_map.clear();
allocated_qubits = 0;
}
[[nodiscard]] auto GetNumQubits() const -> size_t override
{
Expand Down

0 comments on commit 8de9edc

Please sign in to comment.