aws-sdk-sagemakertrainingsessionruntime 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1183 @@
1
+ # frozen_string_literal: true
2
+
3
+ # WARNING ABOUT GENERATED CODE
4
+ #
5
+ # This file is generated. See the contributing guide for more information:
6
+ # https://github.com/aws/aws-sdk-ruby/blob/version-3/CONTRIBUTING.md
7
+ #
8
+ # WARNING ABOUT GENERATED CODE
9
+
10
+ module Aws::SageMakerTrainingSessionRuntime
11
+ module Types
12
+
13
+ # The Adam optimizer hyperparameters used during an optimizer step.
14
+ #
15
+ # @!attribute [rw] learning_rate
16
+ # The learning rate for the optimizer. Must be greater than 0.
17
+ # @return [Float]
18
+ #
19
+ # @!attribute [rw] beta1
20
+ # The exponential decay rate for the first moment estimates.
21
+ # @return [Float]
22
+ #
23
+ # @!attribute [rw] beta2
24
+ # The exponential decay rate for the second moment estimates.
25
+ # @return [Float]
26
+ #
27
+ # @!attribute [rw] eps
28
+ # A small constant added to the denominator for numerical stability.
29
+ # @return [Float]
30
+ #
31
+ # @!attribute [rw] weight_decay
32
+ # The weight decay (L2 regularization) coefficient.
33
+ # @return [Float]
34
+ #
35
+ # @!attribute [rw] grad_clip_norm
36
+ # The maximum gradient norm for gradient clipping. Gradients are
37
+ # scaled down if their norm exceeds this value.
38
+ # @return [Float]
39
+ #
40
+ # @!attribute [rw] lora_plus_lr_ratio
41
+ # The learning rate multiplier for LoRA+ B matrices relative to A
42
+ # matrices. When set, B matrices use `learningRate * loraPlusLrRatio`
43
+ # while A matrices use the base learning rate.
44
+ # @return [Float]
45
+ #
46
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/AdamParamsConfig AWS API Documentation
47
+ #
48
+ class AdamParamsConfig < Struct.new(
49
+ :learning_rate,
50
+ :beta1,
51
+ :beta2,
52
+ :eps,
53
+ :weight_decay,
54
+ :grad_clip_norm,
55
+ :lora_plus_lr_ratio)
56
+ SENSITIVE = []
57
+ include Aws::Structure
58
+ end
59
+
60
+ # The configuration for computing log-probabilities of prompt tokens
61
+ # without generating new text.
62
+ #
63
+ # @!attribute [rw] prompt
64
+ # The input prompt whose token log-probabilities will be computed.
65
+ # @return [Types::ModelInput]
66
+ #
67
+ # @!attribute [rw] model_package_arn
68
+ # The ARN of the model package whose checkpoint this operation should
69
+ # run against. Must be a valid SageMaker model package ARN in the
70
+ # format
71
+ # `arn:aws:sagemaker:REGION:ACCOUNT:model-package/PACKAGE_NAME/VERSION`.
72
+ # When absent, the operation runs against the session's latest
73
+ # checkpoint.
74
+ # @return [String]
75
+ #
76
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ComputeLogprobsConfig AWS API Documentation
77
+ #
78
+ class ComputeLogprobsConfig < Struct.new(
79
+ :prompt,
80
+ :model_package_arn)
81
+ SENSITIVE = [:prompt]
82
+ include Aws::Structure
83
+ end
84
+
85
+ # The result of a compute-logprobs operation.
86
+ #
87
+ # @!attribute [rw] logprobs
88
+ # The per-token log-probabilities for the input prompt.
89
+ # @return [Array<Float>]
90
+ #
91
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ComputeLogprobsResult AWS API Documentation
92
+ #
93
+ class ComputeLogprobsResult < Struct.new(
94
+ :logprobs)
95
+ SENSITIVE = []
96
+ include Aws::Structure
97
+ end
98
+
99
+ # The training session is in a state that cannot accept new operations.
100
+ # The session must be in `Running` or `Blocked` state to accept
101
+ # requests.
102
+ #
103
+ # @!attribute [rw] message
104
+ # @return [String]
105
+ #
106
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ConflictException AWS API Documentation
107
+ #
108
+ class ConflictException < Struct.new(
109
+ :message)
110
+ SENSITIVE = []
111
+ include Aws::Structure
112
+ end
113
+
114
+ # A single training datum containing model input and optional loss
115
+ # function inputs.
116
+ #
117
+ # @!attribute [rw] model_input
118
+ # The tokenized input to feed to the model.
119
+ # @return [Types::ModelInput]
120
+ #
121
+ # @!attribute [rw] loss_fn_inputs
122
+ # The tensor inputs for the loss function, keyed by name. Unsupported
123
+ # keys are rejected. Supported keys: `target_tokens`, `weights`,
124
+ # `advantages`, `logprobs`, `ref_log_prob`, `temperature`. Required
125
+ # keys depend on the loss function type: SFT (`cross_entropy`)
126
+ # requires `target_tokens` and `weights`; RL (`ppo`, `cispo`,
127
+ # `importance_sampling`) requires `target_tokens`, `weights`,
128
+ # `advantages`, and `logprobs`.
129
+ # @return [Hash<String,Types::TensorData>]
130
+ #
131
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/Datum AWS API Documentation
132
+ #
133
+ class Datum < Struct.new(
134
+ :model_input,
135
+ :loss_fn_inputs)
136
+ SENSITIVE = [:model_input]
137
+ include Aws::Structure
138
+ end
139
+
140
+ # A chunk of pre-tokenized text represented as a list of token IDs.
141
+ #
142
+ # @!attribute [rw] tokens
143
+ # The token IDs representing the encoded text.
144
+ # @return [Array<Integer>]
145
+ #
146
+ # @!attribute [rw] type
147
+ # The type of the chunk encoding.
148
+ # @return [String]
149
+ #
150
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/EncodedTextChunk AWS API Documentation
151
+ #
152
+ class EncodedTextChunk < Struct.new(
153
+ :tokens,
154
+ :type)
155
+ SENSITIVE = []
156
+ include Aws::Structure
157
+ end
158
+
159
+ # @!attribute [rw] training_session_name
160
+ # The name of the training session to sample from.
161
+ # @return [String]
162
+ #
163
+ # @!attribute [rw] operation_config
164
+ # The configuration for the sample operation. Specify either a sample
165
+ # configuration to generate text or a computeLogprobs configuration to
166
+ # compute token log-probabilities.
167
+ # @return [Types::SampleOperationConfig]
168
+ #
169
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ExecuteSamplingOperationInput AWS API Documentation
170
+ #
171
+ class ExecuteSamplingOperationInput < Struct.new(
172
+ :training_session_name,
173
+ :operation_config)
174
+ SENSITIVE = []
175
+ include Aws::Structure
176
+ end
177
+
178
+ # @!attribute [rw] operation_id
179
+ # The unique identifier for the submitted sample operation. Use this
180
+ # identifier with `GetSamplingOperationResult` to retrieve the
181
+ # operation status and result.
182
+ # @return [String]
183
+ #
184
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ExecuteSamplingOperationOutput AWS API Documentation
185
+ #
186
+ class ExecuteSamplingOperationOutput < Struct.new(
187
+ :operation_id)
188
+ SENSITIVE = []
189
+ include Aws::Structure
190
+ end
191
+
192
+ # @!attribute [rw] training_session_name
193
+ # The name of the training session to submit the operation to.
194
+ # @return [String]
195
+ #
196
+ # @!attribute [rw] sequence_number
197
+ # The monotonically increasing sequence number that determines
198
+ # execution order. The training session processes operations strictly
199
+ # in sequence number order. If a gap exists, the session blocks until
200
+ # the missing operation arrives or times out. Must be at least 1.
201
+ # @return [Integer]
202
+ #
203
+ # @!attribute [rw] client_token
204
+ # A unique, case-sensitive identifier that you provide to ensure that
205
+ # the operation completes no more than one time. If you retry a
206
+ # request with the same client token and the same parameters, the
207
+ # service ignores the request but does not return an error.
208
+ # @return [String]
209
+ #
210
+ # @!attribute [rw] operation_config
211
+ # The configuration that specifies the type and parameters of the
212
+ # training operation. Exactly one member of the union must be set.
213
+ # @return [Types::OperationConfig]
214
+ #
215
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ExecuteTrainingOperationInput AWS API Documentation
216
+ #
217
+ class ExecuteTrainingOperationInput < Struct.new(
218
+ :training_session_name,
219
+ :sequence_number,
220
+ :client_token,
221
+ :operation_config)
222
+ SENSITIVE = []
223
+ include Aws::Structure
224
+ end
225
+
226
+ # @!attribute [rw] operation_id
227
+ # The unique identifier for the submitted operation. Use this
228
+ # identifier with `GetTrainingOperationResult` to retrieve the
229
+ # operation status and result.
230
+ # @return [String]
231
+ #
232
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ExecuteTrainingOperationOutput AWS API Documentation
233
+ #
234
+ class ExecuteTrainingOperationOutput < Struct.new(
235
+ :operation_id)
236
+ SENSITIVE = []
237
+ include Aws::Structure
238
+ end
239
+
240
+ # The configuration for a forward and backward pass through the model.
241
+ # This computes both loss values and gradients for use in subsequent
242
+ # optimizer steps.
243
+ #
244
+ # @!attribute [rw] loss_fn_name
245
+ # The name of the loss function to evaluate during the
246
+ # forward-backward pass.
247
+ # @return [String]
248
+ #
249
+ # @!attribute [rw] datum_list
250
+ # The list of input data to feed through the model. Must contain at
251
+ # least one datum, and each datum must have a non-empty modelInput
252
+ # with at least one chunk.
253
+ # @return [Array<Types::Datum>]
254
+ #
255
+ # @!attribute [rw] loss_fn_config
256
+ # Additional loss function configuration passed to the engine.
257
+ # Supported keys are `clip_low_threshold` (valid range: 0 to 1) and
258
+ # `clip_high_threshold` (valid range: 1 to 10). Unsupported keys are
259
+ # rejected.
260
+ # @return [Hash,Array,String,Numeric,Boolean]
261
+ #
262
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ForwardBackwardConfig AWS API Documentation
263
+ #
264
+ class ForwardBackwardConfig < Struct.new(
265
+ :loss_fn_name,
266
+ :datum_list,
267
+ :loss_fn_config)
268
+ SENSITIVE = [:datum_list]
269
+ include Aws::Structure
270
+ end
271
+
272
+ # The result of a forward and backward pass through the model, including
273
+ # computed gradients.
274
+ #
275
+ # @!attribute [rw] loss_fn_output_type
276
+ # The data type of the loss function output tensors.
277
+ # @return [String]
278
+ #
279
+ # @!attribute [rw] loss_fn_outputs
280
+ # The loss function output tensors, keyed by name.
281
+ # @return [Array<Hash<String,Types::TensorData>>]
282
+ #
283
+ # @!attribute [rw] metrics
284
+ # The training metrics emitted by the engine, such as loss values.
285
+ # @return [Hash<String,Float>]
286
+ #
287
+ # @!attribute [rw] token_usage
288
+ # The token usage statistics for metering.
289
+ # @return [Types::TrainingTokenUsage]
290
+ #
291
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ForwardBackwardResult AWS API Documentation
292
+ #
293
+ class ForwardBackwardResult < Struct.new(
294
+ :loss_fn_output_type,
295
+ :loss_fn_outputs,
296
+ :metrics,
297
+ :token_usage)
298
+ SENSITIVE = []
299
+ include Aws::Structure
300
+ end
301
+
302
+ # The configuration for a forward-only pass through the model. This
303
+ # computes loss values without computing gradients.
304
+ #
305
+ # @!attribute [rw] loss_fn_name
306
+ # The name of the loss function to evaluate during the forward pass.
307
+ # @return [String]
308
+ #
309
+ # @!attribute [rw] datum_list
310
+ # The list of input data to feed through the model. Must contain at
311
+ # least one datum, and each datum must have a non-empty modelInput
312
+ # with at least one chunk.
313
+ # @return [Array<Types::Datum>]
314
+ #
315
+ # @!attribute [rw] loss_fn_config
316
+ # Additional loss function configuration passed to the engine.
317
+ # Supported keys are `clip_low_threshold` (valid range: 0 to 1) and
318
+ # `clip_high_threshold` (valid range: 1 to 10). Unsupported keys are
319
+ # rejected.
320
+ # @return [Hash,Array,String,Numeric,Boolean]
321
+ #
322
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ForwardConfig AWS API Documentation
323
+ #
324
+ class ForwardConfig < Struct.new(
325
+ :loss_fn_name,
326
+ :datum_list,
327
+ :loss_fn_config)
328
+ SENSITIVE = [:datum_list]
329
+ include Aws::Structure
330
+ end
331
+
332
+ # The result of a forward-only pass through the model.
333
+ #
334
+ # @!attribute [rw] loss_fn_output_type
335
+ # The data type of the loss function output tensors.
336
+ # @return [String]
337
+ #
338
+ # @!attribute [rw] loss_fn_outputs
339
+ # The loss function output tensors, keyed by name.
340
+ # @return [Array<Hash<String,Types::TensorData>>]
341
+ #
342
+ # @!attribute [rw] metrics
343
+ # The training metrics emitted by the engine, such as loss values.
344
+ # @return [Hash<String,Float>]
345
+ #
346
+ # @!attribute [rw] token_usage
347
+ # The token usage statistics for metering.
348
+ # @return [Types::TrainingTokenUsage]
349
+ #
350
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ForwardResult AWS API Documentation
351
+ #
352
+ class ForwardResult < Struct.new(
353
+ :loss_fn_output_type,
354
+ :loss_fn_outputs,
355
+ :metrics,
356
+ :token_usage)
357
+ SENSITIVE = []
358
+ include Aws::Structure
359
+ end
360
+
361
+ # @!attribute [rw] training_session_name
362
+ # The name of the training session that owns the sample operation.
363
+ # @return [String]
364
+ #
365
+ # @!attribute [rw] operation_id
366
+ # The unique identifier of the sample operation to retrieve, returned
367
+ # by `ExecuteSamplingOperation`.
368
+ # @return [String]
369
+ #
370
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/GetSamplingOperationResultInput AWS API Documentation
371
+ #
372
+ class GetSamplingOperationResultInput < Struct.new(
373
+ :training_session_name,
374
+ :operation_id)
375
+ SENSITIVE = []
376
+ include Aws::Structure
377
+ end
378
+
379
+ # @!attribute [rw] status
380
+ # The current status of the sample operation. Possible values are
381
+ # `Pending`, `InProgress`, `Completed`, or `Failed`.
382
+ # @return [String]
383
+ #
384
+ # @!attribute [rw] operation_result
385
+ # The result payload of the sample operation. The service populates
386
+ # this field only when the status is `Completed`.
387
+ # @return [Types::SampleOperationResult]
388
+ #
389
+ # @!attribute [rw] error_details
390
+ # A message describing why the sample operation failed. The service
391
+ # populates this field only when the status is `Failed`.
392
+ # @return [String]
393
+ #
394
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/GetSamplingOperationResultOutput AWS API Documentation
395
+ #
396
+ class GetSamplingOperationResultOutput < Struct.new(
397
+ :status,
398
+ :operation_result,
399
+ :error_details)
400
+ SENSITIVE = []
401
+ include Aws::Structure
402
+ end
403
+
404
+ # @!attribute [rw] training_session_name
405
+ # The name of the training session that owns the operation.
406
+ # @return [String]
407
+ #
408
+ # @!attribute [rw] operation_id
409
+ # The unique identifier of the operation to retrieve, returned by
410
+ # `ExecuteTrainingOperation`.
411
+ # @return [String]
412
+ #
413
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/GetTrainingOperationResultInput AWS API Documentation
414
+ #
415
+ class GetTrainingOperationResultInput < Struct.new(
416
+ :training_session_name,
417
+ :operation_id)
418
+ SENSITIVE = []
419
+ include Aws::Structure
420
+ end
421
+
422
+ # @!attribute [rw] status
423
+ # The current status of the operation. Possible values are `Pending`,
424
+ # `InProgress`, `Completed`, `Failed`, or `Skipped`.
425
+ # @return [String]
426
+ #
427
+ # @!attribute [rw] operation_result
428
+ # The result payload of the operation. The service populates this
429
+ # field only when the status is `Completed`. The populated member of
430
+ # the union corresponds to the operation type that was submitted.
431
+ # @return [Types::OperationResult]
432
+ #
433
+ # @!attribute [rw] error_details
434
+ # A message describing why the operation failed. The service populates
435
+ # this field only when the status is `Failed`.
436
+ # @return [String]
437
+ #
438
+ # @!attribute [rw] token_usage
439
+ # The token usage statistics for metering purposes. The service
440
+ # populates this field for forward and forwardBackward operations upon
441
+ # completion.
442
+ # @return [Types::TrainingTokenUsage]
443
+ #
444
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/GetTrainingOperationResultOutput AWS API Documentation
445
+ #
446
+ class GetTrainingOperationResultOutput < Struct.new(
447
+ :status,
448
+ :operation_result,
449
+ :error_details,
450
+ :token_usage)
451
+ SENSITIVE = []
452
+ include Aws::Structure
453
+ end
454
+
455
+ # An internal service error occurred. Retry the request using
456
+ # exponential backoff.
457
+ #
458
+ # @!attribute [rw] message
459
+ # @return [String]
460
+ #
461
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/InternalServerException AWS API Documentation
462
+ #
463
+ class InternalServerException < Struct.new(
464
+ :message)
465
+ SENSITIVE = []
466
+ include Aws::Structure
467
+ end
468
+
469
+ # The configuration for loading training state from a previously saved
470
+ # checkpoint. This restores model weights and optionally optimizer
471
+ # state.
472
+ #
473
+ # @!attribute [rw] model_package_arn
474
+ # The ARN of the model package containing the checkpoint to load. Must
475
+ # be a valid SageMaker model package ARN in the format
476
+ # `arn:aws:sagemaker:REGION:ACCOUNT:model-package/PACKAGE_NAME/VERSION`.
477
+ # Model package group ARNs are not accepted.
478
+ # @return [String]
479
+ #
480
+ # @!attribute [rw] load_optimizer
481
+ # Specifies whether to also restore the optimizer state alongside
482
+ # model weights. When true, optimizer state is restored to resume
483
+ # training from where it left off.
484
+ # @return [Boolean]
485
+ #
486
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/LoadStateConfig AWS API Documentation
487
+ #
488
+ class LoadStateConfig < Struct.new(
489
+ :model_package_arn,
490
+ :load_optimizer)
491
+ SENSITIVE = []
492
+ include Aws::Structure
493
+ end
494
+
495
+ # The result of loading training state. An empty response indicates
496
+ # success.
497
+ #
498
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/LoadStateResult AWS API Documentation
499
+ #
500
+ class LoadStateResult < Aws::EmptyStructure; end
501
+
502
+ # The configuration for loading model weights for inference and sampling
503
+ # without restoring optimizer state.
504
+ #
505
+ # @!attribute [rw] model_package_arn
506
+ # The ARN of the model package containing the weights to load for
507
+ # sampling. Must be a valid SageMaker model package ARN in the format
508
+ # `arn:aws:sagemaker:REGION:ACCOUNT:model-package/PACKAGE_NAME/VERSION`.
509
+ # The model package must belong to the same AWS account as the
510
+ # training session.
511
+ # @return [String]
512
+ #
513
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/LoadWeightsForSamplingConfig AWS API Documentation
514
+ #
515
+ class LoadWeightsForSamplingConfig < Struct.new(
516
+ :model_package_arn)
517
+ SENSITIVE = []
518
+ include Aws::Structure
519
+ end
520
+
521
+ # The result of loading weights for sampling. An empty response
522
+ # indicates success.
523
+ #
524
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/LoadWeightsForSamplingResult AWS API Documentation
525
+ #
526
+ class LoadWeightsForSamplingResult < Aws::EmptyStructure; end
527
+
528
+ # The tokenized model input composed of ordered encoded text chunks.
529
+ #
530
+ # @!attribute [rw] chunks
531
+ # The ordered list of encoded text chunks forming the input sequence.
532
+ # @return [Array<Types::EncodedTextChunk>]
533
+ #
534
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ModelInput AWS API Documentation
535
+ #
536
+ class ModelInput < Struct.new(
537
+ :chunks)
538
+ SENSITIVE = []
539
+ include Aws::Structure
540
+ end
541
+
542
+ # The configuration for a training operation. Exactly one member must be
543
+ # set to specify the operation type and its parameters.
544
+ #
545
+ # @note OperationConfig is a union - when making an API calls you must set exactly one of the members.
546
+ #
547
+ # @!attribute [rw] forward
548
+ # The configuration for a forward-only pass through the model without
549
+ # gradient computation.
550
+ # @return [Types::ForwardConfig]
551
+ #
552
+ # @!attribute [rw] forward_backward
553
+ # The configuration for a forward and backward pass that computes
554
+ # gradients.
555
+ # @return [Types::ForwardBackwardConfig]
556
+ #
557
+ # @!attribute [rw] optimizer_step
558
+ # The configuration for an optimizer step that updates model weights
559
+ # using accumulated gradients.
560
+ # @return [Types::OptimizerStepConfig]
561
+ #
562
+ # @!attribute [rw] save_weights
563
+ # The configuration for saving model weights as a checkpoint.
564
+ # @return [Types::SaveWeightsConfig]
565
+ #
566
+ # @!attribute [rw] save_state
567
+ # The configuration for saving full training state, including model
568
+ # weights and optimizer state.
569
+ # @return [Types::SaveStateConfig]
570
+ #
571
+ # @!attribute [rw] load_state
572
+ # The configuration for loading training state from a previously saved
573
+ # checkpoint.
574
+ # @return [Types::LoadStateConfig]
575
+ #
576
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/OperationConfig AWS API Documentation
577
+ #
578
+ class OperationConfig < Struct.new(
579
+ :forward,
580
+ :forward_backward,
581
+ :optimizer_step,
582
+ :save_weights,
583
+ :save_state,
584
+ :load_state,
585
+ :unknown)
586
+ SENSITIVE = []
587
+ include Aws::Structure
588
+ include Aws::Structure::Union
589
+
590
+ class Forward < OperationConfig; end
591
+ class ForwardBackward < OperationConfig; end
592
+ class OptimizerStep < OperationConfig; end
593
+ class SaveWeights < OperationConfig; end
594
+ class SaveState < OperationConfig; end
595
+ class LoadState < OperationConfig; end
596
+ class Unknown < OperationConfig; end
597
+ end
598
+
599
+ # The result of a completed training operation. Exactly one member is
600
+ # populated, corresponding to the operation type that was submitted.
601
+ #
602
+ # @note OperationResult is a union - when returned from an API call exactly one value will be set and the returned type will be a subclass of OperationResult corresponding to the set member.
603
+ #
604
+ # @!attribute [rw] forward
605
+ # The result from a forward-only pass.
606
+ # @return [Types::ForwardResult]
607
+ #
608
+ # @!attribute [rw] forward_backward
609
+ # The result from a forward and backward pass.
610
+ # @return [Types::ForwardBackwardResult]
611
+ #
612
+ # @!attribute [rw] optimizer_step
613
+ # The result from an optimizer step.
614
+ # @return [Types::OptimizerStepResult]
615
+ #
616
+ # @!attribute [rw] save_weights
617
+ # The result from saving model weights.
618
+ # @return [Types::SaveWeightsResult]
619
+ #
620
+ # @!attribute [rw] save_state
621
+ # The result from saving full training state.
622
+ # @return [Types::SaveStateResult]
623
+ #
624
+ # @!attribute [rw] load_state
625
+ # The result from loading training state.
626
+ # @return [Types::LoadStateResult]
627
+ #
628
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/OperationResult AWS API Documentation
629
+ #
630
+ class OperationResult < Struct.new(
631
+ :forward,
632
+ :forward_backward,
633
+ :optimizer_step,
634
+ :save_weights,
635
+ :save_state,
636
+ :load_state,
637
+ :unknown)
638
+ SENSITIVE = []
639
+ include Aws::Structure
640
+ include Aws::Structure::Union
641
+
642
+ class Forward < OperationResult; end
643
+ class ForwardBackward < OperationResult; end
644
+ class OptimizerStep < OperationResult; end
645
+ class SaveWeights < OperationResult; end
646
+ class SaveState < OperationResult; end
647
+ class LoadState < OperationResult; end
648
+ class Unknown < OperationResult; end
649
+ end
650
+
651
+ # The configuration for an optimizer step that updates model weights
652
+ # using gradients accumulated from previous forward-backward passes.
653
+ #
654
+ # @!attribute [rw] adam_params_config
655
+ # The Adam optimizer hyperparameters for this step.
656
+ # @return [Types::AdamParamsConfig]
657
+ #
658
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/OptimizerStepConfig AWS API Documentation
659
+ #
660
+ class OptimizerStepConfig < Struct.new(
661
+ :adam_params_config)
662
+ SENSITIVE = []
663
+ include Aws::Structure
664
+ end
665
+
666
+ # The result of an optimizer step.
667
+ #
668
+ # @!attribute [rw] metrics
669
+ # The training metrics emitted by the engine after the optimizer step.
670
+ # @return [Hash<String,Float>]
671
+ #
672
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/OptimizerStepResult AWS API Documentation
673
+ #
674
+ class OptimizerStepResult < Struct.new(
675
+ :metrics)
676
+ SENSITIVE = []
677
+ include Aws::Structure
678
+ end
679
+
680
+ # The specified training session or operation does not exist, or the
681
+ # operation does not belong to the specified training session.
682
+ #
683
+ # @!attribute [rw] message
684
+ # @return [String]
685
+ #
686
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ResourceNotFoundException AWS API Documentation
687
+ #
688
+ class ResourceNotFoundException < Struct.new(
689
+ :message)
690
+ SENSITIVE = []
691
+ include Aws::Structure
692
+ end
693
+
694
+ # The configuration for generating text samples from the model.
695
+ #
696
+ # @!attribute [rw] prompt
697
+ # The input prompt to send to the model for text generation.
698
+ # @return [Types::ModelInput]
699
+ #
700
+ # @!attribute [rw] num_samples
701
+ # The number of independent samples to generate for the prompt.
702
+ # @return [Integer]
703
+ #
704
+ # @!attribute [rw] sampling_params
705
+ # The parameters controlling the sampling strategy.
706
+ # @return [Types::SamplingParams]
707
+ #
708
+ # @!attribute [rw] include_prompt_logprobs
709
+ # Specifies whether to include per-token log-probabilities for the
710
+ # input prompt in the response.
711
+ # @return [Boolean]
712
+ #
713
+ # @!attribute [rw] topk_prompt_logprobs
714
+ # The number of top-k log-probabilities to return per prompt token.
715
+ # @return [Integer]
716
+ #
717
+ # @!attribute [rw] model_package_arn
718
+ # The ARN of the model package whose checkpoint this sample should run
719
+ # against. Must be a valid SageMaker model package ARN in the format
720
+ # `arn:aws:sagemaker:REGION:ACCOUNT:model-package/PACKAGE_NAME/VERSION`.
721
+ # When absent, the sample runs against the session's latest
722
+ # checkpoint.
723
+ # @return [String]
724
+ #
725
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleConfig AWS API Documentation
726
+ #
727
+ class SampleConfig < Struct.new(
728
+ :prompt,
729
+ :num_samples,
730
+ :sampling_params,
731
+ :include_prompt_logprobs,
732
+ :topk_prompt_logprobs,
733
+ :model_package_arn)
734
+ SENSITIVE = [:prompt]
735
+ include Aws::Structure
736
+ end
737
+
738
+ # The configuration for a sampling operation. Exactly one member must be
739
+ # set to specify the operation type.
740
+ #
741
+ # @note SampleOperationConfig is a union - when making an API calls you must set exactly one of the members.
742
+ #
743
+ # @!attribute [rw] sample
744
+ # The configuration for generating text samples from the model.
745
+ # @return [Types::SampleConfig]
746
+ #
747
+ # @!attribute [rw] compute_logprobs
748
+ # The configuration for computing log-probabilities of prompt tokens
749
+ # without generating new text.
750
+ # @return [Types::ComputeLogprobsConfig]
751
+ #
752
+ # @!attribute [rw] load_weights_for_sampling
753
+ # The configuration for loading model weights for inference and
754
+ # sampling without restoring optimizer state.
755
+ # @return [Types::LoadWeightsForSamplingConfig]
756
+ #
757
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleOperationConfig AWS API Documentation
758
+ #
759
+ class SampleOperationConfig < Struct.new(
760
+ :sample,
761
+ :compute_logprobs,
762
+ :load_weights_for_sampling,
763
+ :unknown)
764
+ SENSITIVE = []
765
+ include Aws::Structure
766
+ include Aws::Structure::Union
767
+
768
+ class Sample < SampleOperationConfig; end
769
+ class ComputeLogprobs < SampleOperationConfig; end
770
+ class LoadWeightsForSampling < SampleOperationConfig; end
771
+ class Unknown < SampleOperationConfig; end
772
+ end
773
+
774
+ # The result of a completed sampling operation. Exactly one member is
775
+ # populated, corresponding to the operation type that was submitted.
776
+ #
777
+ # @note SampleOperationResult is a union - when returned from an API call exactly one value will be set and the returned type will be a subclass of SampleOperationResult corresponding to the set member.
778
+ #
779
+ # @!attribute [rw] sample
780
+ # The generated text samples from the model.
781
+ # @return [Types::SampleResponse]
782
+ #
783
+ # @!attribute [rw] compute_logprobs
784
+ # The computed log-probabilities for the prompt tokens.
785
+ # @return [Types::ComputeLogprobsResult]
786
+ #
787
+ # @!attribute [rw] load_weights_for_sampling
788
+ # The result from loading weights for sampling.
789
+ # @return [Types::LoadWeightsForSamplingResult]
790
+ #
791
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleOperationResult AWS API Documentation
792
+ #
793
+ class SampleOperationResult < Struct.new(
794
+ :sample,
795
+ :compute_logprobs,
796
+ :load_weights_for_sampling,
797
+ :unknown)
798
+ SENSITIVE = [:sample]
799
+ include Aws::Structure
800
+ include Aws::Structure::Union
801
+
802
+ class Sample < SampleOperationResult; end
803
+ class ComputeLogprobs < SampleOperationResult; end
804
+ class LoadWeightsForSampling < SampleOperationResult; end
805
+ class Unknown < SampleOperationResult; end
806
+ end
807
+
808
+ # The response containing generated samples and optional
809
+ # log-probabilities.
810
+ #
811
+ # @!attribute [rw] sequences
812
+ # The list of generated sequences.
813
+ # @return [Array<Types::SampledSequence>]
814
+ #
815
+ # @!attribute [rw] prompt_logprobs
816
+ # The per-token log-probabilities for the input prompt. Populated only
817
+ # when `includePromptLogprobs` is true.
818
+ # @return [Array<Float>]
819
+ #
820
+ # @!attribute [rw] topk_prompt_logprobs
821
+ # The top-k log-probabilities per prompt token, as a list of lists.
822
+ # Populated only when `topkPromptLogprobs` is greater than 0.
823
+ # @return [Array<Array<Types::TokenLogprob>>]
824
+ #
825
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleResponse AWS API Documentation
826
+ #
827
+ class SampleResponse < Struct.new(
828
+ :sequences,
829
+ :prompt_logprobs,
830
+ :topk_prompt_logprobs)
831
+ SENSITIVE = []
832
+ include Aws::Structure
833
+ end
834
+
835
+ # The token usage statistics for a sample generation.
836
+ #
837
+ # @!attribute [rw] prefill
838
+ # The number of tokens in the input prompt (prefill phase).
839
+ # @return [Integer]
840
+ #
841
+ # @!attribute [rw] decode
842
+ # The number of tokens generated (decode phase).
843
+ # @return [Integer]
844
+ #
845
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleTokenUsage AWS API Documentation
846
+ #
847
+ class SampleTokenUsage < Struct.new(
848
+ :prefill,
849
+ :decode)
850
+ SENSITIVE = []
851
+ include Aws::Structure
852
+ end
853
+
854
+ # @!attribute [rw] training_session_name
855
+ # The name of the training session whose model to invoke.
856
+ # @return [String]
857
+ #
858
+ # @!attribute [rw] content_type
859
+ # The MIME type of the input data in the request body.
860
+ # @return [String]
861
+ #
862
+ # @!attribute [rw] accept
863
+ # The desired MIME type of the inference body in the response.
864
+ # @return [String]
865
+ #
866
+ # @!attribute [rw] model_package_arn
867
+ # The ARN of the model package whose checkpoint to invoke.
868
+ # @return [String]
869
+ #
870
+ # @!attribute [rw] body
871
+ # The raw inference request body.
872
+ # @return [String]
873
+ #
874
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleTrainingSessionInput AWS API Documentation
875
+ #
876
+ class SampleTrainingSessionInput < Struct.new(
877
+ :training_session_name,
878
+ :content_type,
879
+ :accept,
880
+ :model_package_arn,
881
+ :body)
882
+ SENSITIVE = [:body]
883
+ include Aws::Structure
884
+ end
885
+
886
+ # @!attribute [rw] content_type
887
+ # The MIME type of the inference result in the response body.
888
+ # @return [String]
889
+ #
890
+ # @!attribute [rw] body
891
+ # The raw inference response body from the model.
892
+ # @return [String]
893
+ #
894
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleTrainingSessionOutput AWS API Documentation
895
+ #
896
+ class SampleTrainingSessionOutput < Struct.new(
897
+ :content_type,
898
+ :body)
899
+ SENSITIVE = [:body]
900
+ include Aws::Structure
901
+ end
902
+
903
+ # @!attribute [rw] training_session_name
904
+ # The name of the training session whose model to invoke.
905
+ # @return [String]
906
+ #
907
+ # @!attribute [rw] content_type
908
+ # The MIME type of the input data in the request body.
909
+ # @return [String]
910
+ #
911
+ # @!attribute [rw] accept
912
+ # The desired MIME type of the inference body in the response.
913
+ # @return [String]
914
+ #
915
+ # @!attribute [rw] model_package_arn
916
+ # The ARN of the model package whose checkpoint to invoke.
917
+ # @return [String]
918
+ #
919
+ # @!attribute [rw] body
920
+ # The raw inference request body.
921
+ # @return [String]
922
+ #
923
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleTrainingSessionWithResponseStreamInput AWS API Documentation
924
+ #
925
+ class SampleTrainingSessionWithResponseStreamInput < Struct.new(
926
+ :training_session_name,
927
+ :content_type,
928
+ :accept,
929
+ :model_package_arn,
930
+ :body)
931
+ SENSITIVE = [:body]
932
+ include Aws::Structure
933
+ end
934
+
935
+ # @!attribute [rw] content_type
936
+ # The MIME type of the streaming inference result.
937
+ # @return [String]
938
+ #
939
+ # @!attribute [rw] body
940
+ # The streaming inference response from the model, delivered as a
941
+ # series of chunks.
942
+ # @return [IO]
943
+ #
944
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampleTrainingSessionWithResponseStreamOutput AWS API Documentation
945
+ #
946
+ class SampleTrainingSessionWithResponseStreamOutput < Struct.new(
947
+ :content_type,
948
+ :body)
949
+ SENSITIVE = [:body]
950
+ include Aws::Structure
951
+ end
952
+
953
+ # A single generated sequence from the model.
954
+ #
955
+ # @!attribute [rw] stop_reason
956
+ # The reason why generation stopped. A value of `stop` indicates a
957
+ # stop sequence was encountered. A value of `length` indicates the
958
+ # maximum token limit was reached.
959
+ # @return [String]
960
+ #
961
+ # @!attribute [rw] tokens
962
+ # The token IDs of the generated sequence.
963
+ # @return [Array<Integer>]
964
+ #
965
+ # @!attribute [rw] logprobs
966
+ # The per-token log-probabilities for the generated tokens.
967
+ # @return [Array<Float>]
968
+ #
969
+ # @!attribute [rw] token_usage
970
+ # The token usage statistics for this individual sample.
971
+ # @return [Types::SampleTokenUsage]
972
+ #
973
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SampledSequence AWS API Documentation
974
+ #
975
+ class SampledSequence < Struct.new(
976
+ :stop_reason,
977
+ :tokens,
978
+ :logprobs,
979
+ :token_usage)
980
+ SENSITIVE = []
981
+ include Aws::Structure
982
+ end
983
+
984
+ # The parameters controlling the text generation sampling strategy.
985
+ #
986
+ # @!attribute [rw] max_tokens
987
+ # The maximum number of tokens to generate per sample.
988
+ # @return [Integer]
989
+ #
990
+ # @!attribute [rw] temperature
991
+ # The sampling temperature controlling randomness. Higher values
992
+ # produce more diverse outputs.
993
+ # @return [Float]
994
+ #
995
+ # @!attribute [rw] top_k
996
+ # The number of highest-probability vocabulary tokens to keep for
997
+ # top-k filtering. Set to -1 to disable.
998
+ # @return [Integer]
999
+ #
1000
+ # @!attribute [rw] top_p
1001
+ # The cumulative probability threshold for nucleus (top-p) sampling.
1002
+ # Only tokens with cumulative probability below this threshold are
1003
+ # considered.
1004
+ # @return [Float]
1005
+ #
1006
+ # @!attribute [rw] seed
1007
+ # The random seed for reproducible sampling. When set, the same seed
1008
+ # with the same input produces deterministic outputs.
1009
+ # @return [Integer]
1010
+ #
1011
+ # @!attribute [rw] stop
1012
+ # The list of stop sequences that terminate generation when
1013
+ # encountered in the output.
1014
+ # @return [Array<String>]
1015
+ #
1016
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SamplingParams AWS API Documentation
1017
+ #
1018
+ class SamplingParams < Struct.new(
1019
+ :max_tokens,
1020
+ :temperature,
1021
+ :top_k,
1022
+ :top_p,
1023
+ :seed,
1024
+ :stop)
1025
+ SENSITIVE = []
1026
+ include Aws::Structure
1027
+ end
1028
+
1029
+ # The configuration for saving full training state, including model
1030
+ # weights and optimizer state. Use this to create resumable checkpoints.
1031
+ #
1032
+ # @!attribute [rw] description
1033
+ # A human-readable description for the saved state checkpoint.
1034
+ # @return [String]
1035
+ #
1036
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SaveStateConfig AWS API Documentation
1037
+ #
1038
+ class SaveStateConfig < Struct.new(
1039
+ :description)
1040
+ SENSITIVE = []
1041
+ include Aws::Structure
1042
+ end
1043
+
1044
+ # The result of saving full training state.
1045
+ #
1046
+ # @!attribute [rw] model_package_arn
1047
+ # The ARN of the model package created for the saved state checkpoint.
1048
+ # @return [String]
1049
+ #
1050
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SaveStateResult AWS API Documentation
1051
+ #
1052
+ class SaveStateResult < Struct.new(
1053
+ :model_package_arn)
1054
+ SENSITIVE = []
1055
+ include Aws::Structure
1056
+ end
1057
+
1058
+ # The configuration for saving model weights as a checkpoint.
1059
+ #
1060
+ # @!attribute [rw] merge_weights
1061
+ # Specifies whether to merge LoRA adapter weights into the base model
1062
+ # before saving. When true, the saved checkpoint contains the full
1063
+ # merged model weights.
1064
+ # @return [Boolean]
1065
+ #
1066
+ # @!attribute [rw] description
1067
+ # A human-readable description for the saved checkpoint.
1068
+ # @return [String]
1069
+ #
1070
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SaveWeightsConfig AWS API Documentation
1071
+ #
1072
+ class SaveWeightsConfig < Struct.new(
1073
+ :merge_weights,
1074
+ :description)
1075
+ SENSITIVE = []
1076
+ include Aws::Structure
1077
+ end
1078
+
1079
+ # The result of saving model weights.
1080
+ #
1081
+ # @!attribute [rw] model_package_arn
1082
+ # The ARN of the model package created for the saved weights.
1083
+ # @return [String]
1084
+ #
1085
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/SaveWeightsResult AWS API Documentation
1086
+ #
1087
+ class SaveWeightsResult < Struct.new(
1088
+ :model_package_arn)
1089
+ SENSITIVE = []
1090
+ include Aws::Structure
1091
+ end
1092
+
1093
+ # A tensor with data, data type, and shape metadata.
1094
+ #
1095
+ # @!attribute [rw] data
1096
+ # The raw tensor data as JSON. The format is determined by the `dtype`
1097
+ # field: integer arrays for `int64`, floating-point arrays for
1098
+ # `float32`.
1099
+ # @return [Hash,Array,String,Numeric,Boolean]
1100
+ #
1101
+ # @!attribute [rw] dtype
1102
+ # The data type of the tensor elements, such as `int64` or `float32`.
1103
+ # @return [String]
1104
+ #
1105
+ # @!attribute [rw] shape
1106
+ # The dimensions of the tensor, such as \[batch\_size, seq\_length\].
1107
+ # @return [Array<Integer>]
1108
+ #
1109
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/TensorData AWS API Documentation
1110
+ #
1111
+ class TensorData < Struct.new(
1112
+ :data,
1113
+ :dtype,
1114
+ :shape)
1115
+ SENSITIVE = []
1116
+ include Aws::Structure
1117
+ end
1118
+
1119
+ # The request was throttled. Retry the request after a brief wait using
1120
+ # exponential backoff.
1121
+ #
1122
+ # @!attribute [rw] message
1123
+ # @return [String]
1124
+ #
1125
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ThrottlingException AWS API Documentation
1126
+ #
1127
+ class ThrottlingException < Struct.new(
1128
+ :message)
1129
+ SENSITIVE = []
1130
+ include Aws::Structure
1131
+ end
1132
+
1133
+ # The log-probability for a single token.
1134
+ #
1135
+ # @!attribute [rw] token_id
1136
+ # The vocabulary token ID.
1137
+ # @return [Integer]
1138
+ #
1139
+ # @!attribute [rw] logprob
1140
+ # The log-probability of the token.
1141
+ # @return [Float]
1142
+ #
1143
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/TokenLogprob AWS API Documentation
1144
+ #
1145
+ class TokenLogprob < Struct.new(
1146
+ :token_id,
1147
+ :logprob)
1148
+ SENSITIVE = []
1149
+ include Aws::Structure
1150
+ end
1151
+
1152
+ # The token usage statistics for training operations.
1153
+ #
1154
+ # @!attribute [rw] training_tokens
1155
+ # The number of training tokens consumed by the operation.
1156
+ # @return [Integer]
1157
+ #
1158
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/TrainingTokenUsage AWS API Documentation
1159
+ #
1160
+ class TrainingTokenUsage < Struct.new(
1161
+ :training_tokens)
1162
+ SENSITIVE = []
1163
+ include Aws::Structure
1164
+ end
1165
+
1166
+ # The request is not valid. Check the request syntax and parameters.
1167
+ # Examples include invalid sequence numbers, malformed client tokens,
1168
+ # missing required fields, or invalid operation configuration.
1169
+ #
1170
+ # @!attribute [rw] message
1171
+ # @return [String]
1172
+ #
1173
+ # @see http://docs.aws.amazon.com/goto/WebAPI/sagemakertrainingsessionruntime-2025-02-10/ValidationException AWS API Documentation
1174
+ #
1175
+ class ValidationException < Struct.new(
1176
+ :message)
1177
+ SENSITIVE = []
1178
+ include Aws::Structure
1179
+ end
1180
+
1181
+ end
1182
+ end
1183
+