char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Fathi Boudracommon: migrate the deprecated --mmap/--no-mmap to --load-mode (#26934)0177dcc73

char/aliceai-t5-moe
5.2 KiB219 linesraw
1::  MIT license
2::  Copyright (C) 2024 Intel Corporation
3::  SPDX-License-Identifier: MIT
4
5
6@echo off
7setlocal EnableExtensions EnableDelayedExpansion
8
9REM MIT license
10REM Copyright (C) 2024 Intel Corporation
11REM SPDX-License-Identifier: MIT
12
13set "BIN_FILE=.\build\bin\llama-completion.exe"
14set "SEED=0"
15set "GPUS_SETTING="
16
17set "INPUT_PROMPT=Building a website can be done in 10 simple steps:^nStep 1:"
18set "MODEL_FILE=..\models\llama-2-7b.Q4_0.gguf"
19set "NGL=99"
20set "CONTEXT=4096"
21set "GGML_SYCL_DEVICE=-1"
22set "SYCL_DEVICES=SYCL0"
23set "SPLIT_MODE=layer"
24set "LOG_VERBOSE=3"
25
26if "%~1"=="" goto after_args
27
28:parse_args
29if "%~1"=="" goto after_args
30
31if /I "%~1"=="-c" (
32  if "%~2"=="" goto missing_value
33  set "CONTEXT=%~2"
34  shift
35  shift
36  goto parse_args
37)
38if /I "%~1"=="--context" (
39  if "%~2"=="" goto missing_value
40  set "CONTEXT=%~2"
41  shift
42  shift
43  goto parse_args
44)
45
46if /I "%~1"=="-d" (
47  if "%~2"=="" goto missing_value
48  set "SYCL_DEVICES=%~2"
49  shift
50  shift
51  goto parse_args
52)
53if /I "%~1"=="--device" (
54  if "%~2"=="" goto missing_value
55  set "SYCL_DEVICES=%~2"
56  shift
57  shift
58  goto parse_args
59)
60
61if /I "%~1"=="-p" (
62  if "%~2"=="" goto missing_value
63  set "INPUT_PROMPT=%~2"
64  shift
65  shift
66  goto parse_args
67)
68if /I "%~1"=="--promote" (
69  if "%~2"=="" goto missing_value
70  set "INPUT_PROMPT=%~2"
71  shift
72  shift
73  goto parse_args
74)
75
76if /I "%~1"=="-m" (
77  if "%~2"=="" goto missing_value
78  set "MODEL_FILE=%~2"
79  shift
80  shift
81  goto parse_args
82)
83if /I "%~1"=="--model" (
84  if "%~2"=="" goto missing_value
85  set "MODEL_FILE=%~2"
86  shift
87  shift
88  goto parse_args
89)
90
91if /I "%~1"=="-mg" (
92  if "%~2"=="" goto missing_value
93  set "GGML_SYCL_DEVICE=%~2"
94  set "SPLIT_MODE=none"
95  shift
96  shift
97  goto parse_args
98)
99if /I "%~1"=="--main-gpu" (
100  if "%~2"=="" goto missing_value
101  set "GGML_SYCL_DEVICE=%~2"
102  set "SPLIT_MODE=none"
103  shift
104  shift
105  goto parse_args
106)
107
108if /I "%~1"=="-sm" (
109  if "%~2"=="" goto missing_value
110  set "SPLIT_MODE=%~2"
111  shift
112  shift
113  goto parse_args
114)
115if /I "%~1"=="--split-mode" (
116  if "%~2"=="" goto missing_value
117  set "SPLIT_MODE=%~2"
118  shift
119  shift
120  goto parse_args
121)
122
123if /I "%~1"=="-ngl" (
124  if "%~2"=="" goto missing_value
125  set "NGL=%~2"
126  shift
127  shift
128  goto parse_args
129)
130if /I "%~1"=="--n-gpu-layers" (
131  if "%~2"=="" goto missing_value
132  set "NGL=%~2"
133  shift
134  shift
135  goto parse_args
136)
137
138if /I "%~1"=="-lv" (
139  if "%~2"=="" goto missing_value
140  set "LOG_VERBOSE=%~2"
141  shift
142  shift
143  goto parse_args
144)
145if /I "%~1"=="--log-verbosity" (
146  if "%~2"=="" goto missing_value
147  set "LOG_VERBOSE=%~2"
148  shift
149  shift
150  goto parse_args
151)
152
153if /I "%~1"=="-h" goto help
154if /I "%~1"=="--help" goto help
155
156echo Invalid option: %~1
157exit /b 1
158
159:missing_value
160echo Missing value for option: %~1
161exit /b 1
162
163:help
164echo Usage: %~n0 [OPTIONS]
165echo.
166echo This script processes files with specified options.
167echo.
168echo Options:
169echo   -h, --help    Display this help message and exit.
170echo   -d, --device ^<value^>    Set SYCL devices (default: SYCL0).
171echo   -c, --context ^<value^>    Set context length. Bigger need more memory.
172echo   -p, --promote ^<value^>    Prompt to start generation with.
173echo   -m, --model   ^<value^>    Full model file path.
174echo   -mg,--main-gpu ^<value^>   Set main GPU ID (0 - n) for single GPU mode.
175echo   -sm,--split-mode ^<value^> How to split the model across multiple GPUs, one of:
176echo                             - none: use one GPU only
177echo                             - layer (default): split layers and KV across GPUs
178echo                             - row: split rows across GPUs
179echo   -ngl,--n-gpu-layers ^<value^>  Max. number of layers to store in VRAM (default: -1)
180echo   -lv,--log-verbosity ^<value^>  Set the verbosity threshold. Messages with a higher verbosity will be
181echo                                ignored. Values:
182echo                                 - 0: generic output
183echo                                 - 1: error
184echo                                 - 2: warning
185echo                                 - 3: info
186echo                                 - 4: debug
187exit /b 0
188
189:after_args
190
191REM In Windows CMD, source is not available; call oneAPI setvars if present.
192if exist "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" (
193  call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat" >nul
194) else (
195  echo Warning: oneAPI setvars.bat not found. Continuing without environment setup.
196)
197
198REM Support malloc device memory more than 4GB.
199set "UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=1"
200echo UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS=%UR_L0_ENABLE_RELAXED_ALLOCATION_LIMITS%
201
202echo ONEAPI_DEVICE_SELECTOR=%ONEAPI_DEVICE_SELECTOR%
203
204if not "%GGML_SYCL_DEVICE%"=="-1" (
205  echo Use %GGML_SYCL_DEVICE% as main GPU
206  REM Use single GPU only.
207  set "GPUS_SETTING=-mg %GGML_SYCL_DEVICE% -sm %SPLIT_MODE%"
208  )
209else (
210  echo Use Intel GPUs: %SYCL_DEVICES%
211  set "GPUS_SETTING=-sm %SPLIT_MODE%"
212)
213
214echo run cmd: ZES_ENABLE_SYSMAN=1 %BIN_FILE% -m %MODEL_FILE% -no-cnv -p "%INPUT_PROMPT%" -n 200 -e -ngl %NGL% -s %SEED% -c %CONTEXT% %GPUS_SETTING% -lv %LOG_VERBOSE% --device %SYCL_DEVICES% --load-mode auto
215set "ZES_ENABLE_SYSMAN=1"
216%BIN_FILE% -m "%MODEL_FILE%" -no-cnv -p "%INPUT_PROMPT%" -n 200 -e -ngl %NGL% -s %SEED% -c %CONTEXT% %GPUS_SETTING% -lv %LOG_VERBOSE% --device "%SYCL_DEVICES%" --load-mode auto
217
218endlocal
219