[Bugfix] Return the tokenizer from maybe_make_thread_pool so it survives pickling (#45460)

Signed-off-by: Wayne Chiu <waynehacking8@gmail.com>
This commit is contained in:
WEI CHENG CHIU
2026-06-13 06:01:35 +00:00
committed by GitHub
parent 43f0e024bc
commit 5b2943f5a6
2 changed files with 28 additions and 1 deletions
+3
View File
@@ -99,6 +99,9 @@ def maybe_make_thread_pool(tokenizer: _T, copies: int = 1):
TokenizerPool.__name__ = f"TokenizerPool{og_tokenizer.__class__.__name__}"
tokenizer.__class__ = TokenizerPool
# Return the tokenizer: TokenizerPool.__reduce__ reconstructs through this
# function, so falling off the end would unpickle to None (issue #45433).
return tokenizer
def get_cached_tokenizer(tokenizer: HfTokenizer) -> HfTokenizer: