Skip to content

Commit

Permalink
Merge branch 'main' into zurich_discrimination
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacfomg committed Dec 1, 2023
2 parents f49378d + 64e3da3 commit 02182fe
Show file tree
Hide file tree
Showing 50 changed files with 3,561 additions and 2,872 deletions.
85 changes: 76 additions & 9 deletions .github/workflows/selfhosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,81 @@ concurrency:
cancel-in-progress: true

jobs:
build:
prepare:
if: contains(join(github.event.pull_request.labels.*.name), 'run-on')
uses: qiboteam/workflows/.github/workflows/selfhosted.yml@main
with:
used-labels: ${{ toJSON(github.event.pull_request.labels.*.name) }}
python-version: "3.10"
artifact-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
poetry-extras: "--with tests --all-extras"
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Read platforms from labels
id: set-matrix
env:
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
run: |
echo $LABELS
platforms="["
combined=""
shopt -s lastpipe
jq -c '.[]' <<< "$LABELS" | while read label; do
platform=(${label//-/ })
if [ ${platform[0]} == "\"run" ] && [ ${platform[1]} == "on" ]; then
platforms+="${combined:+,}\"${platform[2]}"
combined=${platforms}
fi
done
platforms+="]"
echo ${platforms}
echo matrix="${platforms}" >> $GITHUB_OUTPUT
secrets:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tests:
needs: prepare
strategy:
matrix:
platform: ${{ fromJSON(needs.prepare.outputs.matrix) }}
fail-fast: false
runs-on: self-hosted
steps:
- name: Cleanup workspace manually
run: |
rm -rf _work/*
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install and configure poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: false
- name: Install qibolab main
run: |
python -m venv testenv
source testenv/bin/activate
poetry install --no-interaction --all-extras --with tests
- name: Execute on ${{ matrix.platform }}
run: |
source testenv/bin/activate
export platform=${{ matrix.platform }}
git clone https://github.com/qiboteam/qibolab_platforms_qrc
queues=`cat qibolab_platforms_qrc/queues.json`
export QIBOLAB_PLATFORMS=./qibolab_platforms_qrc
partition="$(jq -r -n --argjson data "$queues" '$data.'$platform)"
srun -p $partition selfhosted
mkdir coverage
mv coverage.xml coverage/
mv htmlcov coverage/
- name: Upload coverage report as artifact
uses: actions/upload-artifact@v3
with:
name: coverage-from-self-hosted
path: coverage/
- name: Notify the Pull Request
uses: thollander/actions-comment-pull-request@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
message: |
Run on QPU `${{ matrix.platform }}` completed! :atom:
> *You can download the coverage report as an artifact, from the workflow summary page:*
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: check-toml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.11.0
hooks:
- id: black
args:
Expand All @@ -25,7 +25,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/hadialqattan/pycln
rev: v2.3.0
rev: v2.4.0
hooks:
- id: pycln
args:
Expand Down
9 changes: 9 additions & 0 deletions doc/source/main-documentation/qibolab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ This instrument is also part of the dummy platform which is defined in :py:mod:`
This platform is equivalent to real platforms in terms of attributes and functions, but returns just random numbers.
It is useful for testing parts of the code that do not necessarily require access to an actual quantum hardware platform.

.. testcode:: python

from qibolab import create_platform

platform = create_platform("dummy_couplers")

will create a dummy platform that also has coupler qubits.


.. _main_doc_qubits:

Qubits
Expand Down
14 changes: 10 additions & 4 deletions doc/source/tutorials/circuits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ circuits definition that we leave to the `Qibo
qibo.set_backend("qibolab", "dummy")
hardware_result = circuit(nshots=5000)

# retrieve measured probabilities
freq = hardware_result.frequencies()
p0 = freq["0"] / 5000 if "0" in freq else 0
p1 = freq["1"] / 5000 if "1" in freq else 0
hardware = [p0, p1]

# execute with classical quantum simulation
qibo.set_backend("numpy")
simulation_result = circuit(nshots=5000)

# retrieve measured probabilities
hardware = hardware_result.probabilities(qubits=(0,))
simulation = simulation_result.probabilities(qubits=(0,))


Expand Down Expand Up @@ -87,8 +91,10 @@ results:
circuit.set_parameters([angle])

# execute circuit
state = circuit.execute(nshots=4000)
p0, p1 = state.probabilities(qubits=(0,))
result = circuit.execute(nshots=4000)
freq = result.frequencies()
p0 = freq['0'] / 4000 if '0' in freq else 0
p1 = freq['1'] / 4000 if '1' in freq else 0

# store probability in state |1>
res.append(p1)
Expand Down
Loading

0 comments on commit 02182fe

Please sign in to comment.