Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
183 changes: 183 additions & 0 deletions .github/workflows/stab-mps-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: StabMps Release

on:
push:
tags: ["stab-mps-v*"]
pull_request:
paths:
- '.github/workflows/stab-mps-release.yml'
- 'scripts/ci/build_stab_mps_release.py'
- 'python/selene-plugins/pecos-selene-stab-mps/**'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

defaults:
run:
shell: bash

env:
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_NET_RETRY: "10"

jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
version: ${{ steps.version.outputs.version }}
prerelease: ${{ steps.version.outputs.prerelease }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version-file: .github/uv.toml
python-version: '3.12'
enable-cache: false
- name: Check package version and release tag
id: version
env:
RELEASE_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
run: |
uv run --frozen --no-project --with packaging==25.0 python - <<'PY'
import os
import tomllib
from pathlib import Path
from packaging.version import Version

project = Path('python/selene-plugins/pecos-selene-stab-mps/pyproject.toml')
version = tomllib.loads(project.read_text())['project']['version']
parsed = Version(version)
if str(parsed) != version:
raise SystemExit(f'Use the canonical PEP 440 version: {parsed}')
tag = os.environ['RELEASE_TAG']
if tag and tag != f'stab-mps-v{version}':
raise SystemExit(f'Tag {tag!r} must match package version {version!r}')
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
print(f'version={version}', file=output)
print(f'prerelease={str(parsed.is_prerelease or parsed.is_devrelease).lower()}', file=output)
PY

build-wheels:
needs: prepare
runs-on: ${{ matrix.os }}
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
arch: x86_64
platform-tag: manylinux_2_28_x86_64
- os: macos-15
arch: arm64
platform-tag: macosx_13_0_arm64
- os: macos-15-intel
arch: x86_64
platform-tag: macosx_13_0_x86_64
- os: windows-2022
arch: AMD64
platform-tag: win_amd64
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version: '3.12'
- name: Set up Rust on macOS and Windows
if: runner.os != 'Linux'
run: bash scripts/ci/ensure-rust.sh stable minimal
- name: Build, repair and smoke-test wheel
uses: pypa/cibuildwheel@298ed2fb2c105540f5ed055e8a6ad78d82dd3a7e # v3.3.1
with:
package-dir: python/selene-plugins/pecos-selene-stab-mps
output-dir: wheelhouse
env:
# The plugin uses a C ABI, so one py3-none wheel covers Python 3.12+.
CIBW_BUILD: 'cp312-*'
CIBW_SKIP: '*-musllinux*'
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28
CIBW_ENVIRONMENT_LINUX: >-
PATH=$HOME/.cargo/bin:$PATH
CARGO_NET_GIT_FETCH_WITH_CLI=true
CARGO_NET_RETRY=10
CIBW_BEFORE_ALL_LINUX: bash {project}/scripts/ci/ensure-rust.sh stable minimal
CIBW_BEFORE_BUILD: python {project}/scripts/ci/build_stab_mps_release.py
CIBW_ENVIRONMENT_MACOS: MACOSX_DEPLOYMENT_TARGET=13.0
CIBW_TEST_COMMAND: python {project}/scripts/ci/smoke_selene_wheel.py pecos_selene_stab_mps
- name: Check wheel platform tag
run: >-
python scripts/ci/check_wheel_platform_tags.py
--expected-platform-tag '${{ matrix.platform-tag }}' wheelhouse/*.whl
- name: Check macOS deployment target
if: runner.os == 'macOS'
run: >-
python scripts/ci/check_macos_wheel_minos.py
--maximum-version 13.0 wheelhouse/*.whl
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: stab-mps-wheel-${{ matrix.os }}
path: wheelhouse/*.whl
if-no-files-found: error

publish:
needs: [prepare, build-wheels]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/stab-mps-v')
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
steps:
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
pattern: stab-mps-wheel-*
merge-multiple: true
path: wheelhouse
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
with:
version: '0.11.16'
python-version: '3.12'
enable-cache: false
- name: Check complete release wheel set
env:
RELEASE_VERSION: ${{ needs.prepare.outputs.version }}
run: |
python - <<'PY'
import os
from pathlib import Path

wheels = list(Path('wheelhouse').glob('*.whl'))
prefix = f"pecos_selene_stab_mps-{os.environ['RELEASE_VERSION']}-py3-none-"
if len(wheels) != 4 or any(not wheel.name.startswith(prefix) for wheel in wheels):
raise SystemExit(f'Expected four StabMps release wheels, found {wheels}')
PY
uvx --from twine==7.0.0 twine check wheelhouse/*.whl
- name: Upload wheels to SW Artifactory
run: uvx --from twine==7.0.0 twine upload --non-interactive wheelhouse/*.whl
env:
TWINE_REPOSITORY_URL: https://quantinuumsw.jfrog.io/artifactory/api/pypi/pypi_local/
TWINE_USERNAME: ${{ secrets.QTNM_ARTIF_SW_WRITE_USER }}
TWINE_PASSWORD: ${{ secrets.QTNM_ARTIF_SW_WRITE_TOKEN }}
- name: Create GitHub release with wheels
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
RELEASE_VERSION: ${{ needs.prepare.outputs.version }}
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
run: |
args=()
if [ "$PRERELEASE" = true ]; then args+=(--prerelease); fi
gh release create "$RELEASE_TAG" wheelhouse/*.whl --verify-tag \
--title "StabMps $RELEASE_VERSION" \
--notes 'PECOS StabMps simulator plugin wheels for Selene. Also available from Quantinuum SW Artifactory.' \
"${args[@]}"
55 changes: 55 additions & 0 deletions python/selene-plugins/pecos-selene-stab-mps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,58 @@ geometric-mean slowdown and a 1.548x per-workload maximum versus Pragmatic on
that noisy repetition-code family,
inside the decided Exact-everywhere limits. Exact avoids Pragmatic mode's
known conditional-state bias on honest non-Clifford circuit families.

## Quantinuum SW releases

`.github/workflows/stab-mps-release.yml` builds only this plugin. It produces
`py3-none` wheels for Python 3.12+ on Linux x86-64 (manylinux 2.28), macOS 13+
(Intel and Apple Silicon), and Windows x86-64. CUDA and LLVM are not required.
Linux wheels are built in a manylinux container and repaired with auditwheel;
each platform installs its wheel in an isolated environment and loads the native
library using `scripts/ci/smoke_selene_wheel.py`.

Configure these Actions secrets in the fork before publishing (organization
secrets must explicitly grant the fork access):

- `QTNM_ARTIF_SW_WRITE_USER`
- `QTNM_ARTIF_SW_WRITE_TOKEN`

The destination is
`https://quantinuumsw.jfrog.io/artifactory/api/pypi/pypi_local/`, matching the
guppyft-lib release workflow.

To release:

1. Set `[project].version` in this plugin's `pyproject.toml` to a unique PEP 440
version, regenerate `uv.lock` with `uv lock`, and commit both files. For fork
builds, a local version such as
`0.11.0.dev0+qtnm.1` distinguishes the package from upstream. This Python
distribution version is independent of the Rust workspace version; no Rust
version bump is needed.
2. Optionally run **StabMps Release** manually on the branch to build and test
without publishing. Manual runs and pull requests never receive upload
credentials. GitHub enables manual dispatch once the workflow exists on the
default branch; before then, opening a pull request runs the build checks.
3. Tag that commit with the exact package version and push the tag:

```bash
git tag stab-mps-v0.11.0.dev0+qtnm.1
git push origin stab-mps-v0.11.0.dev0+qtnm.1
```

The tag must match the Python package version. After all four builds and smoke
tests pass, the workflow uploads the wheels to SW Artifactory and creates a
GitHub release with the same wheels attached. Development and prerelease
versions are marked as GitHub prereleases. Use a new version for each release;
the workflow does not overwrite existing Artifactory uploads.

Install a published fork release using the authenticated SW index, for example:

```bash
uv pip install --index https://quantinuumsw.jfrog.io/artifactory/api/pypi/pypi_local/simple \
--index https://pypi.org/simple 'pecos-selene-stab-mps==0.11.0.dev0+qtnm.1'
```

Supply read credentials through your normal package-index authentication.
Consumers such as guppyft-lib must replace their Git source override with the
published version to use the wheels.
42 changes: 42 additions & 0 deletions scripts/ci/build_stab_mps_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2026 The PECOS Developers
# Licensed under the Apache License, Version 2.0
"""Build the StabMps release library with Cargo.lock before Hatch packages it.

Called by cibuildwheel inside the target build environment. Prebuilding makes
the existing Hatch hook collect the locked library rather than invoke Cargo
without --locked. Each release runner starts from a clean checkout.
"""

from __future__ import annotations

import shutil
import subprocess
import sys
from pathlib import Path


def main() -> None:
"""Build and stage the native library for the existing Hatch hook."""
root = Path(__file__).resolve().parents[2]
cargo = shutil.which("cargo")
if cargo is None:
msg = "Cargo is required to build the StabMps release library"
raise RuntimeError(msg)
subprocess.run(
[cargo, "+stable", "build", "--locked", "--release", "-p", "pecos-selene-stab-mps"],
cwd=root,
check=True,
)
names = {
"linux": "libpecos_selene_stab_mps.so",
"darwin": "libpecos_selene_stab_mps.dylib",
"win32": "pecos_selene_stab_mps.dll",
}
name = names[sys.platform]
destination = root / "python/selene-plugins/pecos-selene-stab-mps/python/pecos_selene_stab_mps/_dist/lib"
destination.mkdir(parents=True, exist_ok=True)
shutil.copy2(root / "target/release" / name, destination / name)


if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions scripts/ci/release_tag_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
REPOSITORY = Path(__file__).resolve().parents[2]
WORKFLOWS = REPOSITORY / ".github/workflows"
NON_VALIDATION = {
"stab-mps-release.yml": "Builds and publishes the fork's plugin, independently of upstream release validation.",
"dependency-review.yml": "Reviews dependency diffs rather than validating the whole commit.",
"julia-update-hash.yml": "Opens a build-hash update PR rather than validating the tag.",
"trunk-ci-issues.yml": "Writes CI tracking issues rather than validating the commit.",
Expand Down
1 change: 1 addition & 0 deletions scripts/dependency-integrity-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ unexpected_writable_permissions="$(
$1 == ".github/workflows/julia-update-hash.yml" && $2 == "update-build-hash" &&
($3 == "contents" || $3 == "pull-requests") { next }
$1 == ".github/workflows/julia-release.yml" && $2 == "publish_release" && $3 == "contents" { next }
$1 == ".github/workflows/stab-mps-release.yml" && $2 == "publish" && $3 == "contents" { next }
$1 == ".github/workflows/codeql.yml" && $2 == "-" && $3 == "security-events" { next }
$1 == ".github/workflows/osv-scanner.yml" && $2 == "-" && $3 == "security-events" { next }
$1 == ".github/workflows/trunk-ci-issues.yml" && $2 == "track" && $3 == "issues" { next }
Expand Down
Loading