Skip to main content

cwtrain

PyPI Python

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.

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

pip install 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 hotLoad section naming the snapshot bucket, an optional pathPrefix, and transitionMode: 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, with s3:PutObject and s3: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.

Metadata

Release files for cwtrain 1.0.2

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

Source distribution (sdist)

Source distribution for cwtrain 1.0.2
File Size Uploaded Provenance Actions
cwtrain-1.0.2.tar.gz 241.4 kB Without provenance Details for cwtrain-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 370.5 kB

Release files / cwtrain-1.0.2.tar.gz

Download URL cwtrain-1.0.2.tar.gz
Size 241.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ad587af995573a7a56fbcdea67ae4510f222fc64fa59542574227c7c03f841d7
BLAKE2b-256 checksum
How to use checksums
a89e91829bf87071bfd611a04791d8dc3fbe08daef1f66c5cdd443efc75fd60f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.2-py3-none-any.whl

Download URL cwtrain-1.0.2-py3-none-any.whl
Size 129.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c631f7a0900e3069ff8e7c35e00959728d48354da37ad4733b218fadd57aa81b
BLAKE2b-256 checksum
How to use checksums
86b555f508979694a3e9b33a2d0905e989c03efd642cc7bc2673ef6e457b9fdc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","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.2

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