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

Fix reallocation after free #19

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 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
Loading