Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

KLayout Python library for integrated quantum circuit design. This fork includes exercises for the 2023 iteration of the Winter School

License

Notifications You must be signed in to change notification settings

iqm-finland/KQCircuits-winter-school

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KQCircuits

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.

Continuous Integration DOI License Latest version Click for documentation

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.

QPU design workflow

Example layout

Discord channel

Over the course of this one-week course we will provide help over our Discord channel.

Installation guide for Winter School 2023 participants

Prerequisites

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

Install KLayout

We start by downloading and installing the latest KLayout application. There are options:

  1. 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.

  2. Download and install package from package manager like brew - recommended for macOS platforms

    We 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 the klayout.app package so that its path is /Applications/klayout.app

    Attempt to start up KLayout, which might not work right away for following reasons:

    1. macOS might prompt to install Rosetta to support KLayout - follow macOS instructions to do so.
    2. 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, choose open
      • 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

Set up git

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>)

Install KQCircuits

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"pip install -r {pip_args}")
to:

os.system(f"pip3 install -r {pip_args}")

Confirm KQCircuits is installed correctly

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 the Chip 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.

These should be available if KQCircuits works

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) or klayout > Preferences (macOS)
  • Choose Application > Editing mode window
  • Make sure Use editing mode by default is checked

Enable Editing Mode

Enable Editing Mode

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:

Before choosing layer properties

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

Choosing layer properties

The results should look like this:

After choosing layer properties

Modifying the KQCircuits code

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

Installing KQCircuits as a Python module

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 KQCircuit klayout_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:

Simulation window

cd to KQCircuits/tmp and there should be a waveguides_sim_elmer directory.

Video tutorials (might be outdated)

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.

Windows Ubuntu MacOS
KQCircuits Getting Started (Windows) KQCircuits Getting Started (Ubuntu) KQCircuits Getting Started (MacOS)

Documentation

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.

Contributing

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.

Citation

Please see the documentation for instructions on how to cite KQCircuits in your projects and publications.

Copyright

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).

Trademarks

KQCircuits is a registered trademark of IQM. Please see IQM open source software trademark policy.

About

KLayout Python library for integrated quantum circuit design. This fork includes exercises for the 2023 iteration of the Winter School

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.5%
  • Other 0.5%