Bug 2460068

Summary: python-accelerate fails to build with Python 3.15: TypeError: Signature mismatch between <built-in function pack> and <function pack at 0x7f50247c78a0>: (format, /, *values) != (fmt: 'bytes | str', /, *v: 'Any') -> 'bytes'
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-accelerateAssignee: Alexander Lent <lx>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: ai-packagers-sig, ksurma, lx, mhroncok, python-packagers-sig, Tom.Rix
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2412434    

Description Karolina Surma 2026-04-21 13:40:02 UTC
python-accelerate fails to build with Python 3.15.0a8.

3 tests fail with a similar issue:

____________ CPUOptimizerTester.test_accelerated_optimizer_pickling ____________

self = <test_optimizer.CPUOptimizerTester testMethod=test_accelerated_optimizer_pickling>

    def test_accelerated_optimizer_pickling(self):
        model = torch.nn.Linear(10, 10)
>       optimizer = torch.optim.SGD(model.parameters(), 0.1)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_optimizer.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.15/site-packages/torch/optim/sgd.py:65: in __init__
    super().__init__(params, defaults)
/usr/lib64/python3.15/site-packages/torch/optim/optimizer.py:408: in __init__
    self.add_param_group(cast(dict, param_group))
/usr/lib64/python3.15/site-packages/torch/_compile.py:47: in inner
    import torch._dynamo
/usr/lib64/python3.15/site-packages/torch/_dynamo/__init__.py:76: in <module>
    from .polyfills import loader as _  # usort: skip # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib64/python3.15/site-packages/torch/_dynamo/polyfills/loader.py:34: in <module>
    POLYFILLED_MODULES: tuple["ModuleType", ...] = tuple(
                                                   ^^^^^
/usr/lib64/python3.15/site-packages/torch/_dynamo/polyfills/loader.py:35: in <genexpr>
    importlib.import_module(f".{submodule}", package=polyfills.__name__)
/usr/lib64/python3.15/importlib/__init__.py:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/usr/lib64/python3.15/site-packages/torch/_dynamo/polyfills/struct.py:20: in <module>
    @substitute_in_graph(struct.pack, can_constant_fold_through=True)  # type: ignore[arg-type]
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

traceable_fn = <function pack at 0x7f50247c78a0>

    def wrapper(traceable_fn: Callable[_P, _R]) -> Callable[_P, _R]:
        if not is_function(traceable_fn):
            raise TypeError(
                f"@substitute_in_graph(...) expects a function but got {type(traceable_fn)!r}"
            )
    
        if not skip_signature_check:
            try:
                original_sig = inspect.signature(original_fn)
            except ValueError:
                pass
            else:
                traceable_sig = inspect.signature(traceable_fn)
    
                def sig_ident(
                    sig: inspect.Signature,
                ) -> tuple[tuple[str, ...], set[str], dict[str, Any]]:
                    # Ignore annotations for parameters and return type
                    return (
                        tuple(
                            p.name
                            for p in sig.parameters.values()
                            if (
                                p.kind
                                not in {
                                    p.KEYWORD_ONLY,
                                    # the name of *args and **kwargs is not important
                                    p.VAR_POSITIONAL,
                                    p.VAR_KEYWORD,
                                }
                            )
                        ),
                        {
                            p.name
                            for p in sig.parameters.values()
                            if p.kind == p.KEYWORD_ONLY
                        },
                        {
                            p.name: p.default
                            for p in sig.parameters.values()
                            # the name of *args and **kwargs is not important
                            if p.kind not in {p.VAR_POSITIONAL, p.VAR_KEYWORD}
                        },
                    )
    
                wildcard_sig = inspect.signature(lambda *args, **kwargs: None)
    
                if (
                    sig_ident(original_sig) != sig_ident(traceable_sig)
                    and sig_ident(original_sig) != sig_ident(wildcard_sig)
                    and sig_ident(traceable_sig) != sig_ident(wildcard_sig)
                ):
>                   raise TypeError(
                        f"Signature mismatch between {original_fn} and {traceable_fn}: "
                        f"{original_sig} != {traceable_sig}"
                    )
E                   TypeError: Signature mismatch between <built-in function pack> and <function pack at 0x7f50247c78a0>: (format, /, *values) != (fmt: 'bytes | str', /, *v: 'Any') -> 'bytes'

https://docs.python.org/3.15/whatsnew/3.15.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.15/fedora-rawhide-x86_64/10341837-python-accelerate/

For all our attempts to build python-accelerate with Python 3.15, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/package/python-accelerate/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.15:
https://copr.fedorainfracloud.org/coprs/g/python/python3.15/

Let us know here if you have any questions.

Python 3.15 is planned to be included in Fedora 45.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.15.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Alexander Lent 2026-04-25 05:24:48 UTC
Hmm, thank you for alerting me to this. I wonder if this is actually an issue with PyTorch's dynamo not being compatible with Python 3.15?

I'm adding Tom Rix, who is the torch maintainer, to see if this matches what he's seen previously.