Get started with Cortex Training¶
This guide walks you through installing the client, connecting to your account, running a short fine-tuning loop end to end, and streaming responses from your fine-tuned model.
Prerequisites¶
- A Snowflake account on Amazon Web Services (AWS) with Cortex Training enabled. To enable Cortex Training, contact your account team.
- A programmatic access token (PAT) for authentication.
- Python 3.10 or later.
Step 1: Install the client¶
Install the
Cortex Training client. The
package includes the cortex-training CLI and the cortex_training Python
namespace:
You can use pip instead of uv pip.
Verify the CLI installation:
Step 2: Connect to your account¶
Create a client with your account host and PAT. The database and schema scope where your
jobs and checkpoints live.
Step 3: Create a training job¶
Describe the base model and training parameters with SubJobConfig.training_job, then create
the job and wait for it to start.
Step 4: Run the training loop¶
Each training step is two async calls: a forward and backward pass, then an optimizer step. Poll each request for its result.
Step 5: Save a checkpoint¶
Save a weights-only checkpoint when training finishes. You can use this checkpoint to run
inference.
Step 6: Run inference from your checkpoint¶
Create a sampling job that points at the saved checkpoint, then generate completions.
Step 7: Deploy your checkpoint to a streaming endpoint¶
A model deployment serves your checkpoint through an OpenAI-compatible chat completions endpoint, so any OpenAI-compatible client can stream responses from it token by token.
Create the deployment from the weights-only checkpoint that you saved, then wait until it’s
READY. You don’t specify the model: the client reads it from the training job. This works
the same way for a checkpoint from a LoRA training job.
The deployment ID has the form sf-ct-<UUID>. Reaching READY can take several minutes,
because the deployment loads the model onto the GPUs first. To deploy a base model instead
of a checkpoint, set source to {"type": "base_model", "model": "Qwen/Qwen3-8B"}.
Next, install the openai package:
Then stream a chat completion. Authenticate with your PAT, and pass the deployment ID as
model:
Use max_completion_tokens to limit the response length. The deployment endpoint rejects
max_tokens.
Note
Inference isn’t available on all accounts yet. Until it’s enabled for your account, requests
to the endpoint return HTTP 403 or 405. Requests to a deployment that isn’t READY yet return
HTTP 503.
For the full list of deployment methods, spec rules, and endpoint behavior, see Model deployments.
Step 8: Clean up¶
A deployment holds its GPUs until you drop it. Drop the deployment and cancel jobs you’re no longer using to release GPUs.