Skip to content

Checkpoint conversion to HF fails #284

@flxst

Description

@flxst

System Info

  • modalities version: main branch, 7cd60e2
  • system: linux
  • python version: 3.10.13

🐛 Describe the bug

The conversion of the checkpoint from the getting started example to HF fails.

Error Message:

AttributeError: 'HFModelAdapterConfig' object has no attribute 'config'

Steps to reproduce the error:

  1. Run the getting started example:

    cd tutorials/getting_started
    bash run_getting_started_example.sh 0 1
    
  2. Create a config file example_config_convert.yaml for checkpoint conversion:

    • copy example config
    cp example_config.yaml example_config_convert.yaml
    
    • change settings.cuda_env in example_config_convert.yaml to:
    cuda_env:
      local_rank: 0
      global_rank: 0
      world_size: 1
    
    • append the following top level component to example_config_convert.yaml:
    checkpointed_model:
      component_key: model
      variant_key: checkpointed
      config:
        checkpoint_loading:                                       
          component_key: checkpoint_loading
          variant_key: torch
          config:
            device: 0
            precision: BF16
        model:
          instance_key: model
          pass_type: BY_REFERENCE
        checkpoint_path: checkpoints/<path_to_checkpoint>.bin   # needs to be adjusted to checkpoint created in step 1.
    
  3. Run checkpoint conversion:

    CUDA_VISIBLE_DEVICES=0 modalities convert_pytorch_to_hf_checkpoint --config_file_path example_config_convert.yaml --output_hf_checkpoint_dir checkpoint.hf --prediction_key logits
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions