Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add model memory usage #1934

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

feat: add model memory usage #1934

wants to merge 11 commits into from

Conversation

Samoed
Copy link
Collaborator

@Samoed Samoed commented Feb 2, 2025

To make fully compatible old leaderboard with new, we can add model memory usage. Add property to ModelMeta.

Code Quality

  • Code Formatted: Format the code using make lint to maintain consistent style.

Documentation

  • Updated Documentation: Add or update documentation to reflect the changes introduced in this PR.

Testing

  • New Tests Added: Write tests to cover new functionality. Validate with make test-with-coverage.
  • Tests Passed: Run tests locally using make test or make test-with-coverage to ensure no existing functionality is broken.

@isaac-chung
Copy link
Collaborator

isaac-chung commented Feb 3, 2025

Have you already discussed with @KennethEnevoldsen or @x-tabdeveloping ? I'd prefer not to have such back-and-forth: to add then remove then add back things. #1729

@Samoed
Copy link
Collaborator Author

Samoed commented Feb 3, 2025

Opened issue for this #1935. Previously it was removed, because it was not filled and should be autocalculated based on the number of parameters of the model

Copy link
Collaborator

@isaac-chung isaac-chung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand now (we're not adding this back to be filled in - we are auto-calculating it here. Great stuff!). Thanks for the initiative! Just 2 clarifications then I think we're ready.

mteb/model_meta.py Outdated Show resolved Hide resolved
mteb/model_meta.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@isaac-chung isaac-chung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

Copy link
Collaborator

@x-tabdeveloping x-tabdeveloping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of minor comments. Thanks for adding this

mteb/model_meta.py Outdated Show resolved Hide resolved
if self.n_parameters is None:
return None
# Model memory in bytes. For FP32 each parameter is 4 bytes.
model_memory_bytes = self.num_params * 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a good assumption to make? Do all models have FP32 parameters?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Large models (>1B) params usally loaded with fp16/bp16, but I don't know how to handle this automatically

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you could get this information using huggingface_hub.hf_api.get_safetensors_metadata

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then do a cached_property so that it doesn't have to be fetched every time

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think integrating this could slow down leaderboard building. Maybe we could manually set memory usage instead or add information about the number of parameters for each model weight?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. We could fetch all of these in a script and manually keep count of them in ModelMeta perhaps?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calculated them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants