Skip to content

Error when trying to upload an adapter to HuggingFace #3146

@harisec

Description

@harisec

Describe the bug

When trying to upload a local adapter "output/v0-20250217-155545/checkpoint-62" to HuggingFace I receive the error AttributeError: 'HfApi' object has no attribute 'create_model' and the upload did not proceed.

Here is the full output:

CUDA_VISIBLE_DEVICES=0 swift export     --adapters output/v0-20250217-155545/checkpoint-62     --push_to_hub true     --hub_model_id 'harisec/testing'     --hub_token 'hf_XXX'     --use_hf true
run sh: `/home/h/ai/bin/python3 /home/h/ai/lib/python3.12/site-packages/swift/cli/export.py --adapters output/v0-20250217-155545/checkpoint-62 --push_to_hub true --hub_model_id harisec/testing --hub_token hf_XXX --use_hf true`
[INFO:swift] Successfully registered `/home/h/ai/lib/python3.12/site-packages/swift/llm/dataset/data/dataset_info.json`
[INFO:swift] Loading the model using model_dir: output/v0-20250217-155545/checkpoint-62
[INFO:swift] Successfully loaded /home/h/output/v0-20250217-155545/checkpoint-62/args.json.
[INFO:swift] rank: -1, local_rank: -1, world_size: 1, local_world_size: 1
[INFO:swift.hub.hub] Downloading the model from HuggingFace Hub, model_id: Qwen/Qwen2.5-0.5B-Instruct
Fetching 9 files: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 114737.80it/s]
[INFO:swift] Loading the model using model_dir: /home/h/.cache/huggingface/hub/models--Qwen--Qwen2.5-0.5B-Instruct/snapshots/7ae557604adf67be50417f59c2c2f167def9a775
[INFO:swift] Global seed set to 42
[INFO:swift] args: ExportArguments(model='Qwen/Qwen2.5-0.5B-Instruct', model_type='qwen2_5', model_revision=None, task_type='causal_lm', torch_dtype=torch.bfloat16, attn_impl=None, num_labels=None, rope_scaling=None, device_map=None, local_repo_path=None, template='qwen2_5', system='You are a helpful assistant.', max_length=2048, truncation_strategy='delete', max_pixels=None, tools_prompt='react_en', norm_bbox=None, padding_side='right', loss_scale='default', sequence_parallel_size=1, use_chat_template=True, template_backend='swift', dataset=[], val_dataset=[], split_dataset_ratio=0.01, data_seed=42, dataset_num_proc=1, streaming=False, enable_cache=False, download_mode='reuse_dataset_if_exists', columns={}, strict=False, model_name=[None, None], model_author=[None, None], custom_dataset_info=[], quant_method=None, quant_bits=None, hqq_axis=None, bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_quant_type='nf4', bnb_4bit_use_double_quant=True, bnb_4bit_quant_storage=None, max_new_tokens=None, temperature=None, top_k=None, top_p=None, repetition_penalty=None, num_beams=1, stream=False, stop_words=[], logprobs=False, top_logprobs=None, ckpt_dir='/home/h/output/v0-20250217-155545/checkpoint-62', load_dataset_config=None, lora_modules=[], tuner_backend='peft', train_type='lora', adapters=['/home/h/output/v0-20250217-155545/checkpoint-62'], seed=42, model_kwargs={}, load_args=True, load_data_args=False, use_hf=True, hub_token='hf_XXX', custom_register_path=[], ignore_args_error=False, use_swift_lora=False, merge_lora=False, safe_serialization=True, max_shard_size='5GB', output_dir=None, quant_n_samples=256, quant_batch_size=1, group_size=128, to_ollama=False, gguf_file=None, push_to_hub=True, hub_model_id='harisec/testing', hub_private_repo=False, commit_message='update files', to_peft_format=False, exist_ok=False)
[INFO:swift] Start time of running main: 2025-02-17 16:48:45.331075
Traceback (most recent call last):
  File "/home/h/ai/lib/python3.12/site-packages/swift/cli/export.py", line 5, in <module>
    export_main()
  File "/home/h/ai/lib/python3.12/site-packages/swift/llm/export/export.py", line 44, in export_main
    return SwiftExport(args).main()
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/h/ai/lib/python3.12/site-packages/swift/llm/base.py", line 46, in main
    result = self.run()
             ^^^^^^^^^^
  File "/home/h/ai/lib/python3.12/site-packages/swift/llm/export/export.py", line 35, in run
    args.hub.push_to_hub(
  File "/home/h/ai/lib/python3.12/site-packages/swift/hub/hub.py", line 393, in push_to_hub
    cls.create_model_repo(repo_id, token, private)
  File "/home/h/ai/lib/python3.12/site-packages/swift/hub/hub.py", line 379, in create_model_repo
    return api.create_model(repo_id, token=token, private=private)
           ^^^^^^^^^^^^^^^^
AttributeError: 'HfApi' object has no attribute 'create_model'

Your hardware and system info
Write your system info like CUDA version/system/GPU/torch version here(在这里给出硬件信息和系统信息,如CUDA版本,系统,GPU型号和torch版本等)

$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0

Additional context
Add any other context about the problem here(在这里补充其他信息)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions