Skip to content

Bug: TaskVector object has no attribute scale in merge.py #1

Description

@JiangTao97

Description

Hello, thank you for your great work on this project!

While running the MAP repository, I encountered an issue in merge.py (line 34), where it attempts to use a scale() method on a TaskVector object:

task_vectors = [
    TaskVector(vector=vector).scale(scale)
    for vector, scale in zip(vectors, scaling)
]

However, the referenced [task_vectors](https://github.com/mlfoundations/task_vectors) repository does not include a scale method in the TaskVector class. This results in a runtime error.

### Error Log

/root/miniconda3/envs/map/lib/python3.10/site-packages/timm/models/layers/__init__.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
  warnings.warn(f"Importing from {__name__} is deprecated, please import via timm.layers", FutureWarning)
Traceback (most recent call last):
  File "/home/<user>/map-merge/run_MAP.py", line 330, in <module>
    map.run_MAP_nested(accuracy_dict, args=args)
  File "/home/<user>/map-merge/run_MAP.py", line 243, in run_MAP_nested
    scaling_coefficients_results = evaluate_scalings_nested(
  File "/home/<user>/map-merge/evaluation.py", line 250, in evaluate_scalings_nested
    image_encoder = get_merged_model(
  File "/home/<user>/map-merge/merge.py", line 60, in get_merged_model
    task_vectors = [
  File "/home/<user>/map-merge/merge.py", line 61, in <listcomp>
    TaskVector(pretrained_checkpoint, ft).scale(scale)
AttributeError: 'TaskVector' object has no attribute 'scale'

It seems that the scale method might have been part of a local or extended version of the task_vectors repo, but it is not included in the public version.

Could you kindly:
- Share the version of task_vectors that includes the scale() method, or
- Update merge.py to be compatible with the current public version?

Your help is much appreciated. Looking forward to your advice or a fix. Thanks again for your valuable work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions