# Inference with a trained model

**URL:** <https://discuss.ray.io/t/inference-with-a-trained-model/23456>\
**Category:** RLlib\
**Created:** [January 16, 2026, 5:49pm UTC](https://discuss.ray.io/t/inference-with-a-trained-model/23456 "2026-01-16T17:49:40Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![RunLLM](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/runllm/32/8249_2.png) [@RunLLM](https://discuss.ray.io/u/RunLLM)\
**Post date:** [January 16, 2026, 5:50pm UTC](https://discuss.ray.io/t/inference-with-a-trained-model/23456/2 "2026-01-16T17:50:14Z")

</div>

To use your trained RLlib model for inference, you should load the RLModule from the checkpoint and preprocess observations exactly as during training, including any connector logic (e.g., normalization, concatenation). If you skip the connector pipeline or preprocess differently, inference results may be inconsistent or suboptimal. RLlib recommends using the `EnvToModulePipeline` and `ModuleToEnvPipeline` from the checkpoint for preprocessing and postprocessing, especially if you used custom connectors or filters during training. Directly calling `.forward_inference()` on the module with manually preprocessed observations can lead to mismatches and random behavior, as you observed.

For correct inference, load the connector pipelines from the checkpoint and use them to process observations and actions, ensuring consistency with training. See the official [policy\_inference\_after\_training\_w\_connector.py example](https://github.com/ray-project/ray/blob/master/rllib/examples/inference/policy_inference_after_training_w_connector.py) for a full workflow. If you only use `.forward_inference()` directly, make sure your preprocessing exactly matches what the connector did during training, or else use the connector pipeline itself.

Would you like a step-by-step code example for this process?

Sources:

- [policy\_inference\_after\_training\_w\_connector.py](https://github.com/ray-project/ray/blob/master/rllib/examples/inference/policy_inference_after_training_w_connector.py)
- [policy\_inference\_after\_training.py](https://github.com/ray-project/ray/blob/master/rllib/examples/inference/policy_inference_after_training.py)
- [Ray RLlib inference discussion](https://discuss.ray.io/t/how-can-i-deploy-my-reinforcement-learning-model-trained-with-tune-using-the-new-api/23081)
- [Ray RLlib inference GitHub issue](https://github.com/ray-project/ray/issues/44475)

Hint: Mention @RunLLM in the post for followups.

---

_[View the full topic](https://discuss.ray.io/t/inference-with-a-trained-model/23456)._
