This reference describes unreleased code on main; no release documents it yet.

rlmesh::Policy

traitPreviewuse rlmesh::Policy;[source]

A model's declarations, predict operations and lifecycle hooks. Write the corners the model has and list them in CORNERS; a corner that reads the per-episode context is listed in CONTEXT too and written as its <corner>_with_context twin. Build the model with Model::new or Model::from_config.

trait Policy: Send + 'static

Rust cannot see which methods an impl wrote, so the consts are the declaration: a corner listed but not written fails its first call with the RuntimeError class naming the entry, and a corner written but not listed is never called.

CORNERS

associated constant[source]
const CORNERS: Corners

The corners this policy implements.

CONTEXT

associated constant[source]
const CONTEXT: Corners

The corners that read the context; each is called through its _with_context twin. Must be a subset of CORNERS.

NATIVE_CHUNK

associated constant[source]
const NATIVE_CHUNK: Option<u32>

The static native chunk length K (describe reads this one).

LOAD_KEYS

associated constant[source]
const LOAD_KEYS: Option<&'static [LoadKey]>

The parameter keys load accepts; None forwards every key.

spec

provided method[source]
fn spec() -> Option<SpecArg> where Self: Sized

The model’s adapter spec.

workflow_edition

provided method[source]
fn workflow_edition() -> Option<String> where Self: Sized

The workflow edition the policy was authored against.

load

provided method[source]
fn load(&mut self, kwargs: &Kwargs) -> Result<()>

Load weights from config, once, in the constructor. The default accepts only an empty config.

allow_fusion

provided method[source]
fn allow_fusion(&self) -> bool

Whether a grouped predict may fuse lanes from different envs into one batched-corner call; read once, after load.

native_chunk

provided method[source]
fn native_chunk(&self) -> Option<u32>

The native chunk length K after load (a checkpoint may decide it); read once, after load.

predict

provided method[source]
fn predict(&mut self, observation: Value) -> Result<Value>

One observation to one action.

predict_with_context

provided method[source]
fn predict_with_context(
    &mut self,
    observation: Value,
    context: &mut PredictContext<'_>,
) -> Result<Value>

predict reading the context.

predict_batch

provided method[source]
fn predict_batch(
    &mut self,
    observations: Vec<Value>,
) -> Result<Vec<Value>>

One action per observation, in one call.

predict_batch_with_context

provided method[source]
fn predict_batch_with_context(
    &mut self,
    observations: Vec<Value>,
    context: &mut BatchPredictContext<'_>,
) -> Result<Vec<Value>>

predict_batch reading one context per row.

predict_chunk

provided method[source]
fn predict_chunk(
    &mut self,
    observation: Value,
    execution_horizon: u32,
) -> Result<Value>

One observation to a chunk of actions (leading axis = frames).

predict_chunk_with_context

provided method[source]
fn predict_chunk_with_context(
    &mut self,
    observation: Value,
    execution_horizon: u32,
    context: &mut PredictContext<'_>,
) -> Result<Value>

predict_chunk reading the context.

predict_chunk_batch

provided method[source]
fn predict_chunk_batch(
    &mut self,
    observations: Vec<Value>,
    execution_horizon: u32,
) -> Result<Vec<Value>>

One chunk per observation, in one call.

predict_chunk_batch_with_context

provided method[source]
fn predict_chunk_batch_with_context(
    &mut self,
    observations: Vec<Value>,
    execution_horizon: u32,
    context: &mut BatchPredictContext<'_>,
) -> Result<Vec<Value>>

predict_chunk_batch reading one context per row.

on_episode_end

provided method[source]
fn on_episode_end(&mut self, episode_id: &str) -> Result<()>

An episode ended (after its context entry is dropped).

close

provided method[source]
fn close(&mut self) -> Result<()>

Release the model’s resources: runs at most once.