executeTrainingOperation

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.

Samples

// 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.
val resp = sageMakerTrainingSessionRuntimeClient.executeTrainingOperation {
    trainingSessionName = "my-training-session"
    sequenceNumber = 1
    operationConfig = OperationConfig.ForwardBackward(ForwardBackwardConfig {
        lossFnName = LossFnName.fromValue("cross_entropy")
        datumList = listOf<Datum>(
            Datum {
                modelInput = ModelInput {
                    chunks = listOf<EncodedTextChunk>(
                        EncodedTextChunk {
                            tokens = listOf<Int>(
                                791,
                                6864,
                                315,
                                9822,
                                374,
                                12366
                            )
                            type = EncodedTextChunkType.fromValue("encoded_text")
                        }                            
                    )
                }
            }                
        )
    }
    )
}