trinity.explorer package#

Subpackages#

Submodules#

Module contents#

class trinity.explorer.Explorer(config: Config)[source]#

Bases: object

Responsible for exploring the taskset.

__init__(config: Config)[source]#
async benchmark() bool[source]#

Benchmark the model checkpoints.

async eval()[source]#

Evaluation on all evaluation data samples.

async explore() str[source]#
The timeline of the exploration process:
<β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€” one period β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-> |
explorer | <β€”β€”β€”β€”β€”- step_1 ————–> | |
| <β€”β€”β€”β€”β€”- step_2 ————–> | |
… |
| <β€”β€”β€”β€”β€”- step_n β€”β€”β€”β€”β€”> | |
| <β€”β€”β€”β€”β€”β€”β€”- eval ——————–> | <– sync –> |

|--------------------------------------------------------------------------------------|

trainer | <– idle –> | <– step_1 –> | <– step_2 –> | … | <– step_n –> | <– sync –> |

async explore_step() bool[source]#
classmethod get_actor(config: Config)[source]#

Get a Ray actor for the explorer.

async get_weight(name: str) Tensor[source]#

Get the weight of the loaded model (For checkpoint weights update).

async is_alive() bool[source]#

Check if the explorer is alive.

need_eval() bool[source]#
async need_sync() bool[source]#
async prepare() None[source]#

Preparation before running.

async save_checkpoint(sync_weight: bool = False) None[source]#
async serve() None[source]#

Run the explorer in serving mode.

In serving mode, the explorer starts an OpenAI compatible server to handle requests. Agent applications can be deployed separately and interact with the explorer via the API.

import openai


client = openai.OpenAI(
    base_url=f"{explorer_server_url}/v1",
    api_key="EMPTY",
)
response = client.chat.completions.create(
    model=config.model.model_path,
    messages=[{"role": "user", "content": "Hello!"}]
)
async setup_model_level_weight_sync_group()[source]#

Setup process group for each model, only used in serve mode.

async setup_weight_sync_group(master_address: str, master_port: int, state_dict_meta: List = None)[source]#
async shutdown() None[source]#
async sync_weight() None[source]#

Synchronize model weights.