Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Qiskit/qiskit into deprecat…
Browse files Browse the repository at this point in the history
…e-accidents
  • Loading branch information
ElePT committed Jul 24, 2024
2 parents a7b7361 + e362da5 commit 7f16b67
Show file tree
Hide file tree
Showing 59 changed files with 268,164 additions and 2,940 deletions.
113 changes: 1 addition & 112 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,114 +1,3 @@
# Code of Conduct

## Our Pledge

The Qiskit Community is dedicated to our values of treating every individual
with respect and dignity. In the interest of fostering an open and welcoming
environment, all participants, including attendees, speakers, sponsors,
volunteers, online contributors, and IBM employees are expected to show
courtesy for each other and our community by creating a harassment-free
experience for everyone, regardless of age, personal appearance, disability,
ethnicity, gender identity and expression, body size, level of experience,
nationality, race, religion, caste, or sexual identity and orientation.
Expected behavior applies to both online and offline engagement within the
Qiskit Community.

## Scope

The purpose of this Code of Conduct is to define and enforce the values and
conduct of contributors and participants in the Qiskit open source community.
The Code of Conduct applies both within project spaces and in public spaces
when an individual is engaging with the Qiskit open source community. Examples
include attending a Qiskit event, contributing to online projects, commentary
on Slack, or representing a project or community, including using an official
project e-mail address, posting via an official social media account, or
acting as an appointed representative at an online or offline event.
Representation of a project may be further defined and clarified by project
maintainers.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints, experiences, and cultures
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
- Being mindful of your surroundings and your fellow participants and listening
to others
- Valuing the contributions of all participants
- Engaging in collaboration before conflict
- Pointing out unintentionally racist, sexist, casteist, or biased comments and
jokes made by community members when they happen

Examples of unacceptable behavior by participants, even when presented as
"ironic" or "joking," include:

- The use of sexualized language or imagery and unwelcome physical contact,
sexual attention, or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment, including offensive or degrading language
- Publishing others' private information, such as a physical or electronic
address, without explicit permission. This includes any sort of "outing" of
any aspect of someone's identity without their consent.
- "Doxxing," Publishing screenshots or quotes, especially from identity slack
channels, private chat, or public events, without all quoted users' explicit
consent.
- Engaging in spamming activities, such as repeatedly sending unsolicited messages, LLMs (Large Language Models) output, advertisements, or promotional content to community members without previous IBM authorization.
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Responsibilities & Enforcement

The entire Qiskit community is responsible for upholding the terms of the Code
of Conduct in Qiskit Community events and spaces and reporting violations if
they see them. The internal Qiskit team at IBM is ultimately responsible for
clarifying the standards of acceptable behavior and enforcement, and is expected
to take appropriate and fair corrective action in response to any instances of
unacceptable behavior.

If a participant or contributor engages in negative or harmful behavior, IBM
will take any action they deem appropriate, including but not limited to
issuing warnings, expulsion from an event with no refund, deleting comments,
permanent banning from future events or online community, or calling local law
enforcement. IBM has the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, or to temporarily or permanently ban any
contributor or participant for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

If you see a Code of Conduct violation:

1. If you feel comfortable, let the person know that what they did is not
appropriate and ask them to stop and/or edit or delete their message(s) or
comment(s).
2. If the person does not immediately stop the behavior or correct the issue,
or if you're uncomfortable speaking up, flag a moderator and, if appropriate,
fill out the anonymous
[Code of Conduct violation form](https://airtable.com/shrl5mEF4Eun1aIDm).
3. The Qiskit Community will open an investigation upon receiving your form
entry. When reporting, please include any relevant details, links,
screenshots, context, or other information that may be used to better
understand and resolve the situation.
4. If the code of conduct violation occurs at an event and requires immediate
response or contains a concern about an individual attending an upcoming
event, contact the event's on-call Code of Conduct point of contact listed
in the event specific code of conduct document. If you don't feel comfortable
speaking to the point of contact in person, fill out a Code of Conduct
violation form entry and include the details of the event so that the Code of
Conduct enforcement board can contact the event's on-call Code of Conduct
point of contact.
5. If an IBM employee witnesses a Code of Conduct violation at any time, such as
at events, in a Slack channel, or open source forums, it is their
responsibility to file a Code of Conduct violation report.

This Code of Conduct does not supersede existing IBM corporate policies, such as
the IBM Business Conduct Guidelines and IBM Business Partner Code of Conduct.
IBM employees must follow IBM's Business Conduct Guidelines. IBM's business
partners must follow the IBM Business Partner Code of Conduct. IBM employees
concerned with a fellow IBMer's behavior should follow IBM's own internal HR
reporting protocols, which include engaging the offending IBMer's manager and
involving IBM Concerns and Appeals. IBM employees concerned with an IBM
business partner's behavior should notify [email protected].
All members of this project agree to adhere to the Qiskit Code of Conduct listed at [docs.quantum.ibm.com/open-source/code-of-conduct](https://docs.quantum.ibm.com/open-source/code-of-conduct)
37 changes: 29 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ community in this goal.
* [Testing](#testing)
* [Style and Lint](#style-and-lint)
* [Building API docs locally](#building-api-docs-locally)
* [Troubleshooting docs builds](#troubleshooting-docs-builds)
* [Development Cycle](#development-cycle)
* [Branches](#branches)
* [Release Cycle](#release-cycle)
Expand Down Expand Up @@ -651,21 +652,41 @@ rather than via `tox`. If you have installed the development packages in your py
`pip install -r requirements-dev.txt`, then `ruff` and `black` will be available and can be run from
the command line. See [`tox.ini`](tox.ini) for how `tox` invokes them.


## Building API docs locally

If you have made changes to the API documentation, you can run the command below
to build documentation locally to review the html output.
The easiest and recommended way to build the documentation is to use [**tox**](https://tox.readthedocs.io/en/latest/#):
The API documentation is built with Sphinx.
We recommend that you use [**tox**](https://tox.readthedocs.io/en/latest) to orchestrate this.
Run a complete documentation build with
```
tox -e docs
```

The documentation output will be located at `docs/_build/html`.
Open the `index.html` file there in your browser to find the main page.

### Troubleshooting docs builds

When you build documentation, you might get errors that look like
```
tox -edocs
ValueError: earliest-version set to unknown revision '1.0.0rc1'
```
If so, you need to fetch Qiskit's `git` tags and stable branches, in order to fully build the release notes.
To do this, run the command:
```
git fetch --tags upstream
```
where `upstream` is your name for the [git remote repository](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) that corresponds to https://github.com/Qiskit/qiskit (this repository).
You might need to re-run this command if Qiskit has issued a new release since the last time you built the documentation.

Once you run this command, the output will be located at `docs/_build/html`.
Then, open up the file `index.html` in your browser.
Sometimes, you might get errors about "names not existing" or "failed to import" during the docs build, even when the test suite passes.
This can mean that Sphinx's cache has become invalidated, but hasn't been successfully cleared.
Use the command:
```
tox -e docs-clean
```
to fully clean out all documentation build artefacts and partial builds, and see if the problem persists.

Sometimes Sphinx can get in a bad cache state. Run `tox -e docs-clean`
to reset Sphinx's cache.

## Development cycle

Expand Down
5 changes: 3 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ license = "Apache-2.0"
#
# Each crate can add on specific features freely as it inherits.
[workspace.dependencies]
bytemuck = "1.16"
indexmap.version = "2.2.6"
hashbrown.version = "0.14.0"
num-complex = "0.4"
Expand Down
77 changes: 32 additions & 45 deletions crates/accelerate/src/convert_2q_block_matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,32 @@ use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
use smallvec::SmallVec;

use qiskit_circuit::bit_data::BitData;
use qiskit_circuit::circuit_instruction::{operation_type_to_py, CircuitInstruction};
use qiskit_circuit::circuit_instruction::CircuitInstruction;
use qiskit_circuit::dag_node::DAGOpNode;
use qiskit_circuit::gate_matrix::ONE_QUBIT_IDENTITY;
use qiskit_circuit::imports::QI_OPERATOR;
use qiskit_circuit::operations::{Operation, OperationType};
use qiskit_circuit::operations::{Operation, OperationRef};

use crate::QiskitError;

fn get_matrix_from_inst<'py>(
py: Python<'py>,
inst: &'py CircuitInstruction,
) -> PyResult<Array2<Complex64>> {
match inst.operation.matrix(&inst.params) {
Some(mat) => Ok(mat),
None => match inst.operation {
OperationType::Standard(_) => Err(QiskitError::new_err(
"Parameterized gates can't be consolidated",
)),
OperationType::Gate(_) => Ok(QI_OPERATOR
.get_bound(py)
.call1((operation_type_to_py(py, inst)?,))?
.getattr(intern!(py, "data"))?
.extract::<PyReadonlyArray2<Complex64>>()?
.as_array()
.to_owned()),
_ => unreachable!("Only called for unitary ops"),
},
if let Some(mat) = inst.op().matrix(&inst.params) {
Ok(mat)
} else if inst.operation.try_standard_gate().is_some() {
Err(QiskitError::new_err(
"Parameterized gates can't be consolidated",
))
} else {
Ok(QI_OPERATOR
.get_bound(py)
.call1((inst.get_operation(py)?,))?
.getattr(intern!(py, "data"))?
.extract::<PyReadonlyArray2<Complex64>>()?
.as_array()
.to_owned())
}
}

Expand Down Expand Up @@ -127,34 +126,22 @@ pub fn change_basis(matrix: ArrayView2<Complex64>) -> Array2<Complex64> {

#[pyfunction]
pub fn collect_2q_blocks_filter(node: &Bound<PyAny>) -> Option<bool> {
match node.downcast::<DAGOpNode>() {
Ok(bound_node) => {
let node = bound_node.borrow();
match &node.instruction.operation {
OperationType::Standard(gate) => Some(
gate.num_qubits() <= 2
&& node
.instruction
.extra_attrs
.as_ref()
.and_then(|attrs| attrs.condition.as_ref())
.is_none()
&& !node.is_parameterized(),
),
OperationType::Gate(gate) => Some(
gate.num_qubits() <= 2
&& node
.instruction
.extra_attrs
.as_ref()
.and_then(|attrs| attrs.condition.as_ref())
.is_none()
&& !node.is_parameterized(),
),
_ => Some(false),
}
}
Err(_) => None,
let Ok(node) = node.downcast::<DAGOpNode>() else {
return None;
};
let node = node.borrow();
match node.instruction.op() {
gate @ (OperationRef::Standard(_) | OperationRef::Gate(_)) => Some(
gate.num_qubits() <= 2
&& node
.instruction
.extra_attrs
.as_ref()
.and_then(|attrs| attrs.condition.as_ref())
.is_none()
&& !node.is_parameterized(),
),
_ => Some(false),
}
}

Expand Down
35 changes: 14 additions & 21 deletions crates/accelerate/src/euler_one_qubit_decomposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ pub fn compute_error_list(
.iter()
.map(|node| {
(
node.instruction.operation.name().to_string(),
node.instruction.op().name().to_string(),
smallvec![], // Params not needed in this path
)
})
Expand Down Expand Up @@ -988,11 +988,10 @@ pub fn optimize_1q_gates_decomposition(
.iter()
.map(|node| {
if let Some(err_map) = error_map {
error *=
compute_error_term(node.instruction.operation.name(), err_map, qubit)
error *= compute_error_term(node.instruction.op().name(), err_map, qubit)
}
node.instruction
.operation
.op()
.matrix(&node.instruction.params)
.expect("No matrix defined for operation")
})
Expand Down Expand Up @@ -1046,24 +1045,18 @@ fn matmul_1q(operator: &mut [[Complex64; 2]; 2], other: Array2<Complex64>) {

#[pyfunction]
pub fn collect_1q_runs_filter(node: &Bound<PyAny>) -> bool {
let op_node = node.downcast::<DAGOpNode>();
match op_node {
Ok(bound_node) => {
let node = bound_node.borrow();
node.instruction.operation.num_qubits() == 1
&& node.instruction.operation.num_clbits() == 0
&& node
.instruction
.operation
.matrix(&node.instruction.params)
.is_some()
&& match &node.instruction.extra_attrs {
None => true,
Some(attrs) => attrs.condition.is_none(),
}
let Ok(node) = node.downcast::<DAGOpNode>() else {
return false;
};
let node = node.borrow();
let op = node.instruction.op();
op.num_qubits() == 1
&& op.num_clbits() == 0
&& op.matrix(&node.instruction.params).is_some()
&& match &node.instruction.extra_attrs {
None => true,
Some(attrs) => attrs.condition.is_none(),
}
Err(_) => false,
}
}

#[pymodule]
Expand Down
Loading

0 comments on commit 7f16b67

Please sign in to comment.