nemo_rl.models.generation.trtllm.config#
Module Contents#
Classes#
The |
|
The settings a replica’s prefill and decode engines may disagree on. |
|
One role’s engine overrides: |
|
|
|
Functions#
|
|
|
|
Resolve |
|
The whole engine config of |
|
TP of one engine of |
|
GPUs one rollout replica spans. |
|
|
API#
- class nemo_rl.models.generation.trtllm.config.TrtllmDisaggServerConfig#
Bases:
pydantic.BaseModelThe
DisaggServerConfigfields NeMo RL forwards to TRT-LLM.extra="forbid":build_configforwards only the fields declared here, so any otherDisaggServerConfigkey (max_retries, …) would pass validation and then silently do nothing.Not a :class:
DisaggConfigsubclass: 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.TypedDictThe settings a replica’s prefill and decode engines may disagree on.
Deliberately narrow: everything else in
trtllm_cfgdescribes 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.TrtllmEngineKnobsOne 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.TrtllmEngineKnobstrtllm_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( ) nemo_rl.models.generation.interfaces.DisaggConfig#
generation.disaggregationas 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],
updateoverbase, nested dicts merged key by key; inputs untouched.
- nemo_rl.models.generation.trtllm.config.resolve_role_overrides( ) nemo_rl.models.generation.trtllm.config.TrtllmConfig#
Resolve
trtllm_cfg.{prefill,decode}_engineinto 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 sharedtrtllm_cfgwith the role’s keys on top, andtrtllm_kwargsdeep-merged overgeneration.trtllm_kwargs, so a role’s nested block (saykv_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
TrtllmEngineArgsis rejected: the rest oftrtllm_cfgdescribes 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
configunchanged without disaggregation, where the role blocks are inert. Idempotent: a resolved block only repeats the shared values outsideTrtllmEngineArgs, 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],
The whole engine config of
role.configmust 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],
TP of one engine of
role.configmust be role-resolved.
- nemo_rl.models.generation.trtllm.config.replica_width( ) int#
GPUs one rollout replica spans.
Without disaggregation a replica is one engine,
tensor_parallel_sizewide (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( ) nemo_rl.models.generation.trtllm.config.TrtllmDisaggServerConfig#
trtllm_cfg.disagg_serveras 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.