turboderp / exllamav2

A fast inference library for running LLMs locally on modern consumer-class GPUs
MIT License
3.65k stars 279 forks source link

BF16 conversion completes, but result does not run properly in ooba/llama-cpp as context length is shortened from 8K to 2K #378

Closed jim-plus closed 7 months ago

jim-plus commented 7 months ago

Unsure if this is an exllamav2 issue or a llama-cpp issue. (In contrast, GGUF Q8_0 conversion of BF16 worked.) When I loaded it via ooba/llama-cpp, inference broke when context length exceeded 4K, although the underlying model was 8K.

BF16 model used in testing. https://huggingface.co/grimjim/kunoichi-lemon-royale-7B

jim-plus commented 7 months ago

The problem appears to be reflected in config.json, quantization_config/calibration/length. For some reason it's been cut to only 2K context length. Changing the value manually to 8192 did not fix the problem when loading in ooba.

{
    "_name_or_path": "SanjiWatsuki/Kunoichi-7B",
    "architectures": [
        "MistralForCausalLM"
    ],
    "attention_dropout": 0.0,
    "bos_token_id": 1,
    "eos_token_id": 2,
    "hidden_act": "silu",
    "hidden_size": 4096,
    "initializer_range": 0.02,
    "intermediate_size": 14336,
    "max_position_embeddings": 8192,
    "model_type": "mistral",
    "num_attention_heads": 32,
    "num_hidden_layers": 32,
    "num_key_value_heads": 8,
    "rms_norm_eps": 1e-05,
    "rope_theta": 10000.0,
    "sliding_window": 4096,
    "tie_word_embeddings": false,
    "torch_dtype": "bfloat16",
    "transformers_version": "4.38.2",
    "use_cache": true,
    "vocab_size": 32000,
    "quantization_config": {
        "quant_method": "exl2",
        "version": "0.0.16",
        "bits": 8.0,
        "head_bits": 6,
        "calibration": {
            "rows": 100,
            "length": 2048,
            "dataset": "(default)"
        }
    }
}
turboderp commented 7 months ago

I would open an issue in the text-generation-webui repo for this. Something is overriding the context length and I can't tell what it is since the model works correctly in ExLlama.

turboderp commented 7 months ago

The issue is actually the "bits" metadata key. See https://github.com/oobabooga/text-generation-webui/issues/5750#issuecomment-2024442282

I suppose you could just remove the "quantization_config" key altogether and it should behave as before, until there's a better fix.