cwtrain
cwtrain is the Python library and CLI for training against
CoreWeave Dedicated Inference. In this
setup, the training loop gets its rollouts from a Dedicated Inference deployment, not from its own
inference engines. The library covers each part of the loop:
- The deployment (
cwtrain.infra,cwtrain deployment ...): create the deployment that a run samples from, wait until it serves, find the rollout URL, and delete it at the end. - Weight updates (
cwtrain.hotload,cwtrain hotload ...): after each training step, publish the trainer's weights to the running deployment as a full checkpoint or a compressed delta. Then wait until every replica serves them. This uses checkpoint hot-load from RL Rollouts, so no redeploy is needed. - Rollouts and frameworks (
cwtrain.integrations): a rollout sampler for the deployment's OpenAI-compatible endpoint, the post-write hook for slime and miles, and the generation backend, weight synchronizer and policy-worker extension for NeMo-RL. - W&B dashboards (
cwtrain dashboard ..., pending release): native post-training views, run comparisons, interactive phase timelines, and local timeline export. See Post-training dashboards.
The CoreWeave Inference Cookbook has the recipes
that use cwtrain with miles, slime, NeMo-RL and Axolotl, and examples that run them end to end.
Install
python -m pip install --upgrade cwtrain
This also installs the cwtrain CLI. The framework integrations need no extras: install
cwtrain into the framework's environment, which provides what they import (torch, and for
NeMo-RL also safetensors).
Then point it at your account and bucket. COREWEAVE_API_TOKEN is a CoreWeave API token with the
Inference Admin role. The AWS keys are your CoreWeave AI Object Storage credentials, and
AWS_REGION is the bucket's CoreWeave Availability Zone, such as US-EAST-04A:
export COREWEAVE_API_TOKEN=...
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION=...
When COREWEAVE_API_TOKEN is not set, cwtrain reads the token from CW_API_TOKEN, the variable
that the CoreWeave documentation exports.
Prerequisites
RL Rollouts is in preview and is enabled per organization. To turn it on, contact CoreWeave
support and give your organization ID. Until it is on, creating a deployment with a hotLoad
section fails with hot-load is not enabled for this organization.
Create a new deployment with hot-load enabled. You can set hot-load only when you create a deployment; you cannot add it to an existing one. The deployment needs:
- engine
dynamo-vllm; - a
hotLoadsection naming the snapshotbucket, an optionalpathPrefix, andtransitionMode: TRANSITION_MODE_ASYNC; - all of its gateways in one zone.
Your organization must own the bucket. Its bucket policy needs three statements:
- the one from the Dedicated Inference docs (Grant inference access to your bucket), which lets the canonical inference service account list and read the bucket;
- your organization's statement, which keeps list and read access for your users and the trainer. A bucket policy makes the bucket explicit-allow only, so without it all other access stops;
- one that lets the trainer write under the deployment's
pathPrefix, withs3:PutObjectands3:AbortMultipartUpload. The trainer never deletes objects or changes the policy.
The cookbook's example bucket policy has these statements. The bucket can be empty when you create the deployment, because the service checks snapshots at each hot-load request.
With the trainer's storage credentials, cwtrain hotload check --deployment <id> checks those
permissions before you train. It lists the prefix, reads a key and starts a multipart upload that
it aborts, so it writes no object. When a call is refused, it names the S3 permission that is
missing.
Quick start
Create the deployment
Put a CreateDeploymentRequest body in a file, with its placeholders filled in. Each example in
the cookbook has one, deployment.example.json.
deployment parameters lists the runtime versions, instance types and engine options that your
gateway's zone offers. Then create the deployment:
cwtrain deployment parameters --gateway <gateway id>
cwtrain deployment create --file deployment.json --wait
create prints the deployment as JSON, with its id and its rollout_base_url for rollouts.
With --wait, it returns when the deployment is READY. This takes minutes, and longer for large
models. If the deployment fails, or is not READY within --timeout (an hour by default), create
still prints it and exits with status 1.
Publish weights
from cwtrain import HotLoader, InferenceClient
loader = HotLoader(InferenceClient(), deployment_id="<deployment-uuid>")
# After saving a HuggingFace checkpoint for the current step:
hot_load = loader.publish("/ckpt/step_000100", identity="step_000100")
print(hot_load.state.name) # COMPLETED
publish validates the directory and uploads it to the deployment's bucket and prefix. Then it
creates the hot-load and blocks until every replica serves the new weights. With wait=False, it
returns once the hot-load is created; call loader.wait(hot_load.id) to wait for it later.
From the shell
cwtrain hotload publish --deployment <uuid> --checkpoint /ckpt/step_000100 --identity step_000100
cwtrain hotload list --deployment <uuid>
cwtrain hotload status <hot-load uuid>
cwtrain deployment delete <uuid> --wait
The deployment holds its GPUs until you delete it. cwtrain --help lists the commands, and
cwtrain <group> <command> --help shows a command's options.
W&B dashboards
The dashboard commands need cwtrain 1.0.3 or later. The standard package includes them and
their W&B dependencies:
python -m pip install --upgrade cwtrain
cwtrain dashboard setup --entity ENTITY --project PROJECT --framework miles --dry-run
The dry run previews the full metric catalogue offline. Authenticate with wandb login or
WANDB_API_KEY, then omit --dry-run to create a managed Post-training view from the
project's recorded metrics. Dashboard commands need W&B credentials, not CoreWeave or storage
credentials. The dashboard guide covers the other frameworks, safe reruns,
metric semantics, and exporting an interactive run timeline to HTML.
Metadata
Release files for cwtrain 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cwtrain-1.0.3.tar.gz | 353.8 kB | Without provenance | Details for cwtrain-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cwtrain-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for cwtrain-1.0.3-py3-none-any.whl |
Total release size: 522.4 kB
Release files / cwtrain-1.0.3.tar.gz
| Download URL | cwtrain-1.0.3.tar.gz |
|---|---|
| Size | 353.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a4e4ce7036cc89df138647d4d169bcd399b3c13d676dcbed9074d84facc8e36
|
|
BLAKE2b-256 checksum How to use checksums |
36ac2b4ca008a22271ea9856f2b752fd235c0dcf29561c58d1e708a1d9da6059
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / cwtrain-1.0.3-py3-none-any.whl
| Download URL | cwtrain-1.0.3-py3-none-any.whl |
|---|---|
| Size | 168.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee61a4a9261794f8bd9f73f81c8c49c936ee80857d47a421b48012ce21e32ef4
|
|
BLAKE2b-256 checksum How to use checksums |
7f07a447e7fde3ab690d4ff9428b7a79eb1123672de5199c9fda83e626162e7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for cwtrain 1.0.3
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.