Skip to content

Instantly share code, notes, and snippets.

View cgranade's full-sized avatar

Cassandra Granade cgranade

View GitHub Profile
# NB: This sample uses features from Python 3.10,
# in particular the match statement.
# If you get a syntax error, you may need a more
# recent version of Python.
from __future__ import annotations
from dataclasses import dataclass
class ExprBase:
def __add__(self, other: Expr) -> Expr:
return PlusExpr(self, other)
name: repo2docker-repro
dependencies:
- notebook
- python
- numpy
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cgranade
cgranade / qutip-operator-sum-design.md
Last active September 25, 2021 02:01
Operator Sum support for QuTiP

Operator Sum representation support for QuTiP

Abstract

When working with quantum objects in QuTiP, the library provides the concept of a kind, allowing the use of state vectors, dual vectors, density operators, unitary operators, and superoperators all in unified fashion. Currently, however, this support does not include representations of operator-sum decompositions of channels or instruments. For example, qt.to_kraus returns a list of Qobj instances, which then has no further metadata nor any way of enforcing that each consituent Qobj instance agrees in dimensions and other metadata. Similarly, instruments can commonly be represented by a decomposition into a sum of completely positive trace non-increasing channels, but there is no current reflection of this structure in QuTiP. This design document describes a modification to QuTiP to enable first-class support for operator-sum decompositions.

Dimensions

In general, QuTiP differentiates between kinds by using decompositions of array sh

@cgranade
cgranade / ApplyCZPow.ipynb
Created September 4, 2020 16:53
qcstackexchange-13581
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

DISCLAIMER: This post is still in a draft!

Falsehoods programmers believe about quantum computing

Preamble

Quantum computing has captured broad attention and fascination over the past few years, but with that interest has come a large number of well-intentioned misunderstandings. In this post, I'll lay out a few of these falsehoods in the tradition of other wonderful falsehood lists, and in the hopes of spurring more exploration into this new and fascinating way of solving hard problems.

As a brief housekeeping note, these falsehoods are ordered by theme and topic, not in order of complexity, so don't worry if some of these points seem a bit intimidating. If you're looking to learn more about quantum computing in the first place, check out Learn Quantum Computing with Python and Q# (Manning Publications, October 2020) by Sarah Kaiser and myself.

Special thanks to everyone that made

@cgranade
cgranade / Dockerfile
Last active March 14, 2020 20:23
Values in Q#
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.2002.2610
ENV IQSHARP_HOSTING_ENV=dev-to-sckaiser-arrays
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}
# While root, upgrade the .NET Core SDK.
# Start from the IQ# base image. The definition for this image can be found at
# https://github.com/microsoft/iqsharp/blob/master/images/iqsharp-base/Dockerfile.
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.2001.2831
ENV IQSHARP_HOSTING_ENV=quantumcomputing-9690
# Make sure the contents of our repo are in ${HOME}.
# These steps are required for use on mybinder.org.
USER root
COPY . ${HOME}
RUN chown -R ${USER} ${HOME}
@cgranade
cgranade / Dockerfile
Last active January 22, 2020 05:04
Reproduction for `long?` bug
# The same image used by mybinder.org
FROM mcr.microsoft.com/quantum/iqsharp-base:0.10.1912.0501
ENV IQSHARP_HOSTING_ENV=cgranade-longq-bug-repro
# Make sure the contents of our repo are in ${HOME}
# Required for mybinder.org
COPY . ${HOME}
USER root
RUN chown -R ${USER} ${HOME}
USER ${USER}