Troubleshooting and best practices
Common errors and solutions
ConcurrentAccessError-
A session supports one
TrainingClientat a time. You opened a second client on a session that already has one. Stop the first client, or scope each client to awithblock. OperationErroronforward_backward-
A required
loss_fn_inputskey is missing, or a tensor length does not match the model input. Provide full-sequence values with prompt positions zero-padded, and include every key your loss function requires. See Training data. ValueErrorfrom a restore factory-
You passed both
base_modelandmodel_package_arnand they name different base models, or you calledget_latest_model_packagewithout amodel_package_group_arn. Pass matching values, or set the group on the client. - Rewards stop improving during RL
-
You are sampling from stale weights. A
SamplingClientis bound to the weights that existed when it was created. Rebind after everyoptim_stepwithsave_weights_and_get_sampling_client(). See On-policy sampling. - Checkpoint operations fail with a Amazon VPC configuration
-
S3 hostnames are not resolving to private IPs. Enable Private DNS on your S3 interface endpoint and enable DNS support and DNS hostnames on the Amazon VPC. See Configure a VPC for SageMaker AI training sessions.
Session inspection and diagnostics
-
Use
svc.list_sessions(status_equals=...)to find active or failed sessions, andDescribeTrainingSessionfor the status and failure reason of a specific session. -
future.result()raisesOperationErrorwith the failure detail for an individual operation. Collect results as you pipeline so a failure surfaces at the step that caused it.
Best practices
-
Checkpoint periodically. A session is compute and cannot be reattached by name. Call
save_stateon a fixed interval so you can resume from the latest checkpoint after a fault. -
Stop idle sessions. An idle session holds the resources. Call
stop()when you finish, or scope the client to awithblock. -
Pipeline operations. Submit successive training operations before collecting the earlier result, and keep many sampling calls in flight, to raise throughput.
-
Use one model package group per experiment. An unnamed group is shared across your account, which makes
get_latest_model_packageambiguous. A dedicated group keeps resume exact. -
Clean up model packages. Each saved package consumes Amazon S3 storage until you remove it. Use
delete_model_package(arn, delete_artifacts=True)to remove both the package and its stored weights.