MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT-LLM / invert_module_mapping

Function invert_module_mapping

tensorrt_llm/lora_manager.py:211–230  ·  view source on GitHub ↗

Invert module mapping from TensorRT LLM -> HF to HF -> TensorRT-LLM. Args: trtllm_modules_to_hf_modules: Mapping from TensorRT LLM module names to HF module names (values can be strings or lists of strings) Returns: Dictionary mapping HF

(
    trtllm_modules_to_hf_modules: Dict[str, Union[str, List[str]]],
)

Source from the content-addressed store, hash-verified

209
210
211def invert_module_mapping(
212 trtllm_modules_to_hf_modules: Dict[str, Union[str, List[str]]],
213) -> Dict[str, str]:
214 """Invert module mapping from TensorRT LLM -> HF to HF -> TensorRT-LLM.
215
216 Args:
217 trtllm_modules_to_hf_modules: Mapping from TensorRT LLM module names to HF module names
218 (values can be strings or lists of strings)
219
220 Returns:
221 Dictionary mapping HF module names to TensorRT LLM module names
222 """
223 hf_modules_to_trtllm_modules: Dict[str, str] = {}
224 for k, hf_modules in trtllm_modules_to_hf_modules.items():
225 if isinstance(hf_modules, list):
226 for hf_module in hf_modules:
227 hf_modules_to_trtllm_modules[hf_module] = k
228 else:
229 hf_modules_to_trtllm_modules[hf_modules] = k
230 return hf_modules_to_trtllm_modules
231
232
233def norm_dora_magnitude(

Callers 2

get_target_modulesMethod · 0.85
load_from_hfMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected