fix(embeddings): change default output_type from np to pt in positional embedding helpers - #14372
Open
AloysJehwin wants to merge 1 commit into
Open
Conversation
…tional embedding helpers Four public helpers defaulted to output_type='np', which routes into a past-target deprecate() call (target 0.33.0/0.34.0, current 0.40.0). deprecate() raises once the library version has passed the target, so calling these functions with their defaults raised ValueError. Changed the default to output_type='pt' in: - get_3d_sincos_pos_embed - get_2d_sincos_pos_embed - get_2d_sincos_pos_embed_from_grid - get_1d_sincos_pos_embed_from_grid - get_2d_rotary_pos_embed The deprecated 'np' path is preserved for backward compatibility when callers explicitly pass output_type='np', but the no-argument default no longer crashes. Fixes huggingface#14366 Signed-off-by: Aloys Jehwin <aloysjehwin@gmail.com>
Author
|
Fair point — I went with the minimal change (flip the default) without considering that the intent may be full removal of the np path. Happy to update the PR to remove the deprecated branch entirely if that's the preferred direction, or close and wait for a maintainer to confirm the intended approach. Let me know. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #14366
Four public helpers in
embeddings.pydefaulted tooutput_type='np', which routes into adeprecate()call with target0.33.0/0.34.0. Since the current version is0.40.0,deprecate()raises aValueErrorbefore doing anything — so calling these functions with no arguments crashes.Changed the default to
output_type='pt'in:get_3d_sincos_pos_embedget_2d_sincos_pos_embedget_2d_sincos_pos_embed_from_gridget_1d_sincos_pos_embed_from_gridget_2d_rotary_pos_embedThe deprecated
'np'path is preserved for callers who pass it explicitly.All eight in-tree call sites already pass
output_type='pt'explicitly — this only affects external callers using the default.Before
After
Implemented with Claude Code assistance. All changed lines reviewed manually.