KQCircuits is a Python library developed by IQM for automating the design of superconducting quantum circuits. It uses the KLayout layout design program API. This fork is intended for the use during 2023 iteration of the Winter School as it includes exercises to get familiar with KQCircuits.
KQCircuits generates multi-layer 2-dimensional-geometry representing common structures in quantum processing units (QPU). It includes definitions of parametrized geometrical objects or “elements”, framework to easily define your own elements, framework to get geometry from the elements by setting values to parameters and a framework to assemble a full QPU design by combining many of the elements in different geometrical relations. Among other templates, are also structures to combine QPU designs to create optical mask layout and EBL patterns for fabrication of quantum circuits and export a set of files for a mask as needed for QPU fabrication.
⠀
Over the course of this one-week course we will provide help over our Discord channel.
The system needs to have Python
(version >= 3.7) and pip
installed.
Run the following commands and check for errors to make sure that you have the required software installed.
python --version
pip --version
We start by downloading and installing the latest KLayout
application. There are options:
Download and install package from the KLayout site - recommended for Windows and Linux platforms
Choose the installation package according to your platform (Windows, Linux, etc).
Open the installer and follow the instructions with default suggested
Destination Folder
.Download and install package from package manager like
brew
- recommended for macOS platformsWe recommend using Homebrew to install KLayout on a MacOS platform. After installing Homebrew make sure that python and pip can be run from terminal, and if not, run:
brew install python
Next install KLayout:
brew install --cask klayout
Homebrew might place the
klayout.app
package in/Applications/KLayout/
directory. In this case simply move theklayout.app
package so that its path is/Applications/klayout.app
Attempt to start up KLayout, which might not work right away for following reasons:
- macOS might prompt to install Rosetta to support KLayout - follow macOS instructions to do so.
- macOS might not trust the KLayout application and refuse to run it. In that case do the following:
- open
Applications
folder - control+click
klayout.app
executable, chooseopen
- macOS will again complain about untrusted applications, but this time provide an
open
option which should be chosen to override security - After launching KLayout once there should be no further issues on subsequent launches
- open
We will use the git
tool to download and install the KQCircuits
source code present in this fork.
This tool can also be used to contribute to the KQCircuits project after this course if you wish to do so.
Linux and macOS platforms have git installed by default.
For Windows an external git distribution needs to be used.
We recommend this Windows application.
After install you will have access to the Git Bash
command line application which can be used to run git commands.
Open the Git Bash
terminal and navigate to the folder of your choice using the cd
command.
(the default location is the HOME
directory, which is C:/Users/<UserName>
)
Clone the KQCircuits repository:
git clone https://github.com/iqm-finland/KQCircuits-winter-school.git KQCircuits
This creates the KQCircuits directory at the working directory.
The following commands will configure KLayout to use the KQCircuits library
cd KQCircuits
python setup_within_klayout.py
In case the pip tool is invoked in your terminal with pip3
rather than pip
, open setup_within_klayout.py
with a text editor and edit the second last line
os.system(f"pip3 install -r {pip_args}")
We are now ready to use KQCircuits
. On Windows open the KLayout (Editor)
application, for other platforms open klayout
application.
Make sure that the KQCircuits
works correctly with KLayout
by checking the following:
KQCircuits
entry should be present in the top toolbar.- On the bottom left in the
Libraries
panel theChip Library
option should be available from the dropdown menu. Choose it to see multiple ready made chips available for preview. You can drag any of the chips into the center layout to see its contents.
If the KLayout doesn't seem to allow drag-and-dropping chips etc on to the layout, check the following:
- From top toolbar, choose
File > Setup
(Windows) orklayout > Preferences
(macOS) - Choose
Application > Editing mode
window - Make sure
Use editing mode by default
is checked
Quick editor tips to get started. Of course more techniques will be taught in subsequent lectures.
- Use
F2
to center the view - Use
*
key to view every available layer Left click
to choose elements on the layout- Double click to edit properties of the element on the layout
- Drag with
Right click
to zoom to the selected region Middle click
to drag the layout, scroll to zoom
The content in the layout might look needlessly complicated like so:
This can be simplified by choosing from the top toolbar: File
> Load layer properties
and navigating to: KQCircuits/klayout_package/python/kqcircuits/layer_config/default_layer_props.lym
The results should look like this:
During this course you will be modifying certain parts of the code in the KQCircuits
code as exercise.
You're free to choose the editor: PyCharm and Visual Studio Code are quite good.
For the code changes to take into effect the KLayout instance
needs to be closed and reopened. If Chip Library
panel does not show up, there most likely has been an error
with the KQCircuits code. Changes in the Chip
or Element
design code can also be taken into effect
without reopening KLayout by choosing from the top toolbar: KQCircuits > Reload libraries
So far we have set everything up to work for most of the course. However, on the latter half of the course we will be exporting geometry produced by KQCircuits into data to be used by third-party simulator software. To make this happen we need to have KQCircuits installed as a module in pip.
cd
to the KQCircuits
directory then run
python -m pip install -e klayout_package/python
This might take 5-10 minutes to execute so don't be worried.
macOS users! While installing KQCircuits,pip
will attempt to install KLayout as a dependency. However, most recent KLayout distributions in pip may not work for macOS. To remedy this, the KQCircuitklayout_package/python/setup.py
can be configured to install an older KLayout version that has shown to work for macOS. Change the following line to"klayout==0.27.9",
To test that this got set up correctly, try running
python klayout_package/python/scripts/simulations/waveguides_sim_compare.py
This should cause KLayout to open with the following content:
cd
to KQCircuits/tmp
and there should be a waveguides_sim_elmer
directory.
We have previously recorded video tutorials for the GUI installation available on YouTube. These might be helpful, but we advise to follow the instructions as stated above or as presented in the first lecture. Also always feel free to ask for help on discord.
Documentation for KQCircuits can be found here.
It may also be generated from the sources with make html
in the docs directory.
For Winter school we advise to follow the installation guide as layed out above instead of following the installation guide presented in the documentation. If you experience some installation issue that was not addressed above, contact us by discord.
Contributions to KQC are welcome from the community and we would be happy to accept contributions from the Winter School participants after the course.
Please note that the contributions are accepted in the official KQCircuits repository rather than this Winter School fork.
Contributors are expected to accept IQM Individual Contributor License Agreement by filling a form at IQM website. See also section Contributing in the documentation.
Please see the documentation for instructions on how to cite KQCircuits in your projects and publications.
This code is part of KQCircuits
Copyright (C) 2021-2023 IQM Finland Oy
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html.
The software distribution should follow IQM trademark policy for open-source software (meetiqm.com/developers/osstmpolicy). IQM welcomes contributions to the code. Please see our contribution agreements for individuals (meetiqm.com/developers/clas/individual) and organizations (meetiqm.com/developers/clas/organization).
KQCircuits is a registered trademark of IQM. Please see IQM open source software trademark policy.