Fix SpeculatorsConfig now that PreTrainedConfig is a dataclass in Transformers#37574
Conversation
…in Transformers Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request aims to fix an issue with SpeculatorsConfig initialization when used with newer versions of transformers where PretrainedConfig is a dataclass. The proposed change introduces a passthrough __init__ method. However, the implementation might be incomplete, as it could propagate the original error to the superclass constructor call. I've left a comment with a detailed explanation of the potential issue and how it could be addressed.
| def __init__(self, **kwargs): | ||
| """PretrainedConfig is a dataclass in Transformers v5. | ||
| This pass through is needed to avoid unexpected keyword arguments.""" | ||
| super().__init__(**kwargs) |
There was a problem hiding this comment.
This fix may be incomplete. If the unexpected keyword argument error is due to PretrainedConfig being a dataclass with a standard generated __init__, that __init__ won't accept arbitrary **kwargs. Consequently, this call to super().__init__(**kwargs) will likely fail with the same error. The keyword arguments should be filtered to pass only those that PretrainedConfig.__init__ accepts. This can be done by inspecting the parent's __init__ signature.
There was a problem hiding this comment.
You're wrong, but the docstring didn't tell the whole story, I'll improve it.
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Monishver Chandrasekaran <monishverchandrasekaran@gmail.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Vinay Damodaran <vrdn@hey.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: EricccYang <yangyang4991@gmail.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
…in Transformers (vllm-project#37574) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Since Transformers converted
PretrainedConfigto adataclass, users will see unexpected keyword argument errors onSpeculatorsConfig.__init__.This PR adds a passthrough so that
SpeculatorsConfig.__init__can acceptkwargsand passes them directly toPretrainedConfig.__init__which also acceptskwargs