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]]],
)
| 209 | |
| 210 | |
| 211 | def 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 | |
| 233 | def norm_dora_magnitude( |
no outgoing calls
no test coverage detected