Lightweight Python client for XoRL training service
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xorl_client-0.1.0.tar.gz
(86.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
xorl_client-0.1.0-py3-none-any.whl
(111.3 kB
view details)
File details
Details for the file xorl_client-0.1.0.tar.gz.
File metadata
- Download URL: xorl_client-0.1.0.tar.gz
- Upload date:
- Size: 86.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dea632203abdb47d9eda66b02f3b2e1b1c62606d6708557f1a92bc0d67eb7c6
|
|
| MD5 |
4d6640b4033666f87a8fc150b5b5e6e6
|
|
| BLAKE2b-256 |
fc1c92959079d9ff061aca783cdc78642305de22eb9e14cbb363aee5cb85ded3
|
File details
Details for the file xorl_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: xorl_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 111.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
605bc613101d623cce4c62f0a2f1eb7f9b7e31a4e606e50d912eabe8b0287263
|
|
| MD5 |
13d9f7dfd0a1bd9683dbdc7b87b1a5e9
|
|
| BLAKE2b-256 |
40f6b6bad2c4b3b7777db617e9f5fd2a30b399d7e20ce2578c9b389ade18d81a
|