@sshleifer I was trying to convert pegasus TF checkpoint to pytorch using this 1 script in transformers.
Can you please help me with below queries:
1.While replacing the keys i noticed below replacement which is not matching with BART keys so i have changed it accordingly:
Pegasus:
decoder/LayerNorm/beta -> decoder.layer_norm.bias
decoder/LayerNorm/gamma -> decoder.layer_norm.weight
BART:
decoder.layernorm_embedding.weight
decoder.layernorm_embedding.bias
2.In below code all pegasus dict_keys should be present in BART keys right ? but as Pegasus has more number of layers compared to BART…so it will never get keys like “decoder.layers.12.final_layer_norm.bias” in BART keys
def convert_pegasus_to_bart(tf_weights: dict, cfg_updates: dict) -> PegasusForConditionalGeneration:
    cfg_kwargs = DEFAULTS.copy()
    cfg_kwargs.update(cfg_updates)
    cfg = PegasusConfig(**cfg_updates)
    bart = PegasusForConditionalGeneration(cfg)
    sd = bart.model.state_dict()
    mapping = {}
    for k, v in tf_weights.items():
        new_k = rename_state_dict_key(k)
        if new_k not in sd:
            raise ValueError(f"could not find new key {new_k} in state dict. (converted from {k})")
        if "dense" in k or "proj" in new_k:
            v = v.T