Skip to content

Commit

Permalink
Merge pull request #487 from atilag/stable-0.3.4
Browse files Browse the repository at this point in the history
Stable 0.3.4
  • Loading branch information
atilag authored Dec 9, 2019
2 parents 68e429e + deaa410 commit 86a8758
Show file tree
Hide file tree
Showing 30 changed files with 2,244 additions and 1,118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ contrib/standalone/version.hpp
test/.asv

.tox/
.stestr/

docs/_build/
docs/stubs/
Expand Down
3 changes: 3 additions & 0 deletions .stestr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[DEFAULT]
test_path=./test/terra
parallel_class=True
21 changes: 18 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
notifications:
email: false

cache: pip
cache:
pip: true
directories:
- .stestr
sudo: false

###############################################################################
Expand Down Expand Up @@ -42,10 +45,15 @@ stage_linux: &stage_linux
- sudo apt-get -y update
- sudo apt-get -y install g++-7
- sudo apt-get -y install libopenblas-dev
before_script:
- |
if [ ! "$(ls -A .stestr)" ]; then
rm -rf .stestr
fi
script:
- python setup.py bdist_wheel -- -DCMAKE_CXX_COMPILER=g++-7 -- -j4
- pip install dist/qiskit_aer*whl
- python -m unittest discover -s test -v
- stestr run --slowest

stage_osx: &stage_osx
<<: *stage_generic
Expand All @@ -56,6 +64,7 @@ stage_osx: &stage_osx
pip: true
directories:
- ~/python-interpreters/
- .stestr
before_install:
# Travis does not provide support for Python 3 under osx - it needs to be
# installed manually.
Expand All @@ -71,10 +80,16 @@ stage_osx: &stage_osx
virtualenv --python ~/python-interpreters/$PYTHON_VERSION/bin/python venv
source venv/bin/activate
fi
before_script:
- |
if [ ! "$(ls -A .stestr)" ]; then
rm -rf .stestr
fi
script:
- python setup.py bdist_wheel -- -- -j4
- pip install dist/qiskit_aer*whl
- python -m unittest discover -s test -v
- stestr run --slowest

###############################################################################
# Stage-related definitions
Expand Down
24 changes: 22 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,29 @@ Changelog](http://keepachangelog.com/en/1.0.0/).
> - **Fixed**: for any bug fixes.
> - **Security**: in case of vulnerabilities.
[UNRELEASED](https://github.com/Qiskit/qiskit-aer/compare/0.3.2...HEAD)
[UNRELEASED](https://github.com/Qiskit/qiskit-aer/compare/0.3.3...HEAD)
=======================================================================

Added
-----
- Added support for probabilities snapshot and Pauli expectation value snapshot in the stabilizer simulator (\#423)

Changed
-------

Removed
-------

Fixed
-----
- MPS simulation method: fixed computation of snapshot_probabilities
on subsets of the qubits, in any ordering (\#424)
- Fixes bug where cu3 was being applied as cu1 for unitary_simulator (\#483)


[0.3.3](https://github.com/Qiskit/qiskit-aer/compare/0.3.2...0.3.3) - 2019-11-14
====================================================================================

Added
-----
- Added controlled gates (``cu1``, ``cu2``, ``cu3``) to simulator basis_gates (\#417)
Expand Down Expand Up @@ -53,7 +73,7 @@ Removed
Fixed
-----
- Fix sdist to always attempt to build (\#401)

- New (efficient) implementation for expectation_value_pauli in MPS simulation method (\#344)


[0.3.1](https://github.com/Qiskit/qiskit-aer/compare/0.3.0...0.3.1) - 2019-10-15
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ jobs:
set -e
source activate qiskit-aer-$(Build.BuildNumber)
pip install dist/qiskit_aer*.whl
python -m unittest discover -s test/terra -v
stestr run --slowest
displayName: 'Install Aer and Run Tests'
2 changes: 1 addition & 1 deletion qiskit/providers/aer/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.3
0.3.4
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Sphinx>=1.8.3
sphinx-rtd-theme>=0.4.0
sphinx-tabs>=1.1.11
jupyter-sphinx
stestr>=2.5.0
37 changes: 24 additions & 13 deletions src/simulators/matrix_product_state/matrix_product_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ enum class Snapshots {
expval_matrix//, //expval_matrix_var
};

// Enum class for different types of expectation values
enum class SnapshotDataType {average, average_var, pershot};

//=========================================================================
// Matrix Product State subclass
Expand Down Expand Up @@ -110,7 +112,7 @@ class State : public Base::State<matrixproductstate_t> {
// Return the set of qobj snapshot types supported by the State
virtual stringset_t allowed_snapshots() const override {
//TODO: Review this
return {"statevector", "memory", "register",
return {"statevector", "memory", "register", "probabilities",
"expectation_value_pauli", //"expectation_value_pauli_with_variance",
"expectation_value_matrix"//, //"expectation_value_matrix_with_variance"
};
Expand Down Expand Up @@ -237,7 +239,7 @@ class State : public Base::State<matrixproductstate_t> {
// Snapshot current qubit probabilities for a measurement (average)
void snapshot_probabilities(const Operations::Op &op,
ExperimentData &data,
bool variance);
SnapshotDataType type);

// Snapshot the expectation value of a Pauli operator
void snapshot_pauli_expval(const Operations::Op &op,
Expand Down Expand Up @@ -469,13 +471,13 @@ void State::snapshot_pauli_expval(const Operations::Op &op,

//Compute expval components
complex_t expval(0., 0.);
double one_expval = 0;

for (const auto &param : op.params_expval_pauli) {
complex_t coeff = param.first;
string pauli_matrices = param.second;
one_expval = qreg_.expectation_value(op.qubits, pauli_matrices);
expval += coeff * one_expval;;
std::string pauli_matrices = param.second;
complex_t pauli_expval = qreg_.expectation_value_pauli(op.qubits, pauli_matrices);

expval += coeff * pauli_expval;
}
data.add_pershot_snapshot("expectation_value", op.string_params[0], expval);
}
Expand Down Expand Up @@ -507,17 +509,19 @@ void State::snapshot_state(const Operations::Op &op,
std::string name) {
cvector_t statevector;
qreg_.full_state_vector(statevector);

data.add_pershot_snapshot("statevector", op.string_params[0], statevector);
}

void State::snapshot_probabilities(const Operations::Op &op,
ExperimentData &data,
bool variance) {
MatrixProductState::MPS_Tensor full_tensor = qreg_.state_vec(0, qreg_.num_qubits()-1);
SnapshotDataType type) {
rvector_t prob_vector;
qreg_.probabilities_vector(prob_vector);
data.add_pershot_snapshot("probabilities", op.string_params[0], prob_vector);
qreg_.get_probabilities_vector(prob_vector, op.qubits);
auto probs = Utils::vec2ket(prob_vector, json_chop_threshold_, 16);
bool variance = type == SnapshotDataType::average_var;
data.add_average_snapshot("probabilities", op.string_params[0],
BaseState::creg_.memory_hex(), probs, variance);

}

void State::apply_gate(const Operations::Op &op) {
Expand Down Expand Up @@ -645,7 +649,9 @@ void State::apply_measure(const reg_t &qubits,
}

rvector_t State::measure_probs(const reg_t &qubits) const {
return qreg_.probabilities(qubits);
rvector_t probvector;
qreg_.get_probabilities_vector(probvector, qubits);
return probvector;
}

std::vector<reg_t> State::sample_measure(const reg_t &qubits,
Expand All @@ -668,7 +674,6 @@ std::vector<reg_t> State::sample_measure(const reg_t &qubits,

void State::apply_snapshot(const Operations::Op &op, ExperimentData &data) {
// Look for snapshot type in snapshotset

auto it = snapshotset_.find(op.name);
if (it == snapshotset_.end())
throw std::invalid_argument("MatrixProductState::invalid snapshot instruction \'" +
Expand All @@ -678,6 +683,11 @@ void State::apply_snapshot(const Operations::Op &op, ExperimentData &data) {
snapshot_state(op, data, "statevector");
break;
}
case Snapshots::probs: {
// get probs as hexadecimal
snapshot_probabilities(op, data, SnapshotDataType::average);
break;
}
case Snapshots::expval_pauli: {
snapshot_pauli_expval(op, data, false);
break;
Expand Down Expand Up @@ -721,6 +731,7 @@ State::sample_measure_with_prob(const reg_t &qubits,
return std::make_pair(outcome, probs[outcome]);
}


//-------------------------------------------------------------------------
} // end namespace MatrixProductState
//-------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 86a8758

Please sign in to comment.