Skip to main content

krauncher-jupyter

%%krauncher — a Jupyter cell magic that runs a marked notebook cell as an ephemeral task on the cheapest suitable remote GPU, via the Krauncher broker. The notebook kernel stays local; only cells you mark go remote. Price is quoted before the cell runs.

%pip install krauncher-jupyter
%load_ext krauncher_magic
%%krauncher --pip torch
import torch
import torch.nn as nn

model = build_model().to("cuda")
losses = train(model, epochs, batch_size)   # epochs, batch_size taken from the notebook
accuracy = evaluate(model)
krauncher: auto --in epochs,batch_size --out model,losses,accuracy
krauncher: estimate — cv_training, ≥6 GB VRAM, 214.0 CU
Executing on worker-a1514da4: RTX 5060 Ti, 15GB, storage 2884 MB/s, net 800 Mbps
Epoch 1/3  avg_loss=2.3409          ← streamed live, with a GPU metric line
krauncher: done on RTX 5060 Ti in 131.2s — 3.42 KU → losses, accuracy

losses and accuracy are regular variables in the notebook afterwards, produced on a GPU picked for the lowest price for this specific workload. No flags are required: the transfer set is detected from the cell's code.

Why per-cell

Each marked cell is one ephemeral task: no GPU session, no idle time billed, no instance to choose. The broker classifies the cell's code (VRAM, workload class, compute units), quotes it, and dispatches it to the cheapest GPU that fits — across providers. Unmarked cells cost nothing.

No GPU state persists between cells (load-model-in-one-cell, use-in-the-next does not work — group related work into a single cell). Consecutive cells with the same requirements do reuse a warm worker when one is still around (session affinity), and an opt-in idle hold in your account settings keeps it around longer.

What the magic does for you

  • Auto namespace — free variables of the cell that exist in the notebook are sent as inputs; assigned names come back as outputs. Values are JSON-safe data; models/tensors stay on the worker and are reported, not fatal. Credential-shaped values and values over 1 MB are held back unless passed explicitly with --in.
  • Quote before run — the analysis phase prices the cell (VRAM, compute units, IO) before anything is submitted; --estimate stops there.
  • Live feedback — remote stdout/stderr stream into the cell output as they happen, plus a GPU utilisation/VRAM/elapsed progress line.
  • Hugging Face / S3 pre-fetch — literal load_dataset("org/name"), from_pretrained("org/name") and "s3://bucket/key" references are downloaded by the data bridge before the container starts and served to your unmodified code. Credentials come from your account defaults (Storage → Credentials).
  • Non-blocking cells — --async submits and returns a handle for later cells (await kr_task / kr_task.result()).
  • Restart the kernel = cancel — in-flight tasks are cancelled and their holds released when the kernel exits.

Options

Flag Meaning
--in NAMES override the auto-detected inputs (comma-separated, repeatable)
--out NAMES override the auto-detected outputs
--pip PKGS pip packages installed in the sandbox before execution
--vram N minimum GPU VRAM in GB (default: auto-classified from the code)
--gpu-name S pin a GPU model (case-insensitive substring, e.g. A4000)
--timeout N execution timeout in seconds (default 600)
--dataset-size MB declared input size for the quote (e.g. private S3 objects)
--async [NAME] non-blocking: inject a task handle as NAME (default kr_task)
--estimate classify and print the quote only — do not run

Install & credentials

pip install krauncher-jupyter          # pulls the krauncher SDK

CAS_API_KEY (and optionally CAS_BROKER_URL) as environment variables or in a .env next to the notebook — same as the SDK. Get a key at krauncher.com → Account → API Keys.

Limitations

  • Transferred values are JSON-safe data only (numbers, strings, lists, dicts) within a 16 MB inline budget; larger or binary data goes through data sources / volumes / the HF-S3 pre-fetch above.
  • No GPU state across cells (see "Why per-cell").
  • Dynamic Hub/S3 references (f-strings, variables) cannot be pre-fetched — they download inside execution instead of the pre-fetch phase (a warning says so).
  • Top-level global in a cell is not supported (the body runs as a function).

Development

PYTHONPATH=.:../cas-client python -m pytest tests/

License

MIT © 2026 Ilya Sergeev

Metadata

Release files for krauncher-jupyter 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for krauncher-jupyter 0.2.7
File Size Uploaded Provenance Actions
krauncher_jupyter-0.2.7.tar.gz 10.3 kB Without provenance Details for krauncher_jupyter-0.2.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for krauncher-jupyter 0.2.7
File Interpreter ABI Platform Actions
krauncher_jupyter-0.2.7-py3-none-any.whl Python 3 none any Details for krauncher_jupyter-0.2.7-py3-none-any.whl

Total release size: 21.9 kB

Release files / krauncher_jupyter-0.2.7.tar.gz

Download URL krauncher_jupyter-0.2.7.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7017799756cfae64a7b6a6e326686d6e09c97ab9752ba160e864fb24075cb72e
BLAKE2b-256 checksum
How to use checksums
284f2ee06d40779f28adb4edbf05fc084920380b44f250438f7fdcc17ee4aa2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / krauncher_jupyter-0.2.7-py3-none-any.whl

Download URL krauncher_jupyter-0.2.7-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84ac5941084d3ccfe97de2516a8e90906addd746ff73b0d2f41cf24b04c61929
BLAKE2b-256 checksum
How to use checksums
87f889e02943763b6935cf22f92a6129990be09b0caedb10a42f45127539eae5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for krauncher-jupyter 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page