Skip to content

Commit

Permalink
For #2305
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanro committed Feb 8, 2025
1 parent f1edeed commit b9714c0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
prelude: >
Removed code that was never executed in ``MPS::sample_measure``, also removed
the ``shots`` parameter as it wasn't used.
features:
- |
Probably the compiler can optimize out those things, but the code is cleaner
this way. The ``params`` parameter was removed from ``MPS::sample_measure``
as it's not used, also a check and unreacheable code from the same function
is removed.
- |
There is no change in behaviour, just code cleanup.
Refer to `#2305 <https://github.com/Qiskit/qiskit-aer/issues/2305>`
for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ std::vector<SampleVector> State::sample_measure_all(uint_t shots,

#pragma omp parallel for if (getenv("PRL_PROB_MEAS"))
for (int_t i = 0; i < static_cast<int_t>(shots); i++) {
auto single_result = qreg_.sample_measure(shots, rng);
auto single_result = qreg_.sample_measure(rng);
all_samples[i].from_vector(single_result);
}
return all_samples;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1637,7 +1637,7 @@ reg_t MPS::sort_measured_values(const reg_t &input_outcome,
// probability. We then update 'mat' by contracting it with the suitable
// matrix (0 or 1).

reg_t MPS::sample_measure(uint_t shots, RngEngine &rng) const {
reg_t MPS::sample_measure(RngEngine &rng) const {
double prob = 1;
reg_t current_measure(num_qubits_);
cmatrix_t mat;
Expand Down Expand Up @@ -1683,10 +1683,6 @@ uint_t MPS::sample_measure_single_qubit(uint_t qubit, double &prob, double rnd,
// measurement outcome
if (qubit == 0) {
mat = q_reg_[qubit].get_data(measurement);
if (qubit != 0) // multiply mat by left lambda
for (uint_t col = 0; col < mat.GetColumns(); col++)
for (uint_t row = 0; row < mat.GetRows(); row++)
mat(row, col) *= lambda_reg_[qubit - 1][row];
} else {
mat = mat * q_reg_[qubit].get_data(measurement);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class MPS {

reg_t apply_measure(const reg_t &qubits, const rvector_t &rnds);
reg_t apply_measure_internal(const reg_t &qubits, const rvector_t &rands);
reg_t sample_measure(uint_t shots, RngEngine &rng) const;
reg_t sample_measure(RngEngine &rng) const;

//----------------------------------------------------------------
// Function name: initialize_from_statevector_internal
Expand Down

0 comments on commit b9714c0

Please sign in to comment.