R L

Forward-backward pass

POST
/rl/training-sessions/{session_id}/operations/forward-backward

Submits a forward-backward pass operation that will asynchronously compute gradients via backpropagation.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

session_id*string

Training session ID

Header Parameters

Idempotency-Key*string

Required key that makes retries return the original operation; use a new key for changed request bodies.

Request Body

application/json

samples*array<>

Batch of training samples to process

loss*

Loss function configuration

return_loss_fn_outputs?boolean

Return the loss function's per-sample output tensors alongside the loss and metrics. Defaults to false. Enabling it increases the response size substantially for large batches and reduces step throughput, so leave it unset for ordinary training steps.

forward_only?boolean

Run the forward pass only: report the loss and metrics, and the per-sample outputs when requested, without accumulating gradients. Defaults to false. Pair it with return_loss_fn_outputs to score a batch and read back its per-token log-probabilities.

Response Body

application/json

application/json

curl -X POST "https://example.com/rl/training-sessions/string/operations/forward-backward" \  -H "Idempotency-Key: string" \  -H "Content-Type: application/json" \  -d '{    "samples": [      {        "model_input": {          "chunks": [            {              "encoded_text": {                "tokens": [                  "string"                ]              }            }          ]        },        "loss_fn_inputs": {          "property1": {            "data": [              0.1            ],            "dtype": "int64"          },          "property2": {            "data": [              0.1            ],            "dtype": "int64"          }        }      }    ],    "loss": {      "type": "LOSS_TYPE_UNSPECIFIED"    }  }'
{  "id": "string",  "status": "TRAINING_OPERATION_STATUS_UNSPECIFIED",  "output": {    "loss": 0,    "metrics": {      "property1": 0,      "property2": 0    },    "loss_fn_outputs": [      {        "tensors": {          "property1": {            "data": [              0.1            ],            "dtype": "int64",            "shape": [              0            ],            "sparse_crow_indices": [              0            ],            "sparse_col_indices": [              0            ]          },          "property2": {            "data": [              0.1            ],            "dtype": "int64",            "shape": [              0            ],            "sparse_crow_indices": [              0            ],            "sparse_col_indices": [              0            ]          }        }      }    ]  },  "error": {    "code": "TRAINING_OPERATION_ERROR_CODE_UNSPECIFIED",    "message": "string"  }}