nemo_rl.models.generation.trtllm.trtllm_worker_async#

Ray actor wrapping tensorrt_llm._torch.async_llm.AsyncLLM.

The sole TRT-LLM generation worker (the synchronous engine path was removed; see :class:TrtllmGeneration, which asserts trtllm_cfg.async_engine=true). Every method that calls into AsyncLLM is exposed as async def with the _async suffix, so Ray’s actor runtime runs them on the actor’s own asyncio loop; process-lifecycle / helper methods (e.g. shutdown, configure_worker) stay sync.

Weight updates flow through NcclExtension inside TRT-LLM’s internal RayGPUWorker, invoked via llm.collective_rpc().

Module Contents#

Classes#

TrtllmAsyncGenerationWorkerImpl

Plain (non-actor) implementation of the async TRT-LLM generation worker.

TrtllmAsyncGenerationWorker

Ray actor wrapper around :class:TrtllmAsyncGenerationWorkerImpl.

Functions#

_tag_nsys_output

Append tag to the filename in an nsys -o spec.

API#

nemo_rl.models.generation.trtllm.trtllm_worker_async._tag_nsys_output(output_spec: str, tag: str) → str#

Append tag to the filename in an nsys -o spec.

Operates on the filename rather than substituting a known worker name, because the spec may be the built-in default or anything the user put in NRL_NSYS_EXTRA_OPTIONS – including a directory, which must be left where it is so the reports still land where the user asked. The value arrives quoted from get_nsight_config_if_pattern_matches; a user-supplied one may not be, so the quoting is preserved either way.

Appended rather than prefixed so the documented report names stay prefix-matchable: trtllm_async_generation_worker_* keeps finding every report (docs/nsys-profiling.md), disaggregated or not.

class nemo_rl.models.generation.trtllm.trtllm_worker_async.TrtllmAsyncGenerationWorkerImpl(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
bundle_indices: Optional[list[int]] = None,
bundle_pg_idx: Optional[int] = None,
fraction_of_gpus: float = 1.0,
seed: Optional[int] = None,
)#

Plain (non-actor) implementation of the async TRT-LLM generation worker.

Held separately from the @ray.remote-wrapped

Class:

TrtllmAsyncGenerationWorker so it can be exercised without Ray.

Initialization

static configure_worker(
num_gpus: int | float,
bundle_indices: Optional[tuple[int, list[int]]] = None,
num_gpus_per_node: Optional[int] = None,
) → tuple[dict[str, Any], dict[str, str], dict[str, Any], dict[str, Any]]#
__repr__() → str#
_engine_role() → dict[str, Any]#

This engine’s entry in the driver-built _engine_roles map.

Keyed by (placement group index, local bundle indices) – the same tuple TrtllmGeneration used to create this worker, so the two sides agree without per-worker init kwargs. Returns {} for uniform runs, which carry no map at all.

is_alive() → bool#
async post_init_async() → None#

Finish async engine setup on the Ray actor’s asyncio loop and (optionally) start HTTP server.

shutdown() → bool#
start_http_server(port: int = 0) → str#

Start an OpenAI-compatible HTTP server backed by self.llm.

stop_http_server() → None#
async report_dp_openai_server_base_url() → Optional[str]#
async report_http_addr() → Optional[dict[str, Any]]#

This engine’s {host, port, node_id}.

Under disaggregation an address is the only thing the replica’s disagg server is given about an engine, so host/port is what feeds its context and generation pools. The node id lets the driver put that server’s actor beside its engines.

async init_collective_async(
rank_prefix: int,
ip: str,
port: int,
world_size: int,
train_world_size: int,
) → None#
async prepare_refit_info_async(
state_dict_info: dict[str, Any],
) → None#
async update_weights_from_collective_async(
*,
drain: bool = True,
recompute_kv: bool = False,
) → bool#

Async version of update_weights_from_collective.

Parameters:
  • drain – If False, run the refit at a scheduler step boundary without draining in-flight requests (in-flight weight update). Default True preserves the original drain-first behavior.

  • recompute_kv – If True, re-prefill in-flight requests under the new weights and reset the prefix cache after the refit (recompute_kv_cache_after_weight_updates). If False, in-flight requests keep their current KV cache.

async update_weights_via_ipc_zmq_async() → bool#
async init_nccl_reshard_comm_group_async(
rank_prefix: int,
pp_ips: list[str],
pp_ports: list[int],
pp_size: int,
train_ranks_per_stage: int,
sub_world_size: int,
) → None#
async prepare_nccl_reshard_refit_info_async(refit_info: dict) → None#
async nccl_reshard_refit_async(
refit_timeout_s: Optional[float] = None,
*,
drain: bool = True,
recompute_kv: bool = False,
) → bool#

Receive one refit shard-to-shard on every GPU worker of this engine.

async report_device_id_async() → list[str]#
classmethod _weights_tags() → list[str]#
classmethod _all_sleep_tags() → list[str]#
_resolve_wake_tags(tags: Optional[list[str]]) → list[str]#
async sleep_async(**kwargs: Any) → bool#
async wake_up_async(**kwargs: Any) → bool#
async reset_prefix_cache_async(**kwargs: Any) → bool#
async start_gpu_profiling_async() → None#
async stop_gpu_profiling_async() → None#
async generate_async(
data: nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.generation.interfaces.GenerationDatumSpec],
greedy: bool = False,
) → nemo_rl.distributed.batched_data_dict.BatchedDataDict[nemo_rl.models.generation.interfaces.GenerationOutputSpec]#
_build_sampling_params(*, greedy: bool)#
class nemo_rl.models.generation.trtllm.trtllm_worker_async.TrtllmAsyncGenerationWorker(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
bundle_indices: Optional[list[int]] = None,
bundle_pg_idx: Optional[int] = None,
fraction_of_gpus: float = 1.0,
seed: Optional[int] = None,
)#

Bases: nemo_rl.models.generation.trtllm.trtllm_worker_async.TrtllmAsyncGenerationWorkerImpl

Ray actor wrapper around :class:TrtllmAsyncGenerationWorkerImpl.

Initialization