nemo_rl.models.generation.trtllm.config#

Module Contents#

Classes#

TrtllmDisaggServerConfig

The DisaggServerConfig fields NeMo RL forwards to TRT-LLM.

TrtllmEngineKnobs

The settings a replica’s prefill and decode engines may disagree on.

TrtllmEngineArgs

One role’s engine overrides: trtllm_cfg.{prefill,decode}_engine.

TrtllmSpecificArgs

trtllm_cfg: the per-engine knobs plus what every engine shares.

TrtllmConfig

Functions#

_as_dict

resolve_disagg_layout

generation.disaggregation as its schema.

_deep_merge

update over base, nested dicts merged key by key; inputs untouched.

resolve_role_overrides

Resolve trtllm_cfg.{prefill,decode}_engine into complete engine configs.

role_engine_config

The whole engine config of role. config must be role-resolved.

role_tensor_parallel_size

TP of one engine of role. config must be role-resolved.

replica_width

GPUs one rollout replica spans.

resolve_disagg_server_config

trtllm_cfg.disagg_server as its schema.

API#

class nemo_rl.models.generation.trtllm.config.TrtllmDisaggServerConfig#

Bases: pydantic.BaseModel

The DisaggServerConfig fields NeMo RL forwards to TRT-LLM.

extra="forbid": build_config forwards only the fields declared here, so any other DisaggServerConfig key (max_retries, …) would pass validation and then silently do nothing.

Not a :class:DisaggConfig subclass: the layout is a different thing, and inheriting would let this block declare layout keys nothing here reads. The ctx/gen spelling is TRT-LLM’s; everything NeMo RL owns reads prefill/decode.

ctx_router: Literal[conversation, kv_cache_aware]#

‘conversation’

gen_router: Literal[round_robin, load_balancing]#

‘load_balancing’

gen_tokids_ctxbytes: bool#

False

gen_strip_message_history: bool#

False

class nemo_rl.models.generation.trtllm.config.TrtllmEngineKnobs#

Bases: typing.TypedDict

The settings a replica’s prefill and decode engines may disagree on.

Deliberately narrow: everything else in trtllm_cfg describes the model or the engine’s contract with the rest of the system, and two engines of one replica differing on those would not serve one coherent policy. All optional – a role block names only what differs, and the shared block’s required keys fail loudly on their subscript read, not here.

Initialization

Initialize self. See help(type(self)) for accurate signature.

tensor_parallel_size: int#

None

gpu_memory_utilization: float#

None

max_batch_size: int#

None

max_num_tokens: int#

None

moe_tensor_parallel_size: int#

None

moe_expert_parallel_size: int#

None

class nemo_rl.models.generation.trtllm.config.TrtllmEngineArgs#

Bases: nemo_rl.models.generation.trtllm.config.TrtllmEngineKnobs

One role’s engine overrides: trtllm_cfg.{prefill,decode}_engine.

Initialization

Initialize self. See help(type(self)) for accurate signature.

trtllm_kwargs: NotRequired[dict[str, Any]]#

None

class nemo_rl.models.generation.trtllm.config.TrtllmSpecificArgs#

Bases: nemo_rl.models.generation.trtllm.config.TrtllmEngineKnobs

trtllm_cfg: the per-engine knobs plus what every engine shares.

Initialization

Initialize self. See help(type(self)) for accurate signature.

model_name: NotRequired[str]#

None

max_model_len: int#

None

precision: str#

None

load_format: NotRequired[str]#

None

is_mx: NotRequired[bool]#

None

expose_http_server: NotRequired[bool]#

None

async_engine: NotRequired[bool]#

None

in_flight_weight_updates: NotRequired[bool]#

None

recompute_kv_cache_after_weight_updates: NotRequired[bool]#

None

default_chat_template_kwargs: NotRequired[dict[str, Any]]#

None

chat_template: NotRequired[str]#

None

tool_parser: NotRequired[str]#

None

reasoning_parser: NotRequired[str]#

None

prefill_engine: NotRequired[nemo_rl.models.generation.trtllm.config.TrtllmEngineArgs]#

None

decode_engine: NotRequired[nemo_rl.models.generation.trtllm.config.TrtllmEngineArgs]#

None

disagg_server: NotRequired[nemo_rl.models.generation.trtllm.config.TrtllmDisaggServerConfig]#

None

class nemo_rl.models.generation.trtllm.config.TrtllmConfig#

Bases: nemo_rl.models.generation.interfaces.GenerationConfig

refit_transport: NotRequired[Literal[nccl_reshard] | None]#

None

trtllm_cfg: nemo_rl.models.generation.trtllm.config.TrtllmSpecificArgs#

None

trtllm_kwargs: NotRequired[dict[str, Any]]#

None

nemo_rl.models.generation.trtllm.config._as_dict(raw: Any) → dict[str, Any]#
nemo_rl.models.generation.trtllm.config.resolve_disagg_layout(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
) → nemo_rl.models.generation.interfaces.DisaggConfig#

generation.disaggregation as its schema.

Absent is the same as present-and-disabled: every field carries its default on :class:DisaggConfig, so callers read attributes unconditionally instead of re-deriving a default per key at the call site.

nemo_rl.models.generation.trtllm.config._deep_merge(
base: dict[str, Any],
update: dict[str, Any],
) → dict[str, Any]#

update over base, nested dicts merged key by key; inputs untouched.

nemo_rl.models.generation.trtllm.config.resolve_role_overrides(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
) → nemo_rl.models.generation.trtllm.config.TrtllmConfig#

Resolve trtllm_cfg.{prefill,decode}_engine into complete engine configs.

The one place the “a role wins over the shared value” rule is applied. As written, a role block names only what differs (TrtllmEngineArgs). Afterwards each is that role’s whole engine config: the shared trtllm_cfg with the role’s keys on top, and trtllm_kwargs deep-merged over generation.trtllm_kwargs, so a role’s nested block (say kv_cache_config: {max_tokens: N}) adds to the shared one instead of replacing it. Everything downstream reads the resolved block and merges nothing itself.

A role key outside TrtllmEngineArgs is rejected: the rest of trtllm_cfg describes the model or the engine’s contract with the rest of the system, so a role differing on one would not serve the same policy as its replica-mate. Silently dropping a knob someone wrote down would be worse than refusing to start.

Returns config unchanged without disaggregation, where the role blocks are inert. Idempotent: a resolved block only repeats the shared values outside TrtllmEngineArgs, and those pass the check.

nemo_rl.models.generation.trtllm.config.role_engine_config(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
role: Literal[prefill, decode],
) → dict[str, Any]#

The whole engine config of role. config must be role-resolved.

See :func:resolve_role_overrides.

nemo_rl.models.generation.trtllm.config.role_tensor_parallel_size(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
role: Literal[prefill, decode],
) → int#

TP of one engine of role. config must be role-resolved.

nemo_rl.models.generation.trtllm.config.replica_width(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
) → int#

GPUs one rollout replica spans.

Without disaggregation a replica is one engine, tensor_parallel_size wide (PP is always 1). Under it, a replica is its prefill engines plus its decode engines – the unit that must stay inside one NVLink domain, since the KV cache crosses from prefill to decode on every turn.

nemo_rl.models.generation.trtllm.config.resolve_disagg_server_config(
config: nemo_rl.models.generation.trtllm.config.TrtllmConfig,
) → nemo_rl.models.generation.trtllm.config.TrtllmDisaggServerConfig#

trtllm_cfg.disagg_server as its schema.

Kept separate from the layout rather than merged into one object: the two blocks answer different questions and go to different places – the layout sizes the engine fleet NeMo RL creates, this is forwarded to TRT-LLM’s DisaggServerConfig.