(original_state_dict: dict[str, Any], version: str)
| 708 | |
| 709 | |
| 710 | def convert_ltx2_audio_vae(original_state_dict: dict[str, Any], version: str) -> dict[str, Any]: |
| 711 | config, rename_dict, special_keys_remap = get_ltx2_audio_vae_config(version) |
| 712 | diffusers_config = config["diffusers_config"] |
| 713 | |
| 714 | with init_empty_weights(): |
| 715 | vae = AutoencoderKLLTX2Audio.from_config(diffusers_config) |
| 716 | |
| 717 | # Handle official code --> diffusers key remapping via the remap dict |
| 718 | for key in list(original_state_dict.keys()): |
| 719 | new_key = key[:] |
| 720 | for replace_key, rename_key in rename_dict.items(): |
| 721 | new_key = new_key.replace(replace_key, rename_key) |
| 722 | update_state_dict_inplace(original_state_dict, key, new_key) |
| 723 | |
| 724 | # Handle any special logic which can't be expressed by a simple 1:1 remapping with the handlers in |
| 725 | # special_keys_remap |
| 726 | for key in list(original_state_dict.keys()): |
| 727 | for special_key, handler_fn_inplace in special_keys_remap.items(): |
| 728 | if special_key not in key: |
| 729 | continue |
| 730 | handler_fn_inplace(key, original_state_dict) |
| 731 | |
| 732 | vae.load_state_dict(original_state_dict, strict=True, assign=True) |
| 733 | return vae |
| 734 | |
| 735 | |
| 736 | def get_ltx2_vocoder_config(version: str) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]: |
no test coverage detected
searching dependent graphs…