Working in the lab · Chapter 4 of 14

Python in the browser

The kernel, the SDK that is already there, its limits.

~2 min read4 sectionssame text as the guide inside the lab
All chapters

Every .py file runs in a real CPython 3.12 (Pyodide) inside a Web Worker in your tab. No server, no credits; the only network it touches is %pip fetching pure-Python packages from PyPI (and the Pyodide runtime itself).

Running a file

Open a .py and two buttons appear: ▶ Run file in the tab strip and Run in browser in the Run rail. Output streams into the dock's output tab, prefixed by ▶ main.py. While it runs the tab-strip button becomes ■ Stop — a real KeyboardInterrupt where the browser allows it (cross-origin isolation, which lab.roroquantum.com sets), a worker restart otherwise, and the log says which one happened.

The status bar reads kernel starting…kernel idle. If it says kernel unavailable, in-browser runs are off (a Chromium-based browser usually fixes it); .qasm files still submit from the Run rail.

What "run" means, exactly

  • The whole project is written into the interpreter before every run — including unsaved edits — so main.py can import ansatz, a package with __init__.py works, and open("data.csv") opens the file in the tree.
  • __name__ == "__main__" and __file__ are set; sys.path starts with the file's folder, then the project root.
  • Editing a module and re-running re-imports it; nothing runs stale.
  • Tracebacks are trimmed to frames inside your project. Explain this error in the Output pane sends the log to Copilot (metered).

The SDK that is already there

The kernel boots with the real roro_platform SDK wheels installed, so the code you write here is the code that runs on your laptop against the same package (the platform SDK ships from the RoRo repository today — it is not on PyPI yet; the REST client pip install roro-quantum is):

from roro_platform import Platform, Config, Circuit
from roro_plugin_sim_local import LocalSimulator

sim = Platform(config=Config(usage_file=None, api_key=None, default_target="local.sim.sv"),
               plugins=[LocalSimulator()])
qc = Circuit(2); qc.h(0); qc.cx(0, 1); qc.measure_all()
print(sim.run(qc, shots=1000).counts)   # {"00": ~500, "11": ~500}

Local simulation is free and offline. Machines — code names at the bottom of the Run rail lists every machine with its codename — the exact string submit_run() / run() take, identical in every SDK and the API. Copy the example line there (roro.submit_run("<codename>", shots=1000, circuit=qc)) into your own environment with an API key (mint one in the Integrate rail → API keys); inside the lab, hardware submissions go through the .qasm Run rail, which quotes and confirms before holding anything — the browser kernel deliberately carries no credentials and never spends credits on your behalf.

What it cannot do (and says so)

No qiskit, pennylane, scipy, cirq, torch, pandas — compiled packages with no WebAssembly build. import qiskit fails with one sentence naming the package, never a resolver traceback. Pure-Python packages install with %pip install <name> in a notebook cell. numpy and matplotlib are present (figures render under notebook cells). No threads, no subprocesses.

Related: Notebooks · Copilot · For teams & integration