Skip to content

Commit

Permalink
branch smash
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranra committed Nov 26, 2024
1 parent 31db6c3 commit 444c290
Show file tree
Hide file tree
Showing 71 changed files with 1,143 additions and 2,256 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ repos:
- id: debug-statements

- repo: https://github.com/crate-ci/typos
rev: v1.26.0
rev: v1.27.0
hooks:
- id: typos
args: []

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
rev: v0.7.2
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

33 changes: 16 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ venv: ## Build Python virtual environment and install requirements
# Requirements
# ------------
.PHONY: requirements
requirements: updatereqs installreqs metadeps ## Install/refresh Python project requirements including those needed for development
requirements: metadeps installreqs ## Install/refresh Python project requirements including those needed for development

.PHONY: updatereqs
updatereqs: ## Auto update and generate requirements.txt
Expand Down Expand Up @@ -60,7 +60,7 @@ installreqs: upgrade-pip ## Install Python project requirements

.PHONY: metadeps
metadeps: upgrade-pip ## Install extra dependencies used to develop/build this package
$(VENV_BIN)/pip install -U pip-tools pre-commit pytest hypothesis maturin
$(VENV_BIN)/pip install -U setuptools pip-tools pre-commit pytest hypothesis maturin

# Function to extract version from pyproject.toml
define get_version
Expand All @@ -70,32 +70,32 @@ endef
# Building development environments
# ---------------------------------
.PHONY: build
build: venv ## Compile and install for development
build: requirements ## Compile and install for development
@unset CONDA_PREFIX && cd python/pecos-rslib/ && $(VENV_BIN)/maturin develop
@unset CONDA_PREFIX && cd python/quantum-pecos && $(VENV_BIN)/pip install -e .[all]

.PHONY: build-basic
build-basic: venv ## Compile and install for development but do not include install extras
build-basic: requirements ## Compile and install for development but do not include install extras
@unset CONDA_PREFIX && cd python/pecos-rslib/ && $(VENV_BIN)/maturin develop
@unset CONDA_PREFIX && cd python/quantum-pecos && $(VENV_BIN)/pip install -e .

.PHONY: build-release
build-release: venv ## Build a faster version of binaries
build-release: requirements ## Build a faster version of binaries
@unset CONDA_PREFIX && cd python/pecos-rslib/ && $(VENV_BIN)/maturin develop --release
@unset CONDA_PREFIX && cd python/quantum-pecos && $(VENV_BIN)/pip install -e .[all]

.PHONY: build-native
build-native: venv ## Build a faster version of binaries with native CPU optimization
build-native: requirements ## Build a faster version of binaries with native CPU optimization
@unset CONDA_PREFIX && cd python/pecos-rslib/ && RUSTFLAGS='-C target-cpu=native' \
&& $(VENV_BIN)/maturin develop --release
@unset CONDA_PREFIX && cd python/quantum-pecos && $(VENV_BIN)/pip install -e .[all]

# Documentation
# -------------

.PHONY: docs
docs: ## Generate documentation
#TODO: ...
# .PHONY: docs
# docs: ## Generate documentation
# #TODO: ...

# Linting / formatting
# --------------------
Expand All @@ -113,7 +113,7 @@ fmt: ## Run autoformatting for cargo
cargo fmt --all -- --check

.PHONY: pre-commit ## Run all quality checks / linting / reformatting
pre-commit: venv fmt clippy
pre-commit: fmt clippy
$(VENV_BIN)/pre-commit run --all-files

# Testing
Expand All @@ -131,13 +131,13 @@ pytest: ## Run tests on the Python package (not including optional dependencies
pytest-dep: ## Run tests on the Python package only for optional dependencies. ASSUMES: previous build command
@cd python/ && $(VENV_BIN)/pytest tests -m optional_dependency

.PHONY: pytest-doc
pydoctest: ## Run doctests with pytest. ASSUMES: A build command was ran previously. ASSUMES: previous build command
# TODO: update and install docs requirements
@cd python/ && $(VENV_BIN)/pytest docs --doctest-glob=*.rst --doctest-continue-on-failure
# .PHONY: pytest-doc
# pydoctest: ## Run doctests with pytest. ASSUMES: A build command was ran previously. ASSUMES: previous build command
# # TODO: update and install docs requirements
# @cd python/ && $(VENV_BIN)/pytest docs --doctest-glob=*.rst --doctest-continue-on-failure

.PHONY: test-all
test-all: rstest pytest pytest-dep pydoctest ## Run all tests. ASSUMES: previous build command
.PHONY: test
test: rstest pytest pytest-dep ## Run all tests. ASSUMES: previous build command

# Utility
# -------
Expand All @@ -157,7 +157,6 @@ clean: ## Clean up caches and build artifacts
@rm -rf .ruff_cache/
@rm -rf **/.hypothesis/
@rm -rf **/junit/
@rm -rf **/.venv/
@cargo clean

# Help
Expand Down
39 changes: 13 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ You may find most of these crates in crates.io if you wish to utilize only a par

We follow semantic versioning principles. However, before version 1.0.0, the MAJOR.MINOR.BUG format sees the roles
of MAJOR and MINOR shifted down a step. This means potential breaking changes might occur between MINOR increments, such
as moving from versions 0.1.0 to 0.2.0. All Python packages and all Rust crates will have the same version amongst their
as moving from versions 0.1.0 to 0.2.0.

All Python packages and all Rust crates will have the same version amongst their
respective languages; however, Python and Rust versioning will differ.

## Latest Development
Expand All @@ -60,7 +62,7 @@ Stay updated with the latest developments on the

### Python Package

To install the main Python package:
To install the main Python package for general usage:

```sh
pip install quantum-pecos
Expand All @@ -76,7 +78,13 @@ pip install quantum-pecos[all]

**NOTE:** The `quantum-pecos` package is imported like: `import pecos` and not `import quantum_pecos`.

Certain simulators have special requirements and are not installed by the command above. Installation instructions for
**NOTE:** To install pre-releases (the latest development code) from pypi you may have to specify the version you are
interested like so (e.g., for version `0.6.0.dev5`):
```sh
pip install quantum-pecos==0.6.0.dev5
```

**NOTE:** Certain simulators have special requirements and are not installed by the command above. Installation instructions for
these are provided [here](#simulators-with-special-requirements).


Expand All @@ -91,29 +99,8 @@ pecos = "0.x.x" # Replace with the latest version

## Development Setup

For developers who want to contribute or modify PECOS:

1. Clone the repository:
```sh
git clone https://github.com/PECOS-packages/PECOS.git
cd PECOS
```

2. Set up the development environment using the makefile (for Windows you may need to use a shell that has access to Linux commands such as utilizing [git bash](https://gitforwindows.org/)):
```sh
make venv
make build
```

3. Run tests:
```sh
make test
```

4. Run pre-commit (after [installing it](https://pre-commit.com/))
```sh
make pre-commit
```
If you are interested in editing or developing the code in this project, see this
[development documentation](dev_steps.md) to get started.

## Simulators with special requirements

Expand Down
23 changes: 17 additions & 6 deletions crates/benchmarks/benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
// Copyright 2024 The PECOS Developers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under
// the License.

use criterion::{criterion_group, criterion_main, Criterion};

mod modules {
pub mod element_ops;
pub mod hadamard_ops;
mod helpers;
pub mod pauli_ops;
// TODO: pub mod hadamard_ops;
// TODO: pub mod pauli_ops;
pub mod set_ops;
}

use modules::{element_ops, hadamard_ops, pauli_ops, set_ops};
use modules::{element_ops, set_ops};

fn all_benchmarks(c: &mut Criterion) {
element_ops::benchmarks(c);
set_ops::benchmarks(c);
pauli_ops::benchmarks(c);
hadamard_ops::benchmarks(c);
// TODO: pauli_ops::benchmarks(c);
// TODO: hadamard_ops::benchmarks(c);
}

criterion_group! {
Expand Down
12 changes: 12 additions & 0 deletions crates/benchmarks/benches/modules/element_ops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
// Copyright 2024 The PECOS Developers
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under
// the License.

use criterion::{black_box, measurement::Measurement, BenchmarkGroup, Criterion};
use pecos_core::IndexableElement;

Expand Down
82 changes: 0 additions & 82 deletions crates/benchmarks/benches/modules/hadamard_ops.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/benchmarks/benches/modules/helpers.rs

This file was deleted.

Loading

0 comments on commit 444c290

Please sign in to comment.