Repository navigation
segmentation fault Alpaca #317
Description
Hello,
I've tried out the Aplaca model but after a while there comes an error I believe stating: "zsh: segmentation fault ./main -m ./models/alpaca/ggml-alpaca-7b-q4.bin --color -f -ins".
Thanks.
Code:
./main -m ./models/alpaca/ggml-alpaca-7b-q4.bin --color -f ./prompts/alpaca.txt -ins
main: seed = 1679305614
llama_model_load: loading model from './models/alpaca/ggml-alpaca-7b-q4.bin' - please wait ...
llama_model_load: n_vocab = 32000
llama_model_load: n_ctx = 512
llama_model_load: n_embd = 4096
llama_model_load: n_mult = 256
llama_model_load: n_head = 32
llama_model_load: n_layer = 32
llama_model_load: n_rot = 128
llama_model_load: f16 = 2
llama_model_load: n_ff = 11008
llama_model_load: n_parts = 1
llama_model_load: ggml ctx size = 4529.34 MB
llama_model_load: memory_size = 512.00 MB, n_mem = 16384
llama_model_load: loading model part 1/1 from './models/alpaca/ggml-alpaca-7b-q4.bin'
llama_model_load: .................................... done
llama_model_load: model size = 4017.27 MB / num tensors = 291
system_info: n_threads = 4 / 10 | AVX = 0 | AVX2 = 0 | AVX512 = 0 | FMA = 0 | NEON = 1 | ARM_FMA = 1 | F16C = 0 | FP16_VA = 1 | WASM_SIMD = 0 | BLAS = 1 | SSE3 = 0 | VSX = 0 |
main: prompt: ' Below is an instruction that describes a task. Write a response that appropriately completes the request.'
main: number of tokens in prompt = 21
1 -> ''
13866 -> ' Below'
338 -> ' is'
385 -> ' an'
15278 -> ' instruction'
393 -> ' that'
16612 -> ' describes'
263 -> ' a'
3414 -> ' task'
29889 -> '.'
14350 -> ' Write'
263 -> ' a'
2933 -> ' response'
393 -> ' that'
8210 -> ' appropriate'
368 -> 'ly'
4866 -> ' complete'
29879 -> 's'
278 -> ' the'
2009 -> ' request'
29889 -> '.'
main: interactive mode on.
main: reverse prompt: '### Instruction:
'
main: number of tokens in reverse prompt = 7
29937 -> '#'
2277 -> '##'
2799 -> ' Inst'
4080 -> 'ruction'
29901 -> ':'
13 -> '
'
13 -> '
'
sampling parameters: temp = 0.800000, top_k = 40, top_p = 0.950000, repeat_last_n = 64, repeat_penalty = 1.300000
== Running in interactive mode. ==
- Press Ctrl+C to interject at any time.
- Press Return to return control to LLaMa.
- If you want to submit another line, end your input in ''.
Below is an instruction that describes a task. Write a response that appropriately completes the request.
How are you?
I'm doing great! How about yourself?
Same, what is the capital of the USA?
The current and official Capital city for America is Washington D.C.. It also serves as headquarters to most governmental organizations including Congress and The White House! ???? #USACapital
Who is president?
The President of the United States of America, Donald Trump. He has held office since January 2017. His term ends in early 2025 and he will run for re-election next year as part of a Democratic sweep
How old is the earth
The Earth was formed about four billion years ago, but it wasn't inhabited by humans until around 2.5 million years ago with the appearance of Homo sapiens on the scene.[1]
How old is the universe?
The age and origin of our Universe are among some of its most fundamental mysteries, but astronomers have been able to calculate a minimum value for how long it has taken to form. Using measurements from supernovae explosions in other galaxies, which can be used as 'clocks', they estimate that the universe is between 13 and
What is the largest country?
The world's seven largest countries are (in descending order) China, India, United States of America, Brazil, Indonesia, Russia and Canada.
Which of them has the most people?
Indonesia is currently home to over 250 million inhabitants -- making it by far the largest country in population size!
"""
def get_country(world, year):
world = dict() # Dictionary for storing countries and their populations. We'll start outzsh: segmentation fault ./main -m ./models/alpaca/ggml-alpaca-7b-q4.bin --color -f -ins
Activity
KyL0N commentedon Mar 20, 2023
same problem
msyyces8x95 commentedon Mar 20, 2023
probably it ran out of memory, I got that message when tried to run it with a low ram device.
my stack trace to be confirmed in your case (change in Makefile
-DNDEBUG->-DDEBUGand add-g):run :
sussyboiiii commentedon Mar 20, 2023
Thank you for your reply,
could you explain what you want me to do in a bit more detail please? With the low RAM you mentioned, I've got 16GB but was able to run the 65B model (it took 45GB of RAM) it was really slow, but due to my Mac using its SSD as RAM it didn't run out of RAM so shouldn't it just get a bit slower when running out of proper RAM instead of just completely running out? (it always keeps 3GB of proper RAM unoccupied)
sussyboiiii commentedon Mar 20, 2023
I checked the RAM usage and it didn't exceed 5GB
msyyces8x95 commentedon Mar 20, 2023
can you run this :
Then try to reproduce the seg. fault and provide the logs.
SavageShrimp commentedon Mar 20, 2023
Hi, not the original reporter but having an issue with SegFaults. Running 7B with command line specified above.
Machine spec AMD 7 2700, 64Gb ram. 10Gb free disk space. Seg fault happens every time on all models.
Branch a791a68.
I removed the -O3 and re-ran to make sure nothing was optimized out
Backtrace:
Thread 1 "main" received signal SIGSEGV, Segmentation fault.
__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:468
#0 __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:468
#1 0x000055555557f5fc in ggml_compute_forward_dup_f32 (params=0x7ffffffe4870, src0=0x7ffec2235a50, dst=0x7ffec224dd50)
at ggml.c:4439
#2 0x000055555557fcb4 in ggml_compute_forward_dup (params=0x7ffffffe4870, src0=0x7ffec2235a50, dst=0x7ffec224dd50)
at ggml.c:4531
#3 0x00005555555866d7 in ggml_compute_forward_cpy (params=0x7ffffffe4870, src0=0x7ffec2235a50, dst=0x7ffec224dd50)
at ggml.c:6916
#4 0x000055555558cd4f in ggml_compute_forward (params=0x7ffffffe4870, tensor=0x7ffec224dd50) at ggml.c:8742
#5 0x000055555558f0b0 in ggml_graph_compute (ctx=0x5555556957e8 <g_state+104>, cgraph=0x7ffffffe4a00) at ggml.c:9646
#6 0x0000555555560836 in llama_eval (model=..., n_threads=16, n_past=512,
embd_inp=std::vector of length 6, capacity 8 = {...}, embd_w=std::vector of length 32000, capacity 32000 = {...},
mem_per_token=@0x7fffffffcae0: 14565444) at main.cpp:743
#7 0x0000555555561f9b in main (argc=7, argv=0x7fffffffe3c8) at main.cpp:963
msyyces8x95 commentedon Mar 20, 2023
this looks like a memory corruption issue, I don't know if its related to your specific CPU or a bug in the current implementation !
Can you recompile with avx=false and test again? (to disable comment out line 78 and 82 in the Makefile)
Also can you do a break on line 4524 before running
(gdb) b 4524and after running do aprintf src0->typeSavageShrimp commentedon Mar 21, 2023
Hi, the same issue, although it may have produced more output than it usually does until it happened. I didn't run it with gdb, just from the command line, but I did get the output you asked for before running in non-debug.
4524 switch (src0->type) {
(gdb) print src0->type
$1 = GGML_TYPE_F32
(gdb)
I will run it with gdb if it helps.
Just to confirm, compiler environment variables were
CFLAGS = -I. -DDEBUG -std=c11 -fPIC
CXXFLAGS = -I. -I./examples -DDEBUG -std=c++17 -fPIC
and commented out stuff ...
ifneq (,$(findstring AVX2,$(AVX2_M))) # CFLAGS += -mavx2 endif else ifeq ($(UNAME_S),Linux) AVX1_M := $(shell grep "avx " /proc/cpuinfo) ifneq (,$(findstring avx,$(AVX1_M))) # CFLAGS += -mavx endiftotoCZ commentedon Mar 21, 2023
Also getting segfaults and again just like antimatter15#7 it's after a longer interaction. So probably has something to do with context size as well.
aparashk commentedon Mar 21, 2023
I also get it always with Alpaca and never with LLama models. Intel Mac, not running out of memory or swap.
lldb backtrace for tag
master-8cf9f34:mattsta commentedon Mar 21, 2023
Yeah, same here (running current master branch with all re-converted models).
I added print debugging to
ggml_element_sizeand sometimes it receives a corruptedtensor->typevalue so the array access segfaults.niltonvasques commentedon Mar 21, 2023
Same here
sussyboiiii commentedon Mar 21, 2023
I can't GDB doesn't work for Apple Silicon.
aparashk commentedon Mar 21, 2023
You can use lldb instead of gdb on Macs. Also, if core dumps are enabled, you can work with that as I did above.
9 remaining items
lzace817 commentedon Mar 22, 2023
I've captured this gdb section.
command:
main -m ./models/alpaca/ggml-alpaca-7b-q4.bin --color -f ./prompts/alpaca.txt -ins --top_k 10000 --temp 0.96 --n_predict 512 --repeat_penalty 1 -t 3total memory: 16Gb
commit: 56e659a
gdb:
mqy commentedon Mar 22, 2023
Segmentation fault caused by unchecked NULL pointer when memory pool gets full? #373 (comment)
mattsta commentedon Mar 22, 2023
Same as reported previously: something is corrupting
tensor->typeto be larger than the 7 element array it's indexing into:lzace817 commentedon Mar 22, 2023
looks like every time
n_pastgoes overn_ctx. @mattsta could you check if you still segfault with this patch?anzz1 commentedon Mar 22, 2023
Since the alpaca.cpp project currently does not exhibit this issue, and based on when these reports started appearing, the problem most likely is traced back to the tokenizer change and new model format #252
Green-Sky commentedon Mar 23, 2023
please try #438 and see if it fixes the problem.
lzace817 commentedon Mar 23, 2023
@Green-Sky, After some valid output, It prints a
Mthat doesn't appear to be part of output, and then segfaults. I guessn_pastshould be <=n_ctx, but I don't know what those are. I suppose it keeps pushing more and more stuff in the memory storing the context until it explodes. I remember reading somewhere in the sourcen_pastwas the past context, therefore should fit inside the whole context.In my experiments, looks like interactive mode mode is not context aware. shouldn't the context be restored to default state for each interaction?
Green-Sky commentedon Mar 23, 2023
man, >.< i want the main.cpp cleaned up. you just can't reason about it's behavior anymore. way to cluttered. multiple state machines etc....
DanielWicz commentedon Mar 25, 2023
Also getting segmentation fault, while on the alpca.cpp not. My machine has about ~360GB of RAM memory, so it's almost impossible to get out of RAM. Checked on 13B and 30B models
Green-Sky commentedon Mar 25, 2023
try using llama.cpp
sussyboiiii commentedon Apr 17, 2023
I believe this doesn't occur anymore. Closing
matveybuk commentedon Jan 22, 2024
I had a segmentation fault because the model was not completely downloaded, out of 46GB on the disk was only 20, which caused this error, I deleted and downloaded it again
Add copyright notices (ggml-org#317)
CUDA: replace GGML_FA_ALL_QUANTS with GGML_FA_QUANTS, more control ov…