Skip to main content

runara

Fine-tune open models without hosting them. You write the training loop; we hold the base weights and run the forward and backward passes.

pip install "runara[cookbook]"
export RUNARA_API_KEY=rk_live_...
import runara
from runara_cookbook import data, renderers
from transformers import AutoTokenizer

# Tokenized on your machine; only token ids and a loss mask are sent.
renderer = renderers.get("generic", AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct"))
dataset = data.build_data(renderer, data.conversations(data.read_jsonl("my_tickets.jsonl")))

sc = runara.ServiceClient()                      # reads RUNARA_API_KEY
with sc.create_lora_training_client(base_model="qwen-2.5-7b", rank=32) as tc:  # waits for a GPU
    for epoch in range(3):
        for batch in data.batches(dataset, 8, shuffle=True, seed=epoch):
            fb = tc.forward_backward(batch)              # submitted, not awaited
            tc.optim_step(runara.AdamParams(1e-4))       # submitted straight after
            print(fb.result().loss)                      # the loop blocks here
    tc.save_state(name="support-v1").result()

base_model is a slug from the console's Models tab, and the tokenizer is that model's Repository. my_tickets.jsonl holds one {"messages": [{"role": ..., "content": ...}, ...]} per line.

Your data does not leave your machine

open(...) runs on your computer. The cookbook tokenizes locally and builds a per-token loss mask, so what crosses the wire is a list of integers and a list of floats — no text, no filenames, no schema. A two-turn conversation is about 900 bytes of that.

You can check this yourself before sending anything:

datum = renderer.to_datum(messages)
print(datum.token_ids)       # integers
print(datum.weights)         # 0.0 for the prompt, 1.0 for what you train on

What we do keep is the adapter you write with save_state, plus token counts and loss values for billing and the charts in the console.

Why the loop is yours

There is no job to submit and no config to fill in. You decide the batching, the schedule, when to stop, and what the loss means. That is more work than a managed API and it is the point: it is the difference between tuning a model and filling in a form.

forward_backward and optim_step both return immediately. Submit them back to back and collect later — the worker applies calls for a session in the order they arrive, so the round trip overlaps your next batch of tokenization instead of stalling the GPU.

Reinforcement learning

Sample a group of replies per prompt, score them however you like, and train on how much better or worse each did than its group's average:

from runara_cookbook.rl import rl_data

prompt = renderer.generation_prompt([{"role": "user", "content": question}])
group = tc.sample([prompt], num_samples=8,
                  sampling_params=runara.SamplingParams(max_tokens=256)).result().samples[0]
rewards = [my_reward(renderer.decode(s.tokens)) for s in group]   # your code, your machine

data = rl_data(prompt, group, rewards)        # advantages = reward - group mean
if data:
    tc.forward_backward(data, "importance_sampling")
    tc.optim_step(runara.AdamParams(learning_rate=4e-5))

Each sampled sequence carries the policy's logprob of every token. These are scored exactly as training scores them, so on-policy the importance ratio is

  1. python -m runara_cookbook.recipes.rl_math is the whole loop, on problems with checkable numeric answers.

Preferences (DPO)

from runara_cookbook.preference import build_pair

data = build_pair(renderer, prompt_messages, chosen="...", rejected="...")   # chosen first
out = tc.forward_backward(data, "dpo", {"beta": 0.1}).result()
print(out.metrics["accuracy"], out.metrics["margin"])

The reference policy is the base model your session started from, at no extra cost. To compare against something else, send ref_logprobs on each datum. The whole loop is in python -m runara_cookbook.recipes.dpo.

Losses

loss_fn Data loss_fn_config
cross_entropy weights reduction: "mean" (default) or "sum"
importance_sampling logprobs, advantages none
ppo logprobs, advantages clip_low_threshold 0.8, clip_high_threshold 1.2
cispo logprobs, advantages clip_low_threshold 0.0, clip_high_threshold 4.0
dro logprobs, advantages beta (required)
dpo weights, chosen/rejected alternating, optional ref_logprobs beta 0.1

The formulas are Tinker's, so its recipes and hyperparameters carry over. The one difference: cross_entropy defaults to a per-example mean, so a long masked prompt doesn't dilute the loss. Pass {"reduction": "sum"} for Tinker's sum. The RL losses and dpo sum over tokens, as Tinker's do.

tc.forward(data) returns each target token's logprob without training, and tc.forward(data, reference=True) returns it under the base model. AdamParams(grad_clip_norm=1.0) clips gradients, and each step's gradient norm is in tc.last_optim_metrics.

A session on a worker started before these features existed refuses them up front, naming the feature. Start a new session to get a current worker.

What you get out

for checkpoint in sc.list_checkpoints():
    print(checkpoint.name, checkpoint.size_bytes, checkpoint.base_model)

Each checkpoint's uri is what tc.load_state(uri) takes to resume from it. Optimizer state isn't saved yet, so a resumed run restarts Adam's moments.

Checkpoints are standard PEFT adapters — adapter_config.json and adapter_model.safetensors — so they load in vLLM, SGLang or transformers without conversion. Download them from the console, or serve them on Runara alongside the base model.

Errors worth catching

runara.InsufficientBalance The organization is out of credit.
runara.SessionClosed The session ended, or is ending because the balance ran out.
runara.RunaraError Everything else, with .status and .code.

A training call is never retried automatically. One that timed out may already have applied its gradients, and sending it again would train on the same batch twice.

Checked against the reference

The renderers are verified to produce byte-identical tokens, targets and loss masks to tinker-cookbook for the same conversation and tokenizer. Chat templating is the part of fine-tuning that goes wrong silently, so it is checked against an independent implementation rather than only against itself.

Installing

The client has no dependencies at all — it is stdlib, so installing it cannot conflict with whatever torch, transformers or numpy versions your training code already pins. The cookbook's dependencies (transformers for tokenizers) come with the runara[cookbook] extra.

Metadata

Release files for runara 0.2.0

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

Source distribution (sdist)

Source distribution for runara 0.2.0
File Size Uploaded Provenance Actions
runara-0.2.0.tar.gz 41.8 kB Without provenance Details for runara-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runara 0.2.0
File Interpreter ABI Platform Actions
runara-0.2.0-py3-none-any.whl Python 3 none any Details for runara-0.2.0-py3-none-any.whl

Total release size: 75.4 kB

Release files / runara-0.2.0.tar.gz

Download URL runara-0.2.0.tar.gz
Size 41.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c1817b9ad2b873178a48de13cae374659b0f9b6b17102da4bb4e90841ae26e17
BLAKE2b-256 checksum
How to use checksums
b29fcdbcefc12fa287200c6879e85722f170904f836d969e98dd78656ba8be2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / runara-0.2.0-py3-none-any.whl

Download URL runara-0.2.0-py3-none-any.whl
Size 33.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9da201b45e726b39fabc3c4c868ccd9416123f0bb0e0f8ce90cf2343700526a
BLAKE2b-256 checksum
How to use checksums
54d53407d47f58edc3ce2feb5edef5c517a3d5267222cbb867147a292d0f54fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for runara 0.2.0

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