# Quantum Bayesian Networks

## July 2, 2019

### Qubiter now has an automatically generated SUMMARY of all its Jupyter notebooks

Filed under: Uncategorized — rrtucci @ 7:36 pm

I just added to Qubiter one of those features that Americans like to call “A Big Time Saver”. Automobiles, washers and driers of clothing, those are all big time savers, but this is even better… for Qubiter users.

Something about Qubiter’s jupyter_notebooks folder had been embittering my life. But, praise the Lord and Hallelujah :), today I found a solution to that something, a solution that I find very satisfying. Let me tell you all about it.

Qubiter has a folder full of Jupyter notebooks (in fact, 27 of them). Opening a notebook takes a short while, which is slightly annoying. I wanted to give Qubiter users the ability to peek inside all the notebooks at once, without having to open all of them. Qubiter’s new SUMMARY.ipynb notebook allows the user to do just that.

SUMMARY.ipynb scans the directory in which it lives to find all Jupyter notebooks (other than itself) in that directory. It then prints for every notebook it finds (1) a hyperlink to the notebook, and (2) the first cell (which is always markdown) of the notebook. This way you can read a nice, automatically generated summary of all the notebooks without having to open all of them. If you find a notebook that you want to explore further, you can simply click on its link to open it.

Here is the code that I use. I posted it on StackOverflow

https://stackoverflow.com/questions/56829884/how-to-execute-cell-1-from-another-notebook-in-current-notebook?noredirect=1#comment100244813_56829884

And here is Qubiter’s notebook using the code:

https://nbviewer.jupyter.org/github/artiste-qb-net/qubiter/blob/master/qubiter/jupyter_notebooks/SUMMARY.ipynb

## July 1, 2019

Filed under: Uncategorized — rrtucci @ 4:39 pm

P.S. Xanadu AI is a scam Canadian company that has nothing to do with “Project Xanadu” of the brilliant Ted Nelson.

## June 30, 2019

### A Cool, Highly Effective Combination: parametric quantum circuit + Jupyter notebook with widgets + Qubiter

Filed under: Uncategorized — rrtucci @ 3:08 am

Check out my new Jupyter notebook for Qubiter.

Sorry. The following link was broken for a while because I unwittingly damaged the json format of the notebook. It’s now working again

Here is a jpeg of the widgets that this notebook presents to the user. On my computer, it takes a few seconds before the widgets are rendered, so if you don’t see this immediately, near the bottom of the notebook, when you open the notebook in your browser, just be patient. Sometimes, the widgets don’t show up unless you **run** the notebook. Sorry.

Suppose that you are interested in printing out the state vector of a quantum circuit at various times (points) in its evolution, as well as at the end of the circuit. Qubiter can do that.

Furthermore, suppose that the circuit is a parametric one, and you want to vary its parameters using sliders on a gui (graphical user interface). Qubiter can do that too, via a jupyter notebook with widgets. This notebook is one such notebook.

A jupyter notebook with widgets gives you the best of both worlds, the gui world and the notebooks world.

Gui’s excel at reducing the possibility of user errors, increasing the ease of use for the user, and reducing the amount of understanding of the code that is demanded from the user in order for him or her to use the code correctly.

Notebooks excel at providing a robust, flexible, ready made, familiar method of documenting and saving your work for multiple use cases. They are also great for explaining your work to others with great detail and precision.

## June 29, 2019

### Xanadu AI, Canadian Quantum Computing Ponzi scheme, gets an extra CAN$32 Million Filed under: Uncategorized — rrtucci @ 12:38 pm In a previous blog post, I commented about Xanadu AI: The latest news about the Xanadu Ponzi scheme is that they just got an extra CAN$32 Million (This raises their total funding so far to CAN\$41M, according to TechCruch). This company has practically zero chance of succeeding. Their quantum computing technology, using squeezed light, is **far inferior** to the ones (ion trap, squids, optical, anyons, quantum dots) being pursued by a crowded field of well funded startups (Rigetti, IonQ, PsiQ, and many others) and giant monopolies (IBM, Google, Microsoft, Intel, Alibaba, Huawei, …).

The latest 32 million was reported in the Globe and Mail:

Excerpts in boldface:

But Xanadu needs to take “three giant steps,” before it can fully commercialize its technology, said Massachusetts Institute of Technology mechanical engineering and physics professor Seth Lloyd, a leading expert in quantum computing who advises the startup:

“They need to improve the squeezing by a significant amount and show they can get many pulses of this squeezed light into their device, and then control these pulses … [then] show you can actually do something that’s useful to people with the device. Given what they’re trying to do, they’re on schedule. Any one of those things could fail, which is the nature of science and life and being a startup.”

Only that, just a cake walk away. Right on schedule?? Squeezed light was invented by H. P. Yuen in 1976, 43 years ago. Brilliant experimentalists like Bernard Yurke and Jeffrey Kimble soon hit a brick wall in the amount of possible squeezing attainable. I hardly think that the CEO of Xanadu, Elizabeth Holmes or whatever his name is, can improve much on what they did. Nowadays, squeezing is used mainly by the LIGO people. I believe it might reduce their noise by a factor of 10 or so, but is that enough for Xanadu’s speculative analog quantum computer to perform calculations better than a cell phone. Highly doubtful.

The only thing that is on schedule here is Seth Lloyd’s Ponzi scheme.

Xanadu is looking to generate revenue in the short term with proof-of-concept projects for a few customers including Bank of Montreal, and by offering cloud-based software that customers can use to test out not only its quantum technology, but that of its competitors. Lawrence Wan, chief architect and head of enterprise platforms with BMO, said Xanadu’s approach “looks to be more commercially viable and scalable” than others.

Obvious BS. Why would the competitors with qc machines allow Xanadu to poach their clients? Besides, Xanadu’s underperforming or nonexistent squeezed light “quantum computer” is very different from a gate model machine so Xanadu is not especially qualified to advise others about gate model machines. Dozens of companies are already offering qc consulting services. Consulting won’t generate enough near-term revenue for Xanadu in the next 5-10 years of toy qc machines to cover the cost of the very expensive hardware R&D effort that they are “promising” to undertake.

Let’s face it, the real revenue maker for Xanadu is their Ponzi scheme.

## June 27, 2019

### Comments on quant-ph arXiv:1906.10726, “Quantum Causal Models”, by Jonathan Barrett, Robin Lorenz, Ognyan Oreshkov

Filed under: Uncategorized — rrtucci @ 6:59 am

The paper

“Quantum Causal Models”, by Jonathan Barrett, Robin Lorenz, Ognyan Oreshkov, https://arxiv.org/abs/1906.10726

was published by BLO tonight. This is my initial response to it.

It’s been just a few hours since BLO published this paper in arxiv, so I haven’t had a chance to read it in its entirety, yet. I have never communicated with BLO, so this is the first time the authors will hear about my response to it. However, much of the material covered in the BLO paper is familiar territory to me, having worked on QB Nets (Quantum Bayesian Networks) since my first paper on them in 1995

Excellent job! And it mentions my work. Thank you!

Here is how BLO explain the relevance of my work to theirs:

Many works are explicitly concerned with causal structure, but not to the end of a quantum generalization of causal models. These include, for example, Refs. [19, 22, 45, 64–69], and are not discussed here any further. Early work by Tucci [6, 7] aims at a quantum generalization of classical Bayesian (rather than causal) networks, obtained by associating probability amplitudes with nodes. More closely related to our work is that of Leifer and Poulin [9], which presents (amongst other things) an approach to quantum Bayesian networks, wherein a quantum state is associated with a DAG, and must satisfy independence relationships formalised by the quantum mutual information, given by the structure of the DAG. The results of Ref. [9] have at various times been used in our proofs. Leifer and Spekkens [11] adapt the ideas of Ref. [9] to quantum causal models, using a particular definition of a quantum conditional state. Our approach differs from that of Ref. [11] in taking influence in unitary transformations as defining of causal relations, in its use of the process operator formalism, and in the fact that we don’t use quantum conditional states.

Under Refs. 6, 7 they list

[6] R. R. Tucci, “Quantum bayesian nets,” International Journal of Modern Physics B 9 no. 03, (1995) 295–337.
[7] R. R. Tucci, “Factorization of quantum density matrices according to bayesian and markov networks,” arXiv:quant-ph/0701201.

I do disagree with their characterization of my work. My early work Ref.6 in 1995 was on QB nets for pure states, but then I published Ref.7 in 2007 which explains how QB nets can also be used to describe density matrices that are not pure states. In 2012, I published the following introductory review and reprise of the use of QB nets to describe general density matrices

“An Introduction to Quantum Bayesian Networks for Mixed States”, by Robert R. Tucci, https://arxiv.org/abs/1204.1550

I contend that what the BLO paper proposes is **exactly** QB nets for density matrices. They just call them by a different name. A rose by any other name would smell as sweet.

I have also published in this blog the following article describing the connection of QB Nets to “Tensor Networks”. This is an obvious connection that a lot of people have asked me about, and which is not addressed anywhere in the BLO paper. (I searched the BLO paper in vain for the phrase “tensor network”).

As an aside, I think that BLO’s Ref.9 by Leifer and Poulin is patently incorrect because it is based on a new definition of conditional density matrices which imposes major constraints on standard Quantum Mechanics. So, if the work of Leifer and Poulin applies to the real world at all, it does so only within the context of a severely maimed Quantum Mechanics.

QB nets, which are exactly what BLO call “Quantum Causal Models”, do not assume any axioms beyond those of standard Quantum Mechanics. QB nets are simply a graphical way of displaying (any, all) quantum density matrices, the same way that classical Bayesian networks are simply a graphical way of displaying (any, all) joint probability distributions. In the same way that classical Bayesian networks arise from the chain rule for joint probability distributions, QB nets arise from a chain rule for quantum **probability amplitudes**. That is the gist of Ref.7, cited by the BLO paper.

I would also like to point out that the BLO paper does not mention that I too have addressed Judea Pearl’s d-separation and do-calculus as it pertains to the quantum realm. In the 2013 paper:

“An Information Theoretic Measure of Judea Pearl’s Identifiability and Causal Influence”, by Robert R. Tucci, https://arxiv.org/abs/1307.5837

I address the do-calculus for **classical** Bayesian networks, but I do so in terms of entropy. I explicitly mention in the introduction to that paper, that I intentionally use only entropy concepts to define things, with the intention that these concepts be generalized to Quantum Mechanics, using the simple rule of replacing H(P) by S(\rho) (i.e., by replacing entropies of classical probability distributions by entropies of quantum density matrices). This “minimal substitution” was invented by Cerf and Adami, and has been proven to be a powerful guiding principle in Quantum Information Theory. For instance, it led me to the discovery of the definition of Squashed Entanglement, as documented in its Wikipedia article.

## June 25, 2019

### Two Days Wasted and not Wasted, to get glorious class graph for Qubiter

Filed under: Uncategorized — rrtucci @ 9:57 pm

3 days ago, I first posted some automatically generated documentation for Qubiter at the readthedocs.org website. My first readthedocs…like having sex for the first time, not. I’ve now improved that documentation by adding a glorious, automatically generated class graph for Qubiter (a diagram showing all of Qubiter’s classes with arrows pointing from parent to children classes).

To accomplish this, I wrote in the last 2 days a python script called classgraph.py (which can now be found at the Qubiter repo at github) that generates this class graph by first scanning the Qubiter code to gather the necessary info, and then using the graphviz software to process that info. Writing that script was, in a sense, a waste of time, because a class graph, even though it looks gorgeous, is of marginal utility to the users. It helps them navigate the code slightly better, I guess. In my defense, I would like to say that 2 days is a short time, and I learned a lot in those 2 days. I learned some stuff (coding skills) that will no doubt be useful to me at a later date (like, for example, stuff about graphviz, the readthedocs website, and restructured text)

## June 22, 2019

### Qubiter Now On ReadTheDocs, like all the big boys

Filed under: Uncategorized — rrtucci @ 7:59 pm

Five days ago, I and my friend Dr. Tao Yin fixed and greatly improved pip installation of Qubiter. Today, I am happy to announce that I’ve further enhanced the Qubiter experience by adding its Sphinx generated documentation to the ReadTheDocs website. Check it out.

In technical jargon, the Sphinx software (with the Napoleon extension) can be made to produce beautiful documentation of your Python code, automatically, if the code’s docstrings are in the numpy format, as are Qubiter’s. Sphinx has various themes (skins). Among them is the one provided by the ReadTheDocs people. The ReadTheDocs people will host your documentation, free of charge, except for some ads on the left side bar. Most of the big boys in the qc languages field (for example, Rigetti Pyquil/Forest, Google Cirq, Google OpenFermion, Xanadu PennyLane) already have their documentation on ReadTheDocs. So, the bottom line is, I succumbed to peer pressure and followed the big boys.

## June 19, 2019

### The Next Man Who Fell To Earth

Filed under: Uncategorized — rrtucci @ 5:02 am

‘The Man Who Fell To Earth’ is an old British sci-fi novel and film about an extraterrestial space traveller who lands on Earth. He looks human but dresses funny. He founds a new company with the goal of building a spaceship that uses super-advanced inventions of his (including quantum computers, surely). The patents to those inventions, capable of curing world hunger and climate change on Earth, he shares freely with the world. Of course, intelligence agencies eventually find out about his extraterrestial origins and … In an upcoming movie with a similar plot, Hartmut Neven, head of Google Quantum AI, plays brilliantly the role of the extraterrestial
This photo comes from a recent article in Quanta Magazine. The article credits the photo to Hartmut Neven himself. His bathroom selfie?

More blog posts on Hartmut Neven here.

## June 17, 2019

### Pip Qubiter, Pip Qubiter, Hurray!

Filed under: Uncategorized — rrtucci @ 3:34 am

The purpose of this brief blog post is to announce that the Qubiter team (me and my friend Dr. Tao Yin) are finally getting serious about pip installation of Qubiter. Previously, Tao had uploaded what is, by now, a very old version (0.0.0) of Qubiter, onto the PyPi servers that provide the pip installation service. But as of today, you can pip install the latest version 1.0.1 of Qubiter. Just type

pip install qubiter --user

in your shell command line. This new version (unlike 0.0.0) has the canonical, pip compliant folder structure at its github repository

 folder1 ....setup.py ....folder2 ........app.py 

V 1.0.1 of Qubiter also includes a myriad of small improvements over the version of just a few weeks ago. Qubiter changes at a very fast pace! Last time I blogged about Qubiter improvements, I touted its new native Tensorflow backend, and its new implementation of a novel multi-threaded algorithm for computing gradients of quantum cost functions.

Since then, I have added to Qubiter two simple yet very useful tools for doing Continuous Integration (CI). Usually, for CI, what the big boys like Rigetti PyQuil, Google Cirq and IBM Qiskit do, is to write a matching pytest (or unittest) module for each app module and run all those pytest modules in batch via a service like travis. What I do for CI of Qubiter is not as industrial strength as the pytest/travis route, but it is much less onerous to the programmer and almost as effective at catching bugs.

Most Qubiter py files have a main() method at the end that tests the methods defined in that file. Qubiter also has a large library of Jupyter notebooks that put Qubiter through its paces. The new version 1.0.1 of Qubiter includes two py scripts,

run_all_nb.py
run_all_py.py.

The first script batch runs all the Jupyter notebooks, and the second script batch runs all those py files with a main() method at the end. These 2 py scripts together constitute a homemade tool for doing rudimentary (but pretty effective!) CI.

## May 29, 2019

### UFO’s and quantum computers

Filed under: Uncategorized — rrtucci @ 5:50 pm

Apple computer is building a quantum computer. Yes-siree. As usual, they are extremely secretive about their new products, but our carefully planted mole was able to get a picture of the iQC before its official unveiling:

Recently, the U.S. Air Force divulged that it believes in UFO’s. It stands to reason that if UFO’s exist, they must run the most advanced quantum computer software and hardware

## May 28, 2019

### Xanadu.ai, a quantum computing Theranos, will never make a profit

Filed under: Uncategorized — rrtucci @ 8:44 pm

Last night, Xanadu.ai, a quantum computing company, published the following paper in arXiv

“Quantum-inspired algorithms in practice”, by Juan Miguel Arrazola, Alain Delgado, Bhaskar Roy Bardhan, Seth Lloyd,
https://arxiv.org/abs/1905.10415

All 4 authors give Xanadu as their affiliation. The last one, Seth Lloyd, also gives MIT as an affiliation.

The main author, Arrazola, has also published a popular description of the work in his Medium blog:

This Theranos-syndrome-showing company claims that its main goal is to build hardware, a CV (Continuous Values or Variables, squeezed light) quantum computer. I am told that they just closed their second round of funding, and yet…they have never presented any hardware that can calculate anything more efficiently than a cell phone does. Even if they had, it is doubtful that such hardware could be error corrected in a fault tolerant way.

And today we learn that they spent so much time and manpower on a very abstract subject that has almost zero overlap with their CV hardware. Is this company ever going to make a profit? I am extremely doubtful that it will.

In my opinion, last night’s paper is a vanity paper for Seth Lloyd, whose obvious narcissism has been hurt by Ewing Tang’s brilliant work, which I described in a previous blog post:

https://qbnets.wordpress.com/2018/11/17/18-year-old-girl-shows-that-seth-lloyds-quantum-machine-learning-algorithm-is-junk/

Actually, the paper backfired to some extent, because Tang’s algorithm seems to work better than her complexity theory upper bounds predicted. I bet that Tang, or others, will improve her algorithm so that it works better for high rank matrices. Xanadu bozos, I hate to tell you this, but mathematical algorithms are a moving target, they almost always can be improved, especially algorithms that are so new and novel.

Despite this silly paper, the fact remains that Seth Lloyd’s Machine Learning algorithm is as dead as a door nail. It always has been, even before Ewin Tang’s brilliant work. I say this because Lloyd’s ML algorithm uses something called QRAM. QRAM is a very distant pipe dream, even more distant than far easier Fault Tolerant quantum computing, which is itself a distant dream.

To summarize, for Xanadu to be spending so much time and manpower studying a distant pipe-dream algorithm that is irrelevant to their business, instead of working on their under-performing or non-existent hardware, does not bode well for the company. I am extremely doubtful that Xanadu will ever make a profit, or make a device that calculates anything better than a cell phone does. Xanadu investors: you are being fleeced by your VCs and by Très Void.

## May 26, 2019

### Tucci’s Work Going “Almost” Viral (LOL)

Filed under: Uncategorized — rrtucci @ 3:36 am

Sometimes you find yourself losing faith in yourself and in your hard work of 20 years. But then some very kind people rise out of damn Twitter!, of all God forsaken places, to reassure you. At such times, you thank God for Twitter (LOL, I never thought I would say that. 99% of the time, I hate Twitter with a passion. I used to belong to Twitter, but no longer do. On those painful occasions when I peek into it, I access it via a prophylactic incognito tab of my web browser. )

My recent blog post entitled “Quantum simulator Qubiter now has a native TensorFlow Backend” has been shared on Twitter by a small, select group of super kind people. I want to store in this blog post the ID of those tweets before Twitter archives them and the Twitter search engine stops listing them. As of today, upon querying the Twitter search engine with the keywords (“quantum” or “quantumcomputing”) and “tensorflow”, I count 11 Tweets. In my book, even one retweet is like going “almost” viral!🙃

## May 14, 2019

### Quantum simulator Qubiter now has a native TensorFlow Backend

Filed under: Uncategorized — rrtucci @ 2:05 am

I am pleased to announce that my quantum simulator Qubiter (available at GitHub, BSD license) now has a native TensorFlow Backend-Simulator (see its class SEO_simulator_tf, the tf stands for TensorFlow). This complements Qubiter’s original numpy simulator (contained in its class SEO_simulator). A small step for Mankind, a giant leap for me! Hip Hip Hurray!

This means that Qubiter can now calculate the evolution of a state vector using CPU, GPU or TPU. Plus it can do back-propagation on a quantum circuit. Here is a jupyter notebook that I wrote that uses Qubiter’s TF backend to do VQE (Variational Quantum Eigensolving). (I like to call VQE, mean Hamiltonian minimization)

https://github.com/artiste-qb-net/qubiter/blob/master/qubiter/jupyter_notebooks/MeanHamilMinimizer_native_with_tf.ipynb

Numpy is a tensor library in Python and TensorFlow (produced by Google) is another tensor library in Python. TensorFlow matches by name and functionality, almost 1 to 1, every function in numpy. But the TF namesake functions are much more powerful than their numpy counterparts. Besides accessing the usual CPU, they can access distributed computing resources like GPU and TPU. Furthermore, they can be asked to “tape” a history of their use, and then to replay that history in reverse, back-propagation mode so as to calculate derivatives of a list of user-designated variables. These derivatives can then be used to minimize a cost (aka loss or objective) function. Such minimizations are the bread and butter of classical and quantum neural nets.

These are exciting times for TF:

• Just last March, Google released officially TF version 2.0.

• In TF 2.0, the Eager mode (which is the mode that Qubiter’s TF backend uses) has been elevated to default. TF Eager uses dynamical graphs like the TF competitor, PyTorch, produced by Facebook, uses.

• TF 2.0 also incorporates “Edward”, a software lib by Dustin Tran for doing calculations with Bayesian Networks. Edward in its TF incarnation is called TF Probability. Plus TF 2.0 is also incorporating Keras (a library for doing layered neural nets) and PyMC (a lib for doing Markov Chain Monte Carlo calculations)

• Anyone can run TF 2.0 on the cloud via Google’s Colab. That is, in fact, how I developed and tested Qubiter’s TF backend.

In theory, all you have to do to convert a numpy simulator to a tensorflow one is to change all functions that start with the prefix np. by their namesakes that start with the prefix tf.. However, the devil is in the details. I, like most good programmers, hate repeating code. I try to avoid doing so at all costs, because I don’t want to have to correct the same bug in multiple places. So I built class SEO_simulator_tf by sub-classing the original numpy simulator class SEO_simulator. That is one of the beauties of “sub-classing” in OOP (Object Oriented Programming), of which I am a great fan: sub-classing helps you avoid repeating a lot of code. So SEO_simulator_tf ended up being a deceivingly short and simple class: all it does is basically turn on a bunch of flags that it passes to its parent class SEO_simulator. Most of the new code is in the parent class SEO_simulator and other classes like OneBitGates which have been modified to respond to all those flags that SEO_simulator_tf sets.

## May 5, 2019

### Quantum Matrix Rain

Filed under: Uncategorized — rrtucci @ 9:11 pm

In a previous blog post, I compared the evaluation of gradients in quantum computing via multi-threading to the “digital rain” of The Matrix movie series. This Sunday, I was bored, so I decided to make my own artistic rendition of quantum multi-threading. It turns out to be a trivial task, requiring almost zero javascript knowledge, to write a rudimentary animation, if one uses the power of the browser and the HTML tag marquee.