xlora icon indicating copy to clipboard operation
xlora copied to clipboard

I trained and loaded the xlora model as shown in the tutorial, but I couldn't get the trained xlora model loaded, getting "AttributeError: 'NoneType' object has no attribute 'items'" error.

Open beingdutta opened this issue 1 year ago • 0 comments

I am using a Quantised Qwen VL 2B model, I loaded that as a base model then passed the same to initialise a trained xlora model as follows:

base_model = Qwen2VLForConditionalGeneration.from_pretrained(
    "Qwen/Qwen2-VL-2B-Instruct",
    torch_dtype = torch.bfloat16,
    attn_implementation = "flash_attention_2",
    # quantization_config = bnb_config,
    device_map = 'cuda:0'
)
#### Load processor. 
processor = AutoProcessor.from_pretrained("Qwen/Qwen2-VL-2B-Instruct", min_pixels=256*28*28, max_pixels=512*28*28, padding_side="left", use_fast = True)

XLORA_finetuned_model_path = ./moe-directory/moe-datasets/TDIUC/trained-models/xlora/xlora_4'
mole = xlora.from_pretrained(XLORA_finetuned_model_path, base_model, "cuda:0")

However, I am receiving this error. Below is the full stack trace of the error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[15], line 2
      1 XLORA_finetuned_model_path = '/home/aritrad/moe-directory/moe-datasets/TDIUC/trained-models/xlora/xlora_4'
----> 2 mole = xlora.from_pretrained(XLORA_finetuned_model_path, base_model, "cuda:0")

File ~/miniconda3/envs/stable_env/lib/python3.9/site-packages/xlora/xlora.py:310, in from_pretrained(load_directory, model, device, adapters, classifier_path, config_path, verbose, from_safetensors, **kwargs)
    308     adapters_real = adapters
    309 xlora_config.adapters = adapters_real
--> 310 model_peft = add_xlora_to_model(model, xlora_config, verbose, **kwargs)
    311 classifier: xLoRAClassifier = model_peft.internal_xlora_classifier  # type: ignore
    313 if from_safetensors:

File ~/miniconda3/envs/stable_env/lib/python3.9/site-packages/xlora/xlora.py:115, in add_xlora_to_model(model, xlora_config, verbose, **kwargs)
    113         adapters_items = iter(zip(xlora_config.adapters.items(), kwargs["subfolders"]))
    114     else:
--> 115         adapters_items = iter(xlora_config.adapters.items())
    116 first_item = next(adapters_items)
    117 if subfolders_in_kwargs:

AttributeError: 'NoneType' object has no attribute 'items'

Is there anything wrong with my code, or is it an issue with the "xlora_config.json" file? Please help me fix this error. I've been stuck for so long now without a clue what's wrong inside.

beingdutta avatar Apr 16 '25 19:04 beingdutta