Skip to content

Pin max Transformers version#174

Merged
regisss merged 9 commits intomainfrom
fix_doc_build
Mar 10, 2026
Merged

Pin max Transformers version#174
regisss merged 9 commits intomainfrom
fix_doc_build

Conversation

@regisss
Copy link
Copy Markdown
Contributor

@regisss regisss commented Mar 9, 2026

The library does not seem to be compatible with Transformers v5, which makes the doc build fail: https://github.com/huggingface/optimum/actions/runs/22865237221/attempts/1

This PR thus pins Transformers in order to solve this issue.

Numpy is also pinned for the doc only as the following error appeared in the doc build logs (although the docs were still successfully generated):

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.2.6 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last): File "/usr/local/bin/doc-builder", line 10, in
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/doc_builder/commands/doc_builder_cli.py", line 50, in main
args.func(args)
File "/usr/local/lib/python3.10/site-packages/doc_builder/commands/build.py", line 103, in build_command
build_doc(
File "/usr/local/lib/python3.10/site-packages/doc_builder/build_doc.py", line 391, in build_doc
package = importlib.import_module(package_name) if is_python_module else None
File "/usr/local/lib/python3.10/importlib/init.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.10/site-packages/optimum/amd/init.py", line 6, in
from transformers.utils import _LazyModule
File "/usr/local/lib/python3.10/site-packages/transformers/init.py", line 27, in
from . import dependency_versions_check
File "/usr/local/lib/python3.10/site-packages/transformers/dependency_versions_check.py", line 16, in
from .utils.versions import require_version, require_version_core
File "/usr/local/lib/python3.10/site-packages/transformers/utils/init.py", line 24, in
from .auto_docstring import (
File "/usr/local/lib/python3.10/site-packages/transformers/utils/auto_docstring.py", line 30, in
from .generic import ModelOutput
File "/usr/local/lib/python3.10/site-packages/transformers/utils/generic.py", line 51, in
import torch
File "/usr/local/lib/python3.10/site-packages/torch/init.py", line 1477, in
from .functional import * # noqa: F403
File "/usr/local/lib/python3.10/site-packages/torch/functional.py", line 9, in
import torch.nn.functional as F
File "/usr/local/lib/python3.10/site-packages/torch/nn/init.py", line 1, in
from .modules import * # noqa: F403
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/init.py", line 35, in
from .transformer import TransformerEncoder, TransformerDecoder,
File "/usr/local/lib/python3.10/site-packages/torch/nn/modules/transformer.py", line 20, in
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),
/usr/local/lib/python3.10/site-packages/torch/nn/modules/transformer.py:20: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ../torch/csrc/utils/tensor_numpy.cpp:84.)
device: torch.device = torch.device(torch._C._get_default_device()), # torch.device('cpu'),

A draft PR was opened in Optimum to test these changes and make sure the issue is solved: huggingface/optimum#2411

@regisss regisss merged commit fa22eca into main Mar 10, 2026
2 checks passed
@regisss regisss deleted the fix_doc_build branch March 10, 2026 16:14
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.

2 participants