Skip to content

Commit

Permalink
Merge branch 'main' into alvaro/bf_temperature_controller
Browse files Browse the repository at this point in the history
  • Loading branch information
aorgazf committed Dec 7, 2023
2 parents 05798a8 + 735e34f commit 17646b0
Show file tree
Hide file tree
Showing 61 changed files with 2,566 additions and 6,743 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.10.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
13 changes: 3 additions & 10 deletions doc/source/main-documentation/qibolab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -662,15 +662,9 @@ This procedure typically involves the following steps:
2. All gates are transpiled to native gates, which represent the universal set of gates that can be implemented (via pulses) in the chip.
3. Native gates are compiled to a pulse sequence.

The transpilation and compilation process is taken care of automatically by the :class:`qibolab.backends.QibolabBackend` when a circuit is executed, using :class:`qibolab.transpilers.abstract.Transpiler` and :class:`qibolab.compilers.compiler.Compiler`.
The transpiler is responsible for steps 1 and 2, while the compiler for step 3 of the list above. In order to accomplish this, several transpilers are provided, some of which are listed below:

- :class:`qibolab.transpilers.gate_decompositions.NativeGates`: Transpiles single-qubit Qibo gates to Z, RZ, GPI2 or U3 and two-qubit gates to CZ and/or iSWAP (depending on platform support).
- :class:`qibolab.transpilers.star_connectivity.StarConnectivity`: Transforms a circuit to respect a 5-qubit star chip topology, with one middle qubit connected to each of the remaining four qubits.
- :class:`qibolab.transpilers.routing.ShortestPaths`: Transforms a circuit to respect a general chip topology given as a networkx graph, using a greedy algorithm.
- :class:`qibolab.transpilers.pipeline.Pipeline`: Applies a list of other transpilers sequentially.

Custom transpilers can be added by inheriting the abstract :class:`qibolab.transpilers.abstract.Transpiler` class.
The transpilation and compilation process is taken care of automatically by the :class:`qibolab.backends.QibolabBackend` when a circuit is executed, using circuit transpilers provided by Qibo and :class:`qibolab.compilers.compiler.Compiler`.
The transpiler is responsible for steps 1 and 2, while the compiler for step 3 of the list above.
For more information on the transpiler please refer the `examples in the Qibo documentation <https://qibo.science/qibo/stable/code-examples/advancedexamples.html#how-to-modify-the-transpiler>`_.

Once a circuit has been transpiled, it is converted to a :class:`qibolab.pulses.PulseSequence` by the :class:`qibolab.compilers.compiler.Compiler`.
This is a container of rules which define how each native gate can be translated to pulses.
Expand Down Expand Up @@ -700,7 +694,6 @@ U3, the most general single-qubit gate can be implemented using two RX90 pi-puls
Typical two-qubit native gates are the CZ and iSWAP, with their availability being platform dependent.
These are implemented with a sequence of flux pulses, potentially to multiple qubits, and virtual Z-phases.
Depending on the platform and the quantum chip architecture, two-qubit gates may require pulses acting on qubits that are not targeted by the gate.
The :class:`qibolab.native.NativeType` flag is used for communicating the set of available native two-qubit gates to the transpiler.

.. _main_doc_instruments:

Expand Down
17 changes: 8 additions & 9 deletions doc/source/tutorials/transpiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Creating an instance of the backend provides access to these objects:
.. testoutput:: python
:hide:

<class 'qibolab.transpilers.pipeline.Passes'>
<class 'qibo.transpiler.pipeline.Passes'>
<class 'qibolab.compilers.compiler.Compiler'>

The transpiler is responsible for transforming the circuit to respect the chip connectivity and native gates,
Expand Down Expand Up @@ -56,11 +56,11 @@ Instead of completely disabling, custom transpilation steps can be given:
.. testcode:: python

from qibolab.backends import QibolabBackend
from qibolab.native import NativeType
from qibolab.transpilers.unroller import NativeGates

from qibo.transpiler.unroller import NativeGates, Unroller

backend = QibolabBackend(platform="dummy")
backend.transpiler = NativeGates(two_qubit_natives=NativeType.CZ)
backend.transpiler = Unroller(native_gates=NativeGates.CZ)


Now circuits will only be transpiled to native gates, without any connectivity matching steps.
Expand All @@ -75,16 +75,15 @@ Multiple transpilation steps can be implemented using the :class:`qibolab.transp

.. testcode:: python

from qibolab.native import NativeType
from qibolab.transpilers.pipeline import Passes
from qibolab.transpilers.star_connectivity import StarConnectivity
from qibolab.transpilers.unroller import NativeGates
from qibo.transpiler import Passes
from qibo.transpiler.unroller import NativeGates, Unroller
from qibo.transpiler.star_connectivity import StarConnectivity

backend = QibolabBackend(platform="dummy")
backend.transpiler = Passes(
[
StarConnectivity(middle_qubit=2),
NativeGates(two_qubit_natives=NativeType.CZ),
Unroller(native_gates=NativeGates.CZ),
]
)

Expand Down
Loading

0 comments on commit 17646b0

Please sign in to comment.