hf_text-generation-inference/server/tests/utils
Daniël de Kok 8511669cb2
Move quantized weight handling out of the `Weights` class (#2194)
Quantized weights were loaded in the `Weights` class, but this was
getting quite unwieldy, where every higher level method to load weights
was a long conditional to cover all the different quantizers.

This change moves loading of quantized weights out of the `Weights`
class. This is done by defining a simple `WeightsLoader` interface
that is implemented by `Exl2WeightsLoader`, `GPTQWeightsLoader`,
and `MarlinWeightsLoader`. These implementations are in the quantizers'
respective modules. The `Weights` class provides the low-level load
operations (such as loading tensors or sharded tensors), but delegates
loads that need quantizer-specific weight processing to a loader. The
loaders still use the low-level functionality provided by `Weights`.

I initially tried making a hierarchy where a class like `GPTQWeights`
would inherit from `Weights`. But it is not very flexible (e.g. does
not work well with the new weight storage mock used in tests) and
the implicit indirections made the code harder to follow.
2024-07-09 20:04:03 +02:00
..
test_convert.py fix(server): harden the weights choice to save on disk. (#561) 2023-07-07 14:50:12 +02:00
test_hub.py Fix local load for peft (#1373) 2023-12-21 17:29:23 +01:00
test_layers.py Move quantized weight handling out of the `Weights` class (#2194) 2024-07-09 20:04:03 +02:00
test_tokens.py feat(server): add frequency penalty (#1541) 2024-02-08 18:41:25 +01:00
test_watermark.py feat(server): add watermarking tests (#248) 2023-04-27 19:16:35 +02:00
test_weights.py Move quantized weight handling out of the `Weights` class (#2194) 2024-07-09 20:04:03 +02:00