Skip to content

/AWS1/IF_SGI=>EXECUTETRAININGOPERATION()

About 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.

Method Signature

METHODS /AWS1/IF_SGI~EXECUTETRAININGOPERATION
  IMPORTING
    !IV_TRAININGSESSIONNAME TYPE /AWS1/SGITRAININGSESSIONNAME OPTIONAL
    !IV_SEQUENCENUMBER TYPE /AWS1/SGISEQUENCENUMBER OPTIONAL
    !IV_CLIENTTOKEN TYPE /AWS1/SGICLIENTTOKEN OPTIONAL
    !IO_OPERATIONCONFIG TYPE REF TO /AWS1/CL_SGIOPERATIONCONFIG OPTIONAL
  RETURNING
    VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sgiexecutetrnopoutput
  RAISING
    /AWS1/CX_SGICONFLICTEXCEPTION
    /AWS1/CX_SGIINTERNALSERVEREX
    /AWS1/CX_SGIRESOURCENOTFOUNDEX
    /AWS1/CX_SGITHROTTLINGEX
    /AWS1/CX_SGIVLDTNEXCEPTION
    /AWS1/CX_SGICLIENTEXC
    /AWS1/CX_SGISERVEREXC
    /AWS1/CX_RT_TECHNICAL_GENERIC
    /AWS1/CX_RT_SERVICE_GENERIC.

IMPORTING

Required arguments:

iv_trainingsessionname TYPE /AWS1/SGITRAININGSESSIONNAME /AWS1/SGITRAININGSESSIONNAME

The name of the training session to submit the operation to.

iv_sequencenumber TYPE /AWS1/SGISEQUENCENUMBER /AWS1/SGISEQUENCENUMBER

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.

io_operationconfig TYPE REF TO /AWS1/CL_SGIOPERATIONCONFIG /AWS1/CL_SGIOPERATIONCONFIG

The configuration that specifies the type and parameters of the training operation. Exactly one member of the union must be set.

Optional arguments:

iv_clienttoken TYPE /AWS1/SGICLIENTTOKEN /AWS1/SGICLIENTTOKEN

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.

RETURNING

oo_output TYPE REF TO /aws1/cl_sgiexecutetrnopoutput /AWS1/CL_SGIEXECUTETRNOPOUTPUT

Examples

Syntax Example

This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.

DATA(lo_result) = lo_client->executetrainingoperation(
  io_operationconfig = new /aws1/cl_sgioperationconfig(
    io_forward = new /aws1/cl_sgiforwardconfig(
      io_lossfnconfig = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
      it_datumlist = VALUE /aws1/cl_sgidatum=>tt_datumlist(
        (
          new /aws1/cl_sgidatum(
            io_modelinput = new /aws1/cl_sgimodelinput(
              it_chunks = VALUE /aws1/cl_sgiencodedtextchunk=>tt_encodedtextchunklist(
                (
                  new /aws1/cl_sgiencodedtextchunk(
                    it_tokens = VALUE /aws1/cl_sgiintegerlist_w=>tt_integerlist(
                      ( new /aws1/cl_sgiintegerlist_w( 123 ) )
                    )
                    iv_type = |string|
                  )
                )
              )
            )
            it_lossfninputs = VALUE /aws1/cl_sgitensordata=>tt_tensordatamap(
              (
                VALUE /aws1/cl_sgitensordata=>ts_tensordatamap_maprow(
                  key = |string|
                  value = new /aws1/cl_sgitensordata(
                    io_data = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
                    it_shape = VALUE /aws1/cl_sgiintegerlist_w=>tt_integerlist(
                      ( new /aws1/cl_sgiintegerlist_w( 123 ) )
                    )
                    iv_dtype = |string|
                  )
                )
              )
            )
          )
        )
      )
      iv_lossfnname = |string|
    )
    io_forwardbackward = new /aws1/cl_sgiforwardbackwardcfg(
      io_lossfnconfig = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
      it_datumlist = VALUE /aws1/cl_sgidatum=>tt_datumlist(
        (
          new /aws1/cl_sgidatum(
            io_modelinput = new /aws1/cl_sgimodelinput(
              it_chunks = VALUE /aws1/cl_sgiencodedtextchunk=>tt_encodedtextchunklist(
                (
                  new /aws1/cl_sgiencodedtextchunk(
                    it_tokens = VALUE /aws1/cl_sgiintegerlist_w=>tt_integerlist(
                      ( new /aws1/cl_sgiintegerlist_w( 123 ) )
                    )
                    iv_type = |string|
                  )
                )
              )
            )
            it_lossfninputs = VALUE /aws1/cl_sgitensordata=>tt_tensordatamap(
              (
                VALUE /aws1/cl_sgitensordata=>ts_tensordatamap_maprow(
                  key = |string|
                  value = new /aws1/cl_sgitensordata(
                    io_data = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
                    it_shape = VALUE /aws1/cl_sgiintegerlist_w=>tt_integerlist(
                      ( new /aws1/cl_sgiintegerlist_w( 123 ) )
                    )
                    iv_dtype = |string|
                  )
                )
              )
            )
          )
        )
      )
      iv_lossfnname = |string|
    )
    io_loadstate = new /aws1/cl_sgiloadstateconfig(
      iv_loadoptimizer = ABAP_TRUE
      iv_modelpackagearn = |string|
    )
    io_optimizerstep = new /aws1/cl_sgioptstepconfig(
      io_adamparamsconfig = new /aws1/cl_sgiadamparamsconfig(
        iv_beta1 = '0.1'
        iv_beta2 = '0.1'
        iv_eps = '0.1'
        iv_gradclipnorm = '0.1'
        iv_learningrate = '0.1'
        iv_lorapluslrratio = '0.1'
        iv_weightdecay = '0.1'
      )
    )
    io_savestate = new /aws1/cl_sgisavestateconfig( |string| )
    io_saveweights = new /aws1/cl_sgisaveweightsconfig(
      iv_description = |string|
      iv_mergeweights = ABAP_TRUE
    )
  )
  iv_clienttoken = |string|
  iv_sequencenumber = 123
  iv_trainingsessionname = |string|
).

This is an example of reading all possible response values

lo_result = lo_result.
IF lo_result IS NOT INITIAL.
  lv_operationid = lo_result->get_operationid( ).
ENDIF.

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.

DATA(lo_result) = lo_client->executetrainingoperation(
  io_operationconfig = new /aws1/cl_sgioperationconfig(
    io_forwardbackward = new /aws1/cl_sgiforwardbackwardcfg(
      it_datumlist = VALUE /aws1/cl_sgidatum=>tt_datumlist(
        (
          new /aws1/cl_sgidatum(
            io_modelinput = new /aws1/cl_sgimodelinput(
              it_chunks = VALUE /aws1/cl_sgiencodedtextchunk=>tt_encodedtextchunklist(
                (
                  new /aws1/cl_sgiencodedtextchunk(
                    it_tokens = VALUE /aws1/cl_sgiintegerlist_w=>tt_integerlist(
                      ( new /aws1/cl_sgiintegerlist_w( 791 ) )
                      ( new /aws1/cl_sgiintegerlist_w( 6864 ) )
                      ( new /aws1/cl_sgiintegerlist_w( 315 ) )
                      ( new /aws1/cl_sgiintegerlist_w( 9822 ) )
                      ( new /aws1/cl_sgiintegerlist_w( 374 ) )
                      ( new /aws1/cl_sgiintegerlist_w( 12366 ) )
                    )
                    iv_type = |encoded_text|
                  )
                )
              )
            )
          )
        )
      )
      iv_lossfnname = |cross_entropy|
    )
  )
  iv_sequencenumber = 1
  iv_trainingsessionname = |my-training-session|
).