LoraConfig#
- class tensorrt_llm.llmapi.LoraConfig(
- *,
- lora_dir: ~typing.List[str] = <factory>,
- lora_ckpt_source: ~typing.Literal['hf',
- 'nemo'] = 'hf',
- max_lora_rank: int = 64,
- lora_target_modules: ~typing.List[str] = <factory>,
- trtllm_modules_to_hf_modules: ~typing.Dict[str,
- str] = <factory>,
- max_loras: int | None = None,
- max_cpu_loras: int | None = None,
- swap_gate_up_proj_lora_b_weight: bool = True,
- overlap_lora_and_base: bool = False,
- cuda_graph_specialize_lora: bool = False,
Bases:
StrictBaseModel- field cuda_graph_specialize_lora: bool = False#
Whether to capture separate CUDA graphs for batches with and without active LoRA adapters. Reduces overhead for batches without LoRA at the cost of increased warmup time and CUDA graph metadata.
- field lora_ckpt_source: Literal['hf', 'nemo'] = 'hf'#
Checkpoint format: ‘hf’ for HuggingFace PEFT format, ‘nemo’ for NeMo format. NeMo only supports attn_qkv module.
- field lora_dir: List[str] [Optional]#
List of directories containing LoRA adapter checkpoints. For HuggingFace format, expects adapter_model.bin/.safetensors and adapter_config.json. For NeMo format, expects .nemo files. If empty, lora_target_modules must be provided.
- field lora_target_modules: List[str] [Optional]#
TensorRT-LLM module names where LoRA is applied (e.g., [‘attn_q’, ‘attn_k’, ‘attn_v’], [‘attn_qkv’], [‘mlp_gate’, ‘mlp_up’]). If empty and lora_dir is provided, inferred from checkpoint.
- field max_cpu_loras: int | None = None#
Maximum number of LoRA adapters that can be stored in CPU memory. Controls host-side cache for prefetching adapters before moving to GPU.
- field max_lora_rank: int = 64#
Maximum LoRA rank across all adapters, used to pre-allocate workspace memory. Set to the actual max rank of your adapters to reduce memory usage.
- field max_loras: int | None = None#
Sizes the device-side LoRA cache for this many adapters at max_lora_rank, taking precedence over peft_cache_config.device_cache_percent when positive. Also sets the number of adapter slots in LoRA CUDA graphs (8 when unset). See the CUDA Graph Adapter Capacity section of the LoRA guide.
- field overlap_lora_and_base: bool = False#
Whether to place LoRA operations on a secondary CUDA stream and overlap them with base model computations. Improves latency in memory-bound regimes.
- field swap_gate_up_proj_lora_b_weight: bool = True#
Whether to swap gate/up projection order in fused gate_up_proj LoRA B weights. Set to False for models like Phi-4-MM that use a different weight order.
- field trtllm_modules_to_hf_modules: Dict[str, str] [Optional]#
Mapping from TensorRT-LLM module names to HuggingFace module names (e.g., {‘attn_q’: ‘q_proj’}). If empty, uses default mappings.
- __init__(**data: Any) None#
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
- property missing_qkv_modules: List[str]#