Skip to content

Commit

Permalink
back without dataclass for repo consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrilvallez committed Nov 26, 2024
1 parent 622edbf commit 01e004e
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/transformers/generation/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1562,8 +1562,6 @@ def construct_processor(self, vocab_size: int, device) -> "WatermarkLogitsProces
debug_mode=self.debug_mode,
)


@dataclass
class CompileConfig(object):
"""
Class that holds arguments relative to `torch.compile` behavior, when using automatic compilation in `generate`.
Expand All @@ -1582,14 +1580,27 @@ class CompileConfig(object):
A dictionary of options to pass to the backend.
"""

fullgraph: bool = True
dynamic: Optional[bool] = None
backend: Union[str, Callable] = "inductor"
mode: str = "reduce-overhead"
options: Optional[dict] = None
def __init__(
self,
fullgraph: bool = True,
dynamic: Optional[bool] = None,
backend: Union[str, Callable] = "inductor",
mode: str = "reduce-overhead",
options: Optional[dict] = None,
):
self.fullgraph = fullgraph
self.dynamic = dynamic
self.backend = backend
self.mode = mode
self.options = options

def to_dict(self) -> Dict[str, Any]:
"""
Serializes this instance to a Python dictionary.
"""
return copy.deepcopy(self.__dict__)

def __eq__(self, other) -> bool:
if not isinstance(other, CompileConfig):
raise ValueError(f"Equality not defined between CompileConfig and {type(other)}")
return self.to_dict() == other.to_dict()

0 comments on commit 01e004e

Please sign in to comment.