Skip to content

Add missing match on onnx/model.onnx download #472

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

Merged
merged 4 commits into from
Mar 26, 2025

Conversation

alvarobartt
Copy link
Member

@alvarobartt alvarobartt commented Jan 16, 2025

What does this PR do?

This PR adds a missing match statement within the download_onnx function as it was missing for the onnx/model.onnx download, leading to an unexpected logging message claiming that the ONNX files were downloaded successfully, while those were not indeed (see attachment at huggingface/Google-Cloud-Containers#132 (comment)).

This PR fixes a non-breaking issue, as even if the logging messages were misleading the behaviour for rolling back to safetensors if ONNX weights were not available is working as expected.

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

@OlivierDehaene

Narsil
Narsil previously approved these changes Feb 26, 2025
Copy link
Collaborator

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

LGTM.

I trust that it's fine if you checked it. Worse case we patch.
I'm surprised at the logic flow though.

Prevents the logging message "Model ONNX weights downloaded in ..." from
showing whenever those are either not present or not downloaded
@alvarobartt
Copy link
Member Author

You're right indeed, there's something that I missed because the download_onnx function is not raising errors if the content of the model_files is empty, so that condition won't match, I'll update the check to include the check on whether the model_files is empty or not! Thanks for the great catch and apologies for the oversight!

@alvarobartt
Copy link
Member Author

Should be fixed already, thanks for the catch up!

image

@alvarobartt alvarobartt marked this pull request as ready for review February 26, 2025 13:52
@alvarobartt alvarobartt requested a review from Narsil February 26, 2025 13:52
@alvarobartt alvarobartt requested a review from McPatate March 25, 2025 09:16
Comment on lines -533 to +544
let p = api.get("onnx/model.onnx").await?;
model_files.push(p.parent().unwrap().to_path_buf())

match api.get("onnx/model.onnx").await {
Ok(p) => model_files.push(p.parent().unwrap().to_path_buf()),
Err(err) => tracing::warn!("Could not download `onnx/model.onnx`: {err}"),
};
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this virtually the same? How is the error handled in this fn?

.await
.map_err(|err| BackendError::WeightsNotFound(err.to_string()));
Copy link
Member

Choose a reason for hiding this comment

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

Didn't you only need to add a ? after the map_err?

Copy link
Member Author

Choose a reason for hiding this comment

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

No because it still succeeds as far as I remember the download_onnx function was not producing errors but just warnings so empty ONNX files was not considered an error and so on it was printing that the files where there while those really weren't + this doesn't need to fail as it needs to fallback to the Safetensors backend if the ONNX files are not there.

Anyway I could've missed something, so please let me know!

Copy link
Collaborator

@Narsil Narsil left a comment

Choose a reason for hiding this comment

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

LGTM

@Narsil Narsil merged commit 35fac69 into huggingface:main Mar 26, 2025
2 of 9 checks passed
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