- Hi, my name is Nick Bronn.
I use Qiskit for quantum computing research, and education.
Today, we're gonna talk about installing
the development branch of Qiskit.
You'd be interested in doing this
if you're a researcher who wants access
to the latest and greatest tools in Qiskit,
or maybe you're a software developer
who wants to build onto Qiskit,
or maybe you're some combination of both.
Either way, you wanna live on the bleeding edge
of what Qiskit has to offer.
In a previous video, we covered installing Qiskit for users.
That included topics like registering
for an IBM Quantum account,
and writing Jupyter notebooks.
Today we'll focus on installing Qiskit for developers.
This video will also include some basic tips
for open source software development.
I came to quantum computing from a physics background.
So these are some of the things I picked up
from contributor to Qiskit.
Let's start by downloading the Anaconda version of Python.
Navigate to anaconda.com.
Click on products, and download the individual edition.
Follow the install instructions.
Next, open up a terminal, or Anaconda prompt.
Let's manage our conda environments.
We can see what we have by typing in conda env list.
I'm a busy guy.
I've got a lot of environments.
So let's create a new one for development.
Type in conda create -n, for name, qiskit-dev, let's say,
and install the latest version of Python.
Hit yes when asked.
This will take a moment to install.
Now we need to get set up for GitHub.
Let's go to github.com.
Create an account, if you haven't already.
Next, navigate to github.com/Qiskit.
Click on Qiskit Terra,
which is the foundation on which
the rest of Qiskit is built.
Instructions for installing the other Qiskit modules
can be found in the link below.
In order to make a contribution to Qiskit,
you must fork a copy for yourself.
So navigate to the upper right,
and click on the fork button.
I've already forked Qiskit Terra, but for you,
this will take just a moment.
You'll arrive at your own copy of Qiskit Terra,
that you control.
It's through this version that you'll be able
to make contributions to Qiskit.
If you haven't already,
you need to add an SSH key to your GitHub account.
Click on your profile, settings, SSH and PGP keys,
and add your SSH key.
If you need instructions on generating an SSH key,
please see the link below.
Navigate back to your forked Qiskit Terra repo.
Click on the code button,
and make sure you have SSH selected under clone.
Copy the address, and navigate back to your terminal.
Back at the command line,
we wanna activate our Qiskit dev environment,
conda activate qiskit-dev.
Now we wanna clone the web address we just copied.
Git clone paste.
This will just take a moment.
Objects are being received.
They have been enumerated.
They have been resolved.
And we're good.
Change into your Qiskit Terra directory.
CD qiskit-terra.
While most of Qiskit Terra is written in Python,
some core routines are written in Rust.
This can easily be installed
by navigating to rustup.rs, and following the instruction.
For Unix-based operating systems,
including Linux and Mac OS,
it's as easy as running this command.
For Windows installs,
you'll need to download an executable,
as well as install the latest build tools for Visual Studio,
linked to in the description.
Proceed with installation.
We can restart our terminal,
or source our environment for Rust.
Next, install the required libraries,
pip install -r requirements.txt.
Collecting things.
And let's go ahead and install the developer libraries,
so we don't have to worry about that later,
pip install -r requirements-dev.txt.
Next we'll install a Python kernel,
for using Qiskit inside Jupyter notebooks.
Python -n ipykernal install --user --name qiskit-dev,
we'll use the same name as our environment,
- -display name,
and we'll call that qiskit-dev as well.
And that just takes a second.
And then finally, we'd also like to install Rise,
so we can view Jupyter notebooks in slideshow format,
pip install rise.
Next we'll set of the GitHub environment.
First we'll do remotes.
This allows us to get updates from Qiskit's repo,
and merge them, with our fork.
To see what our remotes are, type in git remote -v.
Currently we can see, we have origin,
which is our forked copy on our own GitHub account.
But we need to know where Qiskit lives.
So we need to add an upstream,
so we can merge with our own local copy.
We do this by typing
git remote add upstream git@github.com:qiskit/qiskit-terra.
Now we can go back and look at our remotes
by typing and get remote -v, again.
Now, in addition to origin, we have upstream,
which allows us to pull, or fetch, the latest updates
from Qiskit into our own local copy.
We can do this by git pull upstream main.
Main is the name of the default branch
And we're up to date.
Now let's push these updates to our origin
on our github.com account.
Git push origin main.
And we're up to date.
Next, let's create a feature branch and do some work.
Git checkout -b, which will create a new branch,
and we'll call it my-feature-branch.
Let's do some work.
Some work.
Now let's see what changed by typing in git status.
I have some of work.
I can add it to my repo, git add work.
Now I can commit my changes,
by doing git commit -m "some awesome work."
And now I can push that to my origin.
Git push origin my-feature-branch.
That was a fake example of a code contribution.
Let's go to one I've actually been working on.
Git checkout template-param-expression.
There we are.
First, let's make sure we're up to date
with the latest dev branch.
Git pull upstream main.
Now there are some important things to do
before submitting the pull request.
If you've added new features, add some release notes
to document what you're changing.
Reno new add parameters-to-template substitution --edit.
Here, we have the features we wish to contribute to Qiskit.
My example involves using circuit parameters,
in a new transpiler pass called template optimization
That saves the release notes in our working branch.
Now we need to perform some code checks.
Tox is a tool to standardize code testing in Python.
And we use it to run code checks
before submitting the pull request.
We'll start with tox -eblack,
where e refers to the current environment,
and black is a tool that automatically fixes white space
and formatting errors.
That took a little while,
because we had to build our tox environment,
because we're starting from a fresh install.
If you need to rebuild your tox environment, use -r.
Next we'll do tox -elint.incr.
Lint checks your code for programming and style errors.
And incr, for incremental, just checks the files
you modified instead of all of them.
That sound good?
Okay.
Then we just wait for a sec.
And finally, type in tox -epy.
This will run unit tests on all of Terra,
for the current version of Python.
These code checks can take a while,
so it might be a good time to stretch your legs.
Now that the checks have passed,
we're ready to submit our pull request.
Let's add the change files to the commit,
by typing git add -A.
Add our commit by doing git commit -m
"added release notes and fixed tox lint issues"
And finally, we'll push to our copy on github.com.
Git push origin template-para-expression, enter.
Next, go to github.com,
and select branch that you would like to submit
a pull request for.
Ours is called template pram expression.
But we're already in the middle of a pull request here.
So let's go to our fake feature branch, my feature branch.
In order to start a contribution,
click on the contribute button,
and click on open pull request.
Here, you can fill out details, such as relevant issues,
other relevant pull requests,
and information regarding what you're trying to contribute.
And then click on create pull request below.
Note your pull request must pass all the continuous
integration checks before anything else happens.
Make sure you read the contributing guidelines,
and the code of conduct, found in the description below.
Now you've just made a pull request Quiskit.
But it's not over yet.
Your code will be reviewed by core Quiskit developers.
This is a collaborative process,
the keyword being process.
It might take a few rounds of review,
but you will receive useful feedback
and you're free to post in Slack with specific questions.
And eventually, your coach should be merged in Quiskit.
So that's how you install
and contribute to Quiskit, as a researcher, or developer.
I've been your host, Nick Bronn,
and I hope you're enjoyed this video and found it useful.
If you have any questions,
please let us know in the comments.
Thanks again for watching.
And don't forget to like and subscribe,
for all things Quiskit.
(bright music)