MCPcopy Create free account
hub / github.com/BeastyZ/ConvSearch-R1 / apply_monkey_patch

Function apply_monkey_patch

verl/verl/models/transformers/monkey_patch.py:49–64  ·  view source on GitHub ↗
(config: PretrainedConfig, verbose=True)

Source from the content-addressed store, hash-verified

47
48
49def apply_monkey_patch(config: PretrainedConfig, verbose=True):
50 if not is_transformers_version_in_range("4.45.0", "4.49.0"):
51 raise AssertionError("The installed `transformers` version doesn't support ulysses patch. "
52 "Please install a version between 4.45.0 and 4.49.0 to use this ulysses feature.")
53 success_apply_monkey_patch = False
54 if config.model_type in _PATCH_NAME_TO_FUNC:
55 _PATCH_NAME_TO_FUNC[config.model_type]()
56 success_apply_monkey_patch = True
57
58 if success_apply_monkey_patch and verbose:
59 print(f'Applying monkey patch to model {config.model_type}')
60 elif not success_apply_monkey_patch:
61 raise NotImplementedError(f'Ulysses for model {config.model_type} is not implemented, \
62 please set `ulysses_sequence_parallel_size=1`')
63
64 return success_apply_monkey_patch
65
66
67from functools import lru_cache

Callers 7

_build_modelMethod · 0.90
test_hf_casual_fwdFunction · 0.85
test_hf_casual_fwd_bwdFunction · 0.85

Calls 1

Tested by 2

test_hf_casual_fwdFunction · 0.68
test_hf_casual_fwd_bwdFunction · 0.68