xbtorch.patches.utils

Functions

replace_all_layers_stateful(model, wage_quantize)

Recursively replace all modules within a model with XBTorch modules for stateful operation.

replace_all_layers_stateless(model[, exclude])

Recursively replace all modules within a model with XBTorch modules for stateless operation.

toggle_xb_eval_all_layers_stateless(model, ...)

Recursively enable or disable linear modules within a model with some customized layer module.

xbtorch.patches.utils.replace_all_layers_stateful(model, wage_quantize)[source]

Recursively replace all modules within a model with XBTorch modules for stateful operation. Supports wage quantization.

xbtorch.patches.utils.replace_all_layers_stateless(model: <module 'transformers.models' from '/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/transformers/models/__init__.py'>, exclude: list = []) None[source]

Recursively replace all modules within a model with XBTorch modules for stateless operation.

xbtorch.patches.utils.toggle_xb_eval_all_layers_stateless(model, enable)[source]

Recursively enable or disable linear modules within a model with some customized layer module.