Skip to content

fix: resolve HuggingFace version alias in image URI tag#5722

Open
giangle-AI wants to merge 2 commits intoaws:masterfrom
giangle-AI:fix/huggingface-image-uri-version-alias
Open

fix: resolve HuggingFace version alias in image URI tag#5722
giangle-AI wants to merge 2 commits intoaws:masterfrom
giangle-AI:fix/huggingface-image-uri-version-alias

Conversation

@giangle-AI
Copy link
Copy Markdown

@giangle-AI giangle-AI commented Apr 7, 2026

Summary

  • Bug: When constructing image URIs for HuggingFace framework containers, the code used original_version (raw user input like "4.49") instead of resolving it through the version alias mapping ("4.49""4.49.0"). This produced incorrect image tags such as transformers4.49 instead of the correct transformers4.49.0, pointing to non-existent container images.
  • Fix: Replace _version = original_version with _version = _version_for_config(version, config) on line 247 of image_uris.py so the version alias is properly resolved before being embedded in the image tag.

Before (broken)

>>> image_uris.retrieve(framework='huggingface', region='ap-southeast-1', version='4.49',
...     py_version='py312', image_scope='inference', base_framework_version="pytorch2.6.0",
...     instance_type="ml.c5.xlarge")
'763104351884.dkr.ecr.ap-southeast-1.amazonaws.com/huggingface-pytorch-inference:2.6.0-transformers4.49-cpu-py312-ubuntu22.04'

After (fixed)

>>> image_uris.retrieve(framework='huggingface', region='ap-southeast-1', version='4.49',
...     py_version='py312', image_scope='inference', base_framework_version="pytorch2.6.0",
...     instance_type="ml.c5.xlarge")
'763104351884.dkr.ecr.ap-southeast-1.amazonaws.com/huggingface-pytorch-inference:2.6.0-transformers4.49.0-cpu-py312-ubuntu22.04'

Test plan

  • Verified the bug reproduces on master (transformers4.49 in the tag)
  • Verified the fix produces the correct output (transformers4.49.0 in the tag)
  • Run existing unit tests for image_uris.retrieve with HuggingFace framework
  • Verify other HuggingFace version aliases (e.g. 4.37, 4.51) also resolve correctly
  • Confirmed all 26 non-aliased full versions (e.g. 4.49.0, 4.51.3) produce correct tags with no regression

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

When constructing the image URI tag for HuggingFace framework containers,
the code used `original_version` (the raw user input, e.g. "4.49") instead
of resolving it through the version alias mapping (e.g. "4.49" → "4.49.0").

This caused image URIs to contain truncated transformer versions like
`transformers4.49` instead of the correct `transformers4.49.0`, resulting
in references to non-existent container images.

Use `_version_for_config(version, config)` to properly resolve the version
alias before embedding it in the image tag.

Made-with: Cursor
- Fix existing test_retrieve_huggingface assertions to expect resolved
  versions (4.2.1) instead of raw aliases (4.2) in image tags
- Add parametrized test covering all 25 version aliases across training
  and inference scopes to verify aliases resolve correctly in tags
- Add parametrized test covering all 26 non-aliased (full) versions to
  confirm no regression when passing complete version strings directly

Made-with: Cursor
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.

1 participant