Skip to main content

XoRL

Installation

pip install -e .

Basic Usage

import xorl_client
from xorl_client import types

# Connect to server
service_client = xorl_client.ServiceClient(base_url="http://localhost:5000")

# Create training client
training_client = service_client.create_lora_training_client(
    base_model="Qwen/Qwen3-4B-Instruct-2507"
)

# Get tokenizer
tokenizer = training_client.get_tokenizer()

# Prepare training data
prompt = "English: hello world\nPig Latin:"
prompt_tokens = tokenizer.encode(prompt, add_special_tokens=True)
prompt_weights = [0] * len(prompt_tokens)

completion_tokens = tokenizer.encode(" ello-hay orld-way\n\n", add_special_tokens=False)
completion_weights = [1] * len(completion_tokens)

tokens = prompt_tokens + completion_tokens
weights = prompt_weights + completion_weights

input_tokens = tokens[:-1]
target_tokens = tokens[1:]
weights = weights[1:]

datum = types.Datum(
    model_input=types.ModelInput.from_ints(tokens=input_tokens),
    loss_fn_inputs=dict(weights=weights, target_tokens=target_tokens)
)

# Training step
fwdbwd_result = training_client.forward_backward([datum], "cross_entropy").result()
optim_result = training_client.optim_step(
    types.AdamParams(learning_rate=1e-4)
).result()

print(f"Grad norm: {optim_result.metrics.get('grad_norm', 0.0):.4f}")

# Save checkpoint
training_client.save_state("checkpoint_001").result()

Checkpoint Management

# Create REST client for checkpoint operations
rest_client = service_client.create_rest_client()

# List all checkpoints
checkpoints = rest_client.list_checkpoints().result()
for cp in checkpoints.checkpoints:
    print(f"{cp.checkpoint_id}: {cp.path}")

# Delete a checkpoint (by ID or xorl:// path)
rest_client.delete_checkpoint("weights/checkpoint_001").result()
rest_client.delete_checkpoint("xorl://default/weights/checkpoint_001").result()

License

Copyright 2025 XoRL Team

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Metadata

Release files for xorl-client 0.1.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 xorl-client 0.1.0
File Size Uploaded
xorl_client-0.1.0.tar.gz 86.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xorl-client 0.1.0
File Interpreter ABI Platform
xorl_client-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 197.4 kB

Release files / xorl_client-0.1.0.tar.gz

Download URL xorl_client-0.1.0.tar.gz
Size 86.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3dea632203abdb47d9eda66b02f3b2e1b1c62606d6708557f1a92bc0d67eb7c6
BLAKE2b-256 checksum
How to use checksums
fc1c92959079d9ff061aca783cdc78642305de22eb9e14cbb363aee5cb85ded3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / xorl_client-0.1.0-py3-none-any.whl

Download URL xorl_client-0.1.0-py3-none-any.whl
Size 111.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
605bc613101d623cce4c62f0a2f1eb7f9b7e31a4e606e50d912eabe8b0287263
BLAKE2b-256 checksum
How to use checksums
40f6b6bad2c4b3b7777db617e9f5fd2a30b399d7e20ce2578c9b389ade18d81a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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