trinity.common.patch.kimi module

trinity.common.patch.kimi module#

Monkey patching for 'kimi_vl' models.

trinity.common.patch.kimi.kimi_vl_monkey_patch_decorator(func)[源代码]#

A decorator that applies temporary monkey patches for 'kimi_vl' models before the decorated function runs, and restores the original state afterward.

The patch is applied only if:
  • The model's config.json exists and specifies "model_type": "kimi_vl"

  • The installed transformers version is >= 4.51.0

Patches include:
  1. Replacing transformers.activations.PytorchGELUTanh with GELUTanh

  2. Wrapping importlib.util.spec_from_file_location to inject DeepseekV3 classes

The decorator automatically extracts model_path and override_model_config from the function's arguments using inspect.signature, regardless of whether they are passed as positional or keyword arguments.