execute_training_operation
async
¶
execute_training_operation(
training_session_name: TrainingSessionName,
sequence_number: SequenceNumber,
operation_config: OperationConfig,
*,
config_overrides: Optional[AsyncSageMakerTrainingSessionRuntimeClientConfig] = None,
client_token: Optional[ClientToken] = None,
) -> ExecuteTrainingOperationOutput
Submits an asynchronous training operation to the specified training session. The service executes operations in sequence number order. The session must be in Running or Blocked state. Use GetTrainingOperationResult to poll for the result. Supported operation types: forward, forwardBackward, optimizerStep, saveWeights, saveState, and loadState.
Parameters:
-
training_session_name(TrainingSessionName) –The name of the training session to submit the operation to.
-
sequence_number(SequenceNumber) –The monotonically increasing sequence number that determines execution order. The training session processes operations strictly in sequence number order. If a gap exists, the session blocks until the missing operation arrives or times out. Must be at least 1.
-
client_token(Optional[ClientToken], default:None) –A unique, case-sensitive identifier that you provide to ensure that the operation completes no more than one time. If you retry a request with the same client token and the same parameters, the service ignores the request but does not return an error.
-
operation_config(OperationConfig) –The configuration that specifies the type and parameters of the training operation. Exactly one member of the union must be set.
Raises:
-
ConflictException–The training session is in a state that cannot accept new operations. The session must be in
RunningorBlockedstate to accept requests. -
InternalServerException–An internal service error occurred. Retry the request using exponential backoff.
-
ResourceNotFoundException–The specified training session or operation does not exist, or the operation does not belong to the specified training session.
-
ThrottlingException–The request was throttled. Retry the request after a brief wait using exponential backoff.
-
ValidationException–The request is not valid. Check the request syntax and parameters. Examples include invalid sequence numbers, malformed client tokens, missing required fields, or invalid operation configuration.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Run a forward and backward pass
Computes gradients for a batch of tokenized prompts and accumulates them into the session. Operations are applied in sequenceNumber order, so each call must supply the next number in the sequence.
>>> await client.execute_training_operation(training_session_name='my-training-session', sequence_number=1, operation_config={'forwardBackward': {'lossFnName': 'cross_entropy', 'datumList': [{'modelInput': {'chunks': [{'tokens': [791, 6864, 315, 9822, 374, 12366], 'type': 'encoded_text'}]}}]}})
Source code in docs_src/capo_sagemakertrainingsessionruntime/_services/async_sage_maker_training_session_runtime.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | |