oobabooga / text-generation-webui

A Gradio web UI for Large Language Models.
GNU Affero General Public License v3.0
40.63k stars 5.31k forks source link

Invoking any grammar except None causes webui to crash #6329

Closed BongoUnicorns closed 2 months ago

BongoUnicorns commented 3 months ago

Describe the bug

When using llama.cpp loader and the latest oobabooga, any gguf model will generate text normally unless any grammar string is supplied, in which case the webui will crash entirely.

Logs attached have additional logs added into the code.

Is there an existing issue for this?

Reproduction

Clone latest webui and run setup. Load any gguf model using llama.cpp. Attempt generation normally. Add grammar string, webui will crash.

Screenshot

No response

Logs

20:45:47-393862 INFO     Starting Text generation web UI                                               
20:45:47-395696 INFO     Loading settings from "settings.yaml"                                         

Running on local URL:  http://127.0.0.1:7860

20:46:07-464325 INFO     Loading "Fimbulvetr-11B-v2.i1-IQ4_XS.gguf"                                    
20:46:07-492790 INFO     llama.cpp weights detected: "models/Fimbulvetr-11B-v2.i1-IQ4_XS.gguf"         
llama_model_loader: loaded meta data with 22 key-value pairs and 435 tensors from models/Fimbulvetr-11B-v2.i1-IQ4_XS.gguf (version GGUF V3 (latest))
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = LLaMA v2
llama_model_loader: - kv   2:                       llama.context_length u32              = 4096
llama_model_loader: - kv   3:                     llama.embedding_length u32              = 4096
llama_model_loader: - kv   4:                          llama.block_count u32              = 48
llama_model_loader: - kv   5:                  llama.feed_forward_length u32              = 14336
llama_model_loader: - kv   6:                 llama.rope.dimension_count u32              = 128
llama_model_loader: - kv   7:                 llama.attention.head_count u32              = 32
llama_model_loader: - kv   8:              llama.attention.head_count_kv u32              = 8
llama_model_loader: - kv   9:     llama.attention.layer_norm_rms_epsilon f32              = 0.000010
llama_model_loader: - kv  10:                       llama.rope.freq_base f32              = 10000.000000
llama_model_loader: - kv  11:                          general.file_type u32              = 30
llama_model_loader: - kv  12:                       tokenizer.ggml.model str              = llama
llama_model_loader: - kv  13:                      tokenizer.ggml.tokens arr[str,32000]   = ["<unk>", "<s>", "</s>", "<0x00>", "<...
llama_model_loader: - kv  14:                      tokenizer.ggml.scores arr[f32,32000]   = [0.000000, 0.000000, 0.000000, 0.0000...
llama_model_loader: - kv  15:                  tokenizer.ggml.token_type arr[i32,32000]   = [2, 3, 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, ...
llama_model_loader: - kv  16:                tokenizer.ggml.bos_token_id u32              = 1
llama_model_loader: - kv  17:                tokenizer.ggml.eos_token_id u32              = 2
llama_model_loader: - kv  18:            tokenizer.ggml.unknown_token_id u32              = 0
llama_model_loader: - kv  19:               tokenizer.ggml.add_bos_token bool             = true
llama_model_loader: - kv  20:               tokenizer.ggml.add_eos_token bool             = false
llama_model_loader: - kv  21:               general.quantization_version u32              = 2
llama_model_loader: - type  f32:   97 tensors
llama_model_loader: - type  f16:    1 tensors
llama_model_loader: - type q5_K:   48 tensors
llama_model_loader: - type iq4_xs:  289 tensors
llm_load_vocab: special tokens cache size = 3
llm_load_vocab: token to piece cache size = 0.1637 MB
llm_load_print_meta: format           = GGUF V3 (latest)
llm_load_print_meta: arch             = llama
llm_load_print_meta: vocab type       = SPM
llm_load_print_meta: n_vocab          = 32000
llm_load_print_meta: n_merges         = 0
llm_load_print_meta: vocab_only       = 0
llm_load_print_meta: n_ctx_train      = 4096
llm_load_print_meta: n_embd           = 4096
llm_load_print_meta: n_layer          = 48
llm_load_print_meta: n_head           = 32
llm_load_print_meta: n_head_kv        = 8
llm_load_print_meta: n_rot            = 128
llm_load_print_meta: n_swa            = 0
llm_load_print_meta: n_embd_head_k    = 128
llm_load_print_meta: n_embd_head_v    = 128
llm_load_print_meta: n_gqa            = 4
llm_load_print_meta: n_embd_k_gqa     = 1024
llm_load_print_meta: n_embd_v_gqa     = 1024
llm_load_print_meta: f_norm_eps       = 0.0e+00
llm_load_print_meta: f_norm_rms_eps   = 1.0e-05
llm_load_print_meta: f_clamp_kqv      = 0.0e+00
llm_load_print_meta: f_max_alibi_bias = 0.0e+00
llm_load_print_meta: f_logit_scale    = 0.0e+00
llm_load_print_meta: n_ff             = 14336
llm_load_print_meta: n_expert         = 0
llm_load_print_meta: n_expert_used    = 0
llm_load_print_meta: causal attn      = 1
llm_load_print_meta: pooling type     = 0
llm_load_print_meta: rope type        = 0
llm_load_print_meta: rope scaling     = linear
llm_load_print_meta: freq_base_train  = 10000.0
llm_load_print_meta: freq_scale_train = 1
llm_load_print_meta: n_ctx_orig_yarn  = 4096
llm_load_print_meta: rope_finetuned   = unknown
llm_load_print_meta: ssm_d_conv       = 0
llm_load_print_meta: ssm_d_inner      = 0
llm_load_print_meta: ssm_d_state      = 0
llm_load_print_meta: ssm_dt_rank      = 0
llm_load_print_meta: model type       = 34B
llm_load_print_meta: model ftype      = IQ4_XS - 4.25 bpw
llm_load_print_meta: model params     = 10.73 B
llm_load_print_meta: model size       = 5.52 GiB (4.42 BPW) 
llm_load_print_meta: general.name     = LLaMA v2
llm_load_print_meta: BOS token        = 1 '<s>'
llm_load_print_meta: EOS token        = 2 '</s>'
llm_load_print_meta: UNK token        = 0 '<unk>'
llm_load_print_meta: LF token         = 13 '<0x0A>'
llm_load_print_meta: max token length = 48
llm_load_tensors: ggml ctx size =    0.41 MiB
ggml_backend_metal_log_allocated_size: allocated buffer, size =  5585.53 MiB, ( 5585.59 / 49152.00)
llm_load_tensors: offloading 48 repeating layers to GPU
llm_load_tensors: offloading non-repeating layers to GPU
llm_load_tensors: offloaded 49/49 layers to GPU
llm_load_tensors:        CPU buffer size =    66.41 MiB
llm_load_tensors:      Metal buffer size =  5585.52 MiB
.................................................................................................
llama_new_context_with_model: n_ctx      = 4096
llama_new_context_with_model: n_batch    = 512
llama_new_context_with_model: n_ubatch   = 512
llama_new_context_with_model: flash_attn = 0
llama_new_context_with_model: freq_base  = 10000.0
llama_new_context_with_model: freq_scale = 1
ggml_metal_init: allocating
ggml_metal_init: found device: Apple M1 Max
ggml_metal_init: picking default device: Apple M1 Max
ggml_metal_init: using embedded metal library
ggml_metal_init: GPU name:   Apple M1 Max
ggml_metal_init: GPU family: MTLGPUFamilyApple7  (1007)
ggml_metal_init: GPU family: MTLGPUFamilyCommon3 (3003)
ggml_metal_init: GPU family: MTLGPUFamilyMetal3  (5001)
ggml_metal_init: simdgroup reduction support   = true
ggml_metal_init: simdgroup matrix mul. support = true
ggml_metal_init: hasUnifiedMemory              = true
ggml_metal_init: recommendedMaxWorkingSetSize  = 51539.61 MB
llama_kv_cache_init:      Metal KV buffer size =   768.00 MiB
llama_new_context_with_model: KV self size  =  768.00 MiB, K (f16):  384.00 MiB, V (f16):  384.00 MiB
llama_new_context_with_model:        CPU  output buffer size =     0.12 MiB
llama_new_context_with_model:      Metal compute buffer size =   296.00 MiB
llama_new_context_with_model:        CPU compute buffer size =    16.01 MiB
llama_new_context_with_model: graph nodes  = 1542
llama_new_context_with_model: graph splits = 2
AVX = 0 | AVX_VNNI = 0 | AVX2 = 0 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | AVX512_BF16 = 0 | FMA = 0 | NEON = 1 | SVE = 0 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | SSSE3 = 0 | VSX = 0 | MATMUL_INT8 = 0 | LLAMAFILE = 1 | 
Model metadata: {'general.quantization_version': '2', 'tokenizer.ggml.add_eos_token': 'false', 'tokenizer.ggml.add_bos_token': 'true', 'tokenizer.ggml.unknown_token_id': '0', 'tokenizer.ggml.eos_token_id': '2', 'tokenizer.ggml.bos_token_id': '1', 'tokenizer.ggml.model': 'llama', 'llama.attention.head_count_kv': '8', 'llama.context_length': '4096', 'llama.attention.head_count': '32', 'llama.rope.freq_base': '10000.000000', 'llama.rope.dimension_count': '128', 'general.file_type': '30', 'llama.feed_forward_length': '14336', 'llama.embedding_length': '4096', 'llama.block_count': '48', 'general.architecture': 'llama', 'llama.attention.layer_norm_rms_epsilon': '0.000010', 'general.name': 'LLaMA v2'}
Using fallback chat format: llama-2
20:46:07-643695 INFO     Loaded "Fimbulvetr-11B-v2.i1-IQ4_XS.gguf" in 0.18 seconds.                    
20:46:07-644405 INFO     LOADER: "llama.cpp"                                                           
20:46:07-644761 INFO     TRUNCATION LENGTH: 4096                                                       
20:46:07-645104 INFO     INSTRUCTION TEMPLATE: "Alpaca"                                                
Output generated in 8.56 seconds (4.21 tokens/s, 36 tokens, context 901, seed 1918112572)              
from_string grammar:
phrasePattern ::= [*] [A-Z<U+00C0>-<U+00DC>] phrasePattern_3 phrasePattern_4 [*] 
phrasePattern_1 ::= phrasePattern_2 [ ] 
phrasePattern_2 ::= [A-Za-z'.?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] phrasePattern_2 | [A-Za-z'.?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] 
phrasePattern_3 ::= phrasePattern_1 phrasePattern_3 | 
phrasePattern_4 ::= [A-Za-z'.?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] phrasePattern_4 | [A-Za-z'.?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] 
quotedText ::= ["] [A-Z<U+00C0>-<U+00DC>] quotedText_6 quotedText_9 ["] 
quotedText_6 ::= [A-Za-z'.*?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] quotedText_6 | 
quotedText_7 ::= [ ] quotedText_8 
quotedText_8 ::= [A-Za-z'.*?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] quotedText_8 | [A-Za-z'.*?!,:;-<U+00E0>-<U+00FC><U+00C0>-<U+00DC>0-9] 
quotedText_9 ::= quotedText_7 quotedText_9 | 
root ::= phrasePattern singleSpace quotedText singleSpace phrasePattern singleSpace quotedText singleSpace root_13 
singleSpace ::= [ ] 
root_12 ::= phrasePattern singleSpace quotedText singleSpace 
root_13 ::= root_12 | 

Llama.generate: prefix-match hit
libc++abi: terminating due to uncaught exception of type std::out_of_range: vector
/bin/sh: line 1:  9339 Abort trap: 6           python server.py
/Users/macbookpro/Documents/Projects/text-generation-webui/installer_files/env/lib/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

System Info

Macbook Pro M1 Max, 64GB Unified Memory, 32c Apple Silicon GPU
kunesj commented 3 months ago

I can confirm this bug is in v1.13, but not in v1.12.

kunesj commented 3 months ago

I think it's caused by this bug in llama-cpp-python. Fix for that is already merged, so using version 0.2.86 or newer might fix it.

BongoUnicorns commented 3 months ago

@kunesj is correct, it is related to the bug in llama-cpp-python. Upgrading the version to 0.2.88 in the conda prefix fixed it for me on v1.13; this version will need to be updated in the project

BongoUnicorns commented 2 months ago

As this was resolved with 1.14, I'm closing this.