Skip to content

Simplify dtype instantiation#42825

Merged
Cyrilvallez merged 11 commits intomainfrom
dtype-stuff
Dec 12, 2025
Merged

Simplify dtype instantiation#42825
Cyrilvallez merged 11 commits intomainfrom
dtype-stuff

Conversation

@Cyrilvallez
Copy link
Copy Markdown
Member

@Cyrilvallez Cyrilvallez commented Dec 11, 2025

What does this PR do?

As per the title. Cleanu-up a bit after #42805 and in general

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Copy Markdown
Collaborator

@ArthurZucker ArthurZucker left a comment

Choose a reason for hiding this comment

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

    @property
    def dtype(self) -> torch.dtype:
        """
        `torch.dtype`: The dtype of the module (assuming that all the module parameters have the same dtype).
        """
        dtype = self._dtype or next(param.dtype for param in self.parameters() if param.is_floating_point())
        if isinstance(dtype, str):
            if hasattr(torch, dtype):
                dtype = getattr(torch, dtype)
        return dtype

you did not change this one either no

@Cyrilvallez
Copy link
Copy Markdown
Member Author

I did, it's here haha

@Cyrilvallez Cyrilvallez merged commit 64a7cc8 into main Dec 12, 2025
26 checks passed
@Cyrilvallez Cyrilvallez deleted the dtype-stuff branch December 12, 2025 13:46
SangbumChoi pushed a commit to SangbumChoi/transformers that referenced this pull request Jan 23, 2026
* fix

* simplify

* align tests

* fix

* oupsi - super bad traceback

* fix

* fix

* fix

* simplify

* fix

* comment
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