|
| 1 | +--- |
| 2 | +title: Trying QuTiP in the Browser |
| 3 | +--- |
| 4 | + |
| 5 | +# Trying QuTiP in the Browser |
| 6 | + |
| 7 | +QuTiP is now available in the browser! |
| 8 | + |
| 9 | +You can open it by clicking on the button below: |
| 10 | + |
| 11 | +<a class="btn btn-primary" href="/try-qutip/" role="button">Try QuTiP</a> |
| 12 | + |
| 13 | +The button opens a JupyterLite notebook server with the qutip package |
| 14 | +preinstalled. It runs entirely in your browser and includes copies of the |
| 15 | +<a href="/qutip-tutorials/">QuTiP tutorials</a> for you to explore. There is |
| 16 | +no server. |
| 17 | + |
| 18 | +Once JupterLite loads, you'll find the tutorials in the file browser on |
| 19 | +the left. If you click on a tutorial notebook, you'll need to select the |
| 20 | +XPython kernel (there is only one option) and then the notebook will open. |
| 21 | +The first imports will be slightly slow, but after that the performance |
| 22 | +should be similar to that of running QuTiP locally. |
| 23 | + |
| 24 | +<div class="alert alert-warning" role="alert"> |
| 25 | +Running QuTiP this way relies on a complex set of underlying layers of |
| 26 | +software that are still maturing. You can read about some of the |
| 27 | +caveats and a description of how it was built below. |
| 28 | +</div> |
| 29 | + |
| 30 | +Contents: |
| 31 | + |
| 32 | + - What's installed |
| 33 | + - Caveats |
| 34 | + - Contributing |
| 35 | + - How the try-qutip site is built |
| 36 | + |
| 37 | + |
| 38 | +## What's installed |
| 39 | + |
| 40 | +Currently installed packages include: |
| 41 | + |
| 42 | + - qutip (5.1.1) |
| 43 | + - qutip-qip (0.4.0) |
| 44 | + - qutip-qtrl (0.1.5) |
| 45 | + - numpy (2.2.4) |
| 46 | + - scipy (1.14.1) |
| 47 | + - matplotlib (3.10.1) |
| 48 | + - python (3.13.1) |
| 49 | + |
| 50 | + |
| 51 | +## Caveats |
| 52 | + |
| 53 | +Most QuTiP features already work. These are the known limitations: |
| 54 | + |
| 55 | + - A recent version of Firefox or Chrome is required. |
| 56 | + - Cython is not yet available so QobjEvo objects cannot currently |
| 57 | + be usefully compiled. |
| 58 | + - You can save notebooks but, they are <em>stored in your web browser's |
| 59 | + internal storage and might be lost if, for example, the browser cache |
| 60 | + is cleared. If you do create notebooks you'd like to keep, please |
| 61 | + use the download button to save them.</em> |
| 62 | + - Notebooks are slow to start, but performance is not too bad after that. |
| 63 | + |
| 64 | +Specific known issues are listed in [try-qutip's GitHub issues](https://github.com/qutip/try-qutip/issues/). |
| 65 | +Further issues and bugs may be reported there. |
| 66 | + |
| 67 | + |
| 68 | +## Contributing |
| 69 | + |
| 70 | +If you encounter bugs with QuTiP in the browser that aren't listed in the |
| 71 | +caveats above, you are welcome to open issues in the |
| 72 | +[try-qutip GitHub repository](https://github.com/qutip/try-qutip/). |
| 73 | + |
| 74 | +If you know a way to address any of the caveats above, please let us |
| 75 | +know by open an issue or pull request in the |
| 76 | +[try-qutip GitHub repository](https://github.com/qutip/try-qutip/). |
| 77 | + |
| 78 | +If you find bugs in a specific tutorial, or would like to add a new tutorial |
| 79 | +or improve an existing one, please see the contributing section at the bottom |
| 80 | +of the [tutorials page](/qutip-tutorials/). |
| 81 | + |
| 82 | +If you have general questions about how to use QuTiP, email the |
| 83 | +[QuTiP mailing list](https://groups.google.com/group/qutip). |
| 84 | + |
| 85 | + |
| 86 | +## How the try-qutip site is built |
| 87 | + |
| 88 | +The try-qutip site contains JupyterLite with QuTiP pre-installed. |
| 89 | + |
| 90 | +[JupyterLite](https://github.com/jupyterlite/jupyterlite) is a |
| 91 | +version of [JupyterLab](https://github.com/jupyterlab/jupyterlab) |
| 92 | +that has been modified work run in the browser as a |
| 93 | +[Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API). |
| 94 | +A service worker acts like a web server that runs inside your browser and in this |
| 95 | +case plays the role of the Jupyter server that would otherwise need to be run locally. |
| 96 | + |
| 97 | +Running this Jupyter server in the browser means running Python and packages |
| 98 | +such as numpy, SciPy and matplotlib in the browser too. To do that, all |
| 99 | +of these packages need to be recompiled to |
| 100 | +[WebAssembly (aka WASM)](https://webassembly.org/) and for |
| 101 | +that one needs a suitable compiler, in this case, |
| 102 | +[Emscripten](https://emscripten.org). |
| 103 | + |
| 104 | +Lastly, we need to compile QuTiP itself. The amazing team at |
| 105 | +[QuantStack](https://quantstack.net/) are building |
| 106 | +[emscripten-forge](https://beta.mamba.pm/channels/emscripten-forge/packages/?tab=packages) |
| 107 | +which is like [conda-forge](https://conda-forge.org/) but for building packages |
| 108 | +for WebAssembly. |
| 109 | + |
| 110 | +With the help of Wolf and Martin from QuantStack, we created a |
| 111 | +[QuTiP package on emscripten-forge](https://beta.mamba.pm/channels/emscripten-forge/packages/qutip). |
| 112 | +The recipe for building the package can be found in the |
| 113 | +[emscripten-forge/recipes](https://github.com/emscripten-forge/recipes) repository. |
| 114 | + |
| 115 | +An additional big thank you to Thorsten Beier from QuantStack for fixing |
| 116 | +numerous small niggles and thus allowing QuTiP 5 to deployed to try-qutip. |
0 commit comments