Add options for configuring quantization in CachedCausalLM.from_pretrained() #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds several kwargs to CachedCausalLM.from_pretrained() to make quantization more configurable. Preserves the default behavior of
load_in_8bit=True
.Motivation: It turns out that NVIDIA Hopper removed int8 support (bitsandbytes-foundation/bitsandbytes#599) in favor of float8 quantization. This is an issue for running hfppl on H100 GPUs which use Hopper architecture. More generally, with the space of LLMs and quantization schemes evolving quickly, the existing
CachedCausalLM.from_pretrained()
should offer the user more configuration control.As a quick fix, this PR adds the ability to pass
load_in_4bit
as well as to specify a custombnb_config
. It's also separately useful to be able to pass atorch_dtype
.Future steps: Certain llama models now usetorch.bfloat16
; however, this dtype isn't supported by numpy so it's currently incompatible withhfppl
, but there are multiple workarounds we should explore that extend numpy to support it.EDIT: Turns out the only issue with
bfloat16
arises when we try to store logprobs in the Trie without converting them to a numpy-friendly format. I've added calls to.float()
in 2 cases and these seem to be sufficient to supportbfloat16
models.