Skip to content

Commit 4db36fb

Browse files
ciaranraperlinm
andauthored
Dev update
* Unroll broadcast face rotations (#110) * Upgrade to using uv instead of pip (#111) * Adding uv to Makefile * Turn on artifact generation (#117) * Add T gates with active error correction (#118) * remove t_tel_cor * bugfix in tdg_cor * fix t_cor * Permute all variables of the Steane code (#114) * compute the swap of CRegs * Add Steane-type and teleportation-based QEC for the Steane code (#115) * fix qec_steane_z * set flag bit correctly * add qec_steane_.*tel templates * fix Steane.qec_steane_tel * permute all qubits for teleportation * fix teleportation-based QEC * two flag bits for Steane.qec_tel * rename flag_bit --> flag, in agreement with elsewhere in the repo * fix If statement * fix Steane QEC and an incorrect type hint --------- Co-authored-by: Michael A. Perlin <mika.perlin@gmail.com>
1 parent 6b19d06 commit 4db36fb

File tree

37 files changed

+2499
-350
lines changed

37 files changed

+2499
-350
lines changed

.github/workflows/python-release.yml

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,20 @@ jobs:
6666
with:
6767
python-version: ${{ env.PYTHON_VERSION }}
6868

69+
- name: Install the latest version of uv
70+
uses: astral-sh/setup-uv@v4
71+
with:
72+
enable-cache: true
73+
ignore-nothing-to-cache: true
74+
cache-dependency-glob: |
75+
**/pyproject.toml
76+
**/requirements*.txt
77+
**/uv.lock
78+
6979
- name: Remove conflicting README.md
7080
run: |
7181
if [ -f crates/pecos-python/README.md ]; then
7282
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
73-
echo "Moved conflicting README.md to README.md.bak"
74-
else
75-
echo "No conflicting README.md found"
7683
fi
7784
7885
- name: Build pecos-rslib SDist
@@ -87,15 +94,13 @@ jobs:
8794
run: |
8895
if [ -f crates/pecos-python/README.md.bak ]; then
8996
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
90-
echo "Restored README.md from backup"
91-
else
92-
echo "No README.md backup found"
9397
fi
9498
95-
- name: Test pecos-rslib SDist
99+
- name: Install and test pecos-rslib SDist
96100
run: |
97-
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.tar.gz
98-
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
101+
uv sync --project .
102+
uv pip install --force-reinstall python/pecos-rslib/dist/*.tar.gz
103+
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
99104
100105
- name: Upload pecos-rslib SDist
101106
uses: actions/upload-artifact@v4
@@ -130,13 +135,20 @@ jobs:
130135
with:
131136
python-version: ${{ matrix.python-version }}
132137

138+
- name: Install the latest version of uv
139+
uses: astral-sh/setup-uv@v4
140+
with:
141+
enable-cache: true
142+
ignore-nothing-to-cache: true
143+
cache-dependency-glob: |
144+
**/pyproject.toml
145+
**/requirements*.txt
146+
**/uv.lock
147+
133148
- name: Remove conflicting README.md
134149
run: |
135150
if [ -f crates/pecos-python/README.md ]; then
136151
mv crates/pecos-python/README.md crates/pecos-python/README.md.bak
137-
echo "Moved conflicting README.md to README.md.bak"
138-
else
139-
echo "No conflicting README.md found"
140152
fi
141153
142154
- name: Build wheel
@@ -153,16 +165,14 @@ jobs:
153165
run: |
154166
if [ -f crates/pecos-python/README.md.bak ]; then
155167
mv crates/pecos-python/README.md.bak crates/pecos-python/README.md
156-
echo "Restored README.md from backup"
157-
else
158-
echo "No README.md backup found"
159168
fi
160169
161170
- name: Test wheel
162171
if: ${{ !(matrix.architecture == 'x86_64' && matrix.os == 'macos-latest') && matrix.architecture != 'aarch64' }}
163172
run: |
164-
pip install --force-reinstall --verbose python/pecos-rslib/dist/*.whl
165-
python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
173+
uv sync --project .
174+
uv pip install --force-reinstall python/pecos-rslib/dist/*.whl
175+
uv run python -c 'import pecos_rslib; print(pecos_rslib.__version__)'
166176
167177
- name: Upload wheel
168178
uses: actions/upload-artifact@v4
@@ -187,29 +197,38 @@ jobs:
187197
with:
188198
python-version: ${{ env.PYTHON_VERSION }}
189199

200+
- name: Install the latest version of uv
201+
uses: astral-sh/setup-uv@v4
202+
with:
203+
enable-cache: true
204+
ignore-nothing-to-cache: true
205+
cache-dependency-glob: |
206+
**/pyproject.toml
207+
**/requirements*.txt
208+
**/uv.lock
209+
190210
- name: Download pecos-rslib wheel
191211
uses: actions/download-artifact@v4
192212
with:
193213
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ env.PYTHON_VERSION }}
194214
path: ./pecos-rslib-wheel
195215

196-
- name: Install pecos-rslib
197-
run: pip install ./pecos-rslib-wheel/*.whl
198-
199-
- name: Install build dependencies
216+
- name: Setup environment and install dependencies
200217
run: |
201-
python -m pip install --upgrade pip
202-
pip install build
218+
uv sync --project .
219+
uv pip install ./pecos-rslib-wheel/*.whl
220+
uv pip install build
203221
204222
- name: Build quantum-pecos SDist
205223
run: |
206224
cd python/quantum-pecos
225+
uv pip install --system build
207226
python -m build --sdist --outdir dist
208227
209228
- name: Test quantum-pecos SDist
210229
run: |
211-
pip install python/quantum-pecos/dist/*.tar.gz
212-
python -c 'import pecos; print(pecos.__version__)'
230+
uv pip install python/quantum-pecos/dist/*.tar.gz
231+
uv run python -c 'import pecos; print(pecos.__version__)'
213232
214233
- name: Upload quantum-pecos SDist
215234
uses: actions/upload-artifact@v4
@@ -233,24 +252,30 @@ jobs:
233252
with:
234253
ref: ${{ inputs.sha || github.sha }}
235254

236-
- name: Set up Python ${{ matrix.python-version }}
255+
- name: Set up Python
237256
uses: actions/setup-python@v5
238257
with:
239258
python-version: ${{ matrix.python-version }}
240259

260+
- name: Install the latest version of uv
261+
uses: astral-sh/setup-uv@v4
262+
with:
263+
enable-cache: true
264+
ignore-nothing-to-cache: true
265+
cache-dependency-glob: |
266+
**/pyproject.toml
267+
**/requirements*.txt
268+
**/uv.lock
269+
241270
- name: Download pecos-rslib wheel
242271
uses: actions/download-artifact@v4
243272
with:
244273
name: wheel-pecos-rslib-ubuntu-latest-x86_64-py${{ matrix.python-version }}
245274
path: ./pecos-rslib-wheel
246275

247-
- name: Install pecos-rslib
248-
run: pip install ./pecos-rslib-wheel/*.whl
249-
250-
- name: Install build dependencies
276+
- name: Setup environment and install dependencies
251277
run: |
252-
python -m pip install --upgrade pip
253-
pip install build
278+
uv pip install --system ./pecos-rslib-wheel/*.whl build
254279
255280
- name: Build quantum-pecos wheel
256281
run: |
@@ -259,8 +284,9 @@ jobs:
259284
260285
- name: Test quantum-pecos wheel
261286
run: |
262-
pip install python/quantum-pecos/dist/*.whl
263-
python -c 'import pecos; print(pecos.__version__)'
287+
uv sync # This will use the workspace config correctly
288+
uv pip install python/quantum-pecos/dist/*.whl
289+
uv run python -c 'import pecos; print(pecos.__version__)'
264290
265291
- name: Upload quantum-pecos wheel
266292
uses: actions/upload-artifact@v4

.github/workflows/python-test.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
name: Python test / linting
2-
32
on:
43
push:
54
branches: [ "master", "development" ]
@@ -22,7 +21,6 @@ concurrency:
2221
group: ${{ github.workflow }}-${{ github.ref }}
2322
cancel-in-progress: true
2423

25-
2624
env:
2725
RUSTFLAGS: -C debuginfo=0
2826
RUST_BACKTRACE: 1
@@ -34,7 +32,6 @@ defaults:
3432

3533
jobs:
3634
python-test:
37-
3835
runs-on: ${{ matrix.os }}
3936
strategy:
4037
fail-fast: false
@@ -50,25 +47,10 @@ jobs:
5047
with:
5148
python-version: ${{ matrix.python-version }}
5249

53-
- name: Create and activate virtual environment
54-
env:
55-
BIN: ${{ matrix.os == 'windows-latest' && 'Scripts' || 'bin' }}
56-
run: |
57-
python -m venv .venv
58-
source .venv/$BIN/activate
59-
echo "$GITHUB_WORKSPACE/.venv/$BIN" >> $GITHUB_PATH
60-
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
61-
62-
- name: Install Python dependencies
63-
run: |
64-
python -m pip install --upgrade pip setuptools
65-
pip install maturin pre-commit
66-
echo "Temporarily removing pecos-rslib from requirements... because we need to build it"
67-
grep -v "pecos-rslib" python/quantum-pecos/requirements.txt > temp_requirements.txt
68-
echo "Installing project requirements (excluding pecos-rslib)..."
69-
pip install -r temp_requirements.txt
70-
echo "Cleaning up temporary files..."
71-
rm temp_requirements.txt
50+
- name: Install the latest version of uv
51+
uses: astral-sh/setup-uv@v4
52+
with:
53+
enable-cache: true
7254

7355
- name: Set up Rust
7456
run: rustup show
@@ -78,23 +60,34 @@ jobs:
7860
with:
7961
workspaces: python/pecos-rslib
8062

81-
- name: Install pecos-rslib with maturin develop
63+
- name: Generate lockfile and install dependencies
64+
run: |
65+
uv lock --project .
66+
uv sync --project .
67+
68+
- name: Install pecos-rslib with maturin
8269
run: |
8370
cd python/pecos-rslib
84-
maturin develop
71+
uv run maturin develop --uv
8572
86-
- name: Install pure Python PECOS
87-
run: pip install ./python/quantum-pecos/
73+
- name: Install quantum-pecos
74+
run: |
75+
cd python/quantum-pecos
76+
uv pip install -e .
8877
8978
- name: Run pre-commit checks
79+
run: uv run pre-commit run --all-files --show-diff-on-failure
80+
81+
- name: Install test dependencies
9082
run: |
91-
pre-commit run --all-files --show-diff-on-failure
83+
cd python/quantum-pecos
84+
uv pip install -e .[all,test] # Install with both all and test extras
85+
uv pip install pytest pytest-cov # Explicitly install test requirements
9286
9387
- name: Run standard tests
9488
run: |
95-
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
89+
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
9690
97-
- name: Run tests with optional dependencies
91+
- name: Run optional dependency tests
9892
run: |
99-
pip install ./python/quantum-pecos/[all]
100-
pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency
93+
uv run pytest ./python/tests --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html -m optional_dependency

development.md renamed to DEVELOPMENT.md

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,14 @@ For developers who want to contribute or modify PECOS:
1010
cd PECOS
1111
```
1212

13-
3. Set up the development environment either using the `Makefile` (Note: for Windows to use the `Makefile` you may need to use a shell that has access to Linux commands such as utilizing [git bash](https://gitforwindows.org/)):
14-
```sh
15-
make venv
16-
```
17-
<details>
18-
<summary>or manually set up a Python virtual environment for develop of this project's code.</summary>
19-
20-
On Linux/Mac:
21-
22-
```sh
23-
python -m venv .venv
24-
source .venv/bin/activate
25-
pip install -U pip setuptools
26-
pip install -r python/quantum-pecos/requirements.txt
27-
make metadeps
28-
pre-commit install
29-
```
30-
31-
On Windows:
13+
3. [Install `uv` for your system](https://docs.astral.sh/uv/getting-started/installation/).
14+
And run the following at the root of the project to create a development environment, which will be stored in `.venv/`:
3215

3316
```sh
34-
python -m venv .venv
35-
.\venv\Scripts\activate
36-
pip install -U pip setuptools
37-
pip install -r python/quantum-pecos/requirements.txt
38-
make metadeps
39-
pre-commit install
17+
uv sync
4018
```
41-
</details>
42-
4319

44-
4. When developing in the development environment, be sure to activate the venv:
20+
4. You may wish to explicitly activate the environment for development. To do so:
4521

4622
On Linux/Mac:
4723
```sh
@@ -50,24 +26,21 @@ For developers who want to contribute or modify PECOS:
5026

5127
On Windows:
5228
```sh
53-
.\venv\Scripts\activate
29+
.\.venv\Scripts\activate
5430
```
5531

56-
5732
5. Build the project in editable mode
5833
```sh
5934
make build
6035
```
6136
See other build options in the `Makefile`.
6237

63-
6438
6. Run all Python and Rust tests:
6539
```sh
6640
make test
6741
```
6842
Note: Make sure you have run a build command before running tests.
6943

70-
7144
7. Run linters using pre-commit (after [installing it](https://pre-commit.com/)) to make sure all everything is properly linted/formated
7245
```sh
7346
make lint
@@ -78,4 +51,6 @@ For developers who want to contribute or modify PECOS:
7851
deactivate
7952
```
8053

54+
Before pull requests are merged, they must pass linting and the test.
55+
8156
Note: For the Rust side of the project, you can use `cargo` to run tests, benchmarks, formatting, etc.

0 commit comments

Comments
 (0)