llama-cpp-python-win 0.3.16__cp314-cp314-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. bin/convert_hf_to_gguf.py +8751 -0
  2. bin/ggml-base.dll +0 -0
  3. bin/ggml-cpu.dll +0 -0
  4. bin/ggml.dll +0 -0
  5. bin/llama-mtmd-cli.exe +0 -0
  6. bin/llama.dll +0 -0
  7. bin/mtmd.dll +0 -0
  8. include/ggml-alloc.h +76 -0
  9. include/ggml-backend.h +354 -0
  10. include/ggml-blas.h +25 -0
  11. include/ggml-cann.h +123 -0
  12. include/ggml-cpp.h +39 -0
  13. include/ggml-cpu.h +145 -0
  14. include/ggml-cuda.h +47 -0
  15. include/ggml-metal.h +66 -0
  16. include/ggml-opt.h +256 -0
  17. include/ggml-rpc.h +33 -0
  18. include/ggml-sycl.h +49 -0
  19. include/ggml-vulkan.h +29 -0
  20. include/ggml-webgpu.h +19 -0
  21. include/ggml.h +2467 -0
  22. include/gguf.h +202 -0
  23. include/llama-cpp.h +30 -0
  24. include/llama.h +1482 -0
  25. include/mtmd-helper.h +91 -0
  26. include/mtmd.h +298 -0
  27. lib/cmake/ggml/ggml-config.cmake +328 -0
  28. lib/cmake/ggml/ggml-version.cmake +65 -0
  29. lib/cmake/llama/llama-config.cmake +54 -0
  30. lib/cmake/llama/llama-version.cmake +65 -0
  31. lib/ggml-base.lib +0 -0
  32. lib/ggml-cpu.lib +0 -0
  33. lib/ggml.lib +0 -0
  34. lib/llama.lib +0 -0
  35. lib/mtmd.lib +0 -0
  36. lib/pkgconfig/llama.pc +10 -0
  37. llama_cpp/__init__.py +4 -0
  38. llama_cpp/_ctypes_extensions.py +131 -0
  39. llama_cpp/_ggml.py +12 -0
  40. llama_cpp/_internals.py +856 -0
  41. llama_cpp/_logger.py +47 -0
  42. llama_cpp/_utils.py +78 -0
  43. llama_cpp/lib/ggml-base.dll +0 -0
  44. llama_cpp/lib/ggml-base.lib +0 -0
  45. llama_cpp/lib/ggml-cpu.dll +0 -0
  46. llama_cpp/lib/ggml-cpu.lib +0 -0
  47. llama_cpp/lib/ggml.dll +0 -0
  48. llama_cpp/lib/ggml.lib +0 -0
  49. llama_cpp/lib/llama.dll +0 -0
  50. llama_cpp/lib/llama.lib +0 -0
  51. llama_cpp/lib/mtmd.dll +0 -0
  52. llama_cpp/lib/mtmd.lib +0 -0
  53. llama_cpp/llama.py +2422 -0
  54. llama_cpp/llama_cache.py +155 -0
  55. llama_cpp/llama_chat_format.py +3962 -0
  56. llama_cpp/llama_cpp.py +4374 -0
  57. llama_cpp/llama_grammar.py +953 -0
  58. llama_cpp/llama_speculative.py +64 -0
  59. llama_cpp/llama_tokenizer.py +120 -0
  60. llama_cpp/llama_types.py +316 -0
  61. llama_cpp/llava_cpp.py +158 -0
  62. llama_cpp/mtmd_cpp.py +280 -0
  63. llama_cpp/py.typed +0 -0
  64. llama_cpp/server/__init__.py +0 -0
  65. llama_cpp/server/__main__.py +100 -0
  66. llama_cpp/server/app.py +597 -0
  67. llama_cpp/server/cli.py +97 -0
  68. llama_cpp/server/errors.py +212 -0
  69. llama_cpp/server/model.py +312 -0
  70. llama_cpp/server/settings.py +240 -0
  71. llama_cpp/server/types.py +316 -0
  72. llama_cpp_python_win-0.3.16.dist-info/METADATA +856 -0
  73. llama_cpp_python_win-0.3.16.dist-info/RECORD +75 -0
  74. llama_cpp_python_win-0.3.16.dist-info/WHEEL +5 -0
  75. llama_cpp_python_win-0.3.16.dist-info/licenses/LICENSE.md +9 -0
@@ -0,0 +1,328 @@
1
+
2
+ ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
3
+ ####### Any changes to this file will be overwritten by the next CMake run ####
4
+ ####### The input file was ggml-config.cmake.in ########
5
+
6
+ get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
7
+
8
+ macro(set_and_check _var _file)
9
+ set(${_var} "${_file}")
10
+ if(NOT EXISTS "${_file}")
11
+ message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
12
+ endif()
13
+ endmacro()
14
+
15
+ macro(check_required_components _NAME)
16
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
17
+ if(NOT ${_NAME}_${comp}_FOUND)
18
+ if(${_NAME}_FIND_REQUIRED_${comp})
19
+ set(${_NAME}_FOUND FALSE)
20
+ endif()
21
+ endif()
22
+ endforeach()
23
+ endmacro()
24
+
25
+ ####################################################################################
26
+
27
+
28
+ ####### Expanded from @GGML_VARIABLES_EXPANED@ by configure_package_config_file() #######
29
+ ####### Any changes to this file will be overwritten by the next CMake run #######
30
+
31
+ set(GGML_ACCELERATE "ON")
32
+ set(GGML_ALL_WARNINGS "ON")
33
+ set(GGML_ALL_WARNINGS_3RD_PARTY "OFF")
34
+ set(GGML_AVAILABLE_BACKENDS "ggml-cpu")
35
+ set(GGML_AVX "OFF")
36
+ set(GGML_AVX2 "OFF")
37
+ set(GGML_AVX512 "OFF")
38
+ set(GGML_AVX512_BF16 "OFF")
39
+ set(GGML_AVX512_VBMI "OFF")
40
+ set(GGML_AVX512_VNNI "OFF")
41
+ set(GGML_AVX_VNNI "OFF")
42
+ set(GGML_BACKEND_DIR "")
43
+ set(GGML_BACKEND_DL "OFF")
44
+ set(GGML_BLAS "OFF")
45
+ set(GGML_BLAS_DEFAULT "OFF")
46
+ set(GGML_BLAS_VENDOR "Generic")
47
+ set(GGML_BLAS_VENDOR_DEFAULT "Generic")
48
+ set(GGML_BMI2 "OFF")
49
+ set(GGML_BUILD_COMMIT "4227c9b")
50
+ set(GGML_BUILD_EXAMPLES "OFF")
51
+ set(GGML_BUILD_NUMBER "1")
52
+ set(GGML_BUILD_TESTS "OFF")
53
+ set(GGML_CCACHE "ON")
54
+ set(GGML_CCACHE_FOUND "GGML_CCACHE_FOUND-NOTFOUND")
55
+ set(GGML_CPU "ON")
56
+ set(GGML_CPU_ALL_VARIANTS "OFF")
57
+ set(GGML_CPU_ARM_ARCH "")
58
+ set(GGML_CPU_HBM "OFF")
59
+ set(GGML_CPU_KLEIDIAI "OFF")
60
+ set(GGML_CPU_POWERPC_CPUTYPE "")
61
+ set(GGML_CPU_REPACK "ON")
62
+ set(GGML_CUDA "OFF")
63
+ set(GGML_CUDA_COMPRESSION_MODE "size")
64
+ set(GGML_CUDA_F16 "OFF")
65
+ set(GGML_CUDA_FA "ON")
66
+ set(GGML_CUDA_FA_ALL_QUANTS "OFF")
67
+ set(GGML_CUDA_FORCE_CUBLAS "OFF")
68
+ set(GGML_CUDA_FORCE_MMQ "OFF")
69
+ set(GGML_CUDA_GRAPHS "ON")
70
+ set(GGML_CUDA_GRAPHS_DEFAULT "ON")
71
+ set(GGML_CUDA_NO_PEER_COPY "OFF")
72
+ set(GGML_CUDA_NO_VMM "OFF")
73
+ set(GGML_CUDA_PEER_MAX_BATCH_SIZE "128")
74
+ set(GGML_FATAL_WARNINGS "OFF")
75
+ set(GGML_GPROF "OFF")
76
+ set(GGML_HIP "OFF")
77
+ set(GGML_HIP_EXPORT_METRICS "OFF")
78
+ set(GGML_HIP_FORCE_ROCWMMA_FATTN_GFX12 "OFF")
79
+ set(GGML_HIP_GRAPHS "OFF")
80
+ set(GGML_HIP_MMQ_MFMA "ON")
81
+ set(GGML_HIP_NO_VMM "ON")
82
+ set(GGML_HIP_ROCWMMA_FATTN "OFF")
83
+ set(GGML_LASX "ON")
84
+ set(GGML_LLAMAFILE "ON")
85
+ set(GGML_LLAMAFILE_DEFAULT "ON")
86
+ set(GGML_LSX "ON")
87
+ set(GGML_LTO "OFF")
88
+ set(GGML_METAL "OFF")
89
+ set(GGML_METAL_DEFAULT "OFF")
90
+ set(GGML_METAL_EMBED_LIBRARY "OFF")
91
+ set(GGML_METAL_MACOSX_VERSION_MIN "")
92
+ set(GGML_METAL_NDEBUG "OFF")
93
+ set(GGML_METAL_SHADER_DEBUG "OFF")
94
+ set(GGML_METAL_STD "")
95
+ set(GGML_METAL_USE_BF16 "OFF")
96
+ set(GGML_MUSA "OFF")
97
+ set(GGML_MUSA_GRAPHS "OFF")
98
+ set(GGML_MUSA_MUDNN_COPY "OFF")
99
+ set(GGML_NATIVE "ON")
100
+ set(GGML_NATIVE_DEFAULT "ON")
101
+ set(GGML_NNPA "OFF")
102
+ set(GGML_OPENCL "OFF")
103
+ set(GGML_OPENCL_EMBED_KERNELS "ON")
104
+ set(GGML_OPENCL_PROFILING "OFF")
105
+ set(GGML_OPENCL_TARGET_VERSION "300")
106
+ set(GGML_OPENCL_USE_ADRENO_KERNELS "ON")
107
+ set(GGML_OPENMP "ON")
108
+ set(GGML_OPENMP_ENABLED "ON")
109
+ set(GGML_PUBLIC_HEADERS "include/ggml.h;include/ggml-cpu.h;include/ggml-alloc.h;include/ggml-backend.h;include/ggml-blas.h;include/ggml-cann.h;include/ggml-cpp.h;include/ggml-cuda.h;include/ggml-opt.h;include/ggml-metal.h;include/ggml-rpc.h;include/ggml-sycl.h;include/ggml-vulkan.h;include/ggml-webgpu.h;include/gguf.h")
110
+ set(GGML_RPC "OFF")
111
+ set(GGML_RVV "ON")
112
+ set(GGML_RV_ZFH "OFF")
113
+ set(GGML_SANITIZE_ADDRESS "OFF")
114
+ set(GGML_SANITIZE_THREAD "OFF")
115
+ set(GGML_SANITIZE_UNDEFINED "OFF")
116
+ set(GGML_SCCACHE_FOUND "GGML_SCCACHE_FOUND-NOTFOUND")
117
+ set(GGML_SCHED_MAX_COPIES "4")
118
+ set(GGML_SHARED_LIB "On")
119
+ set(GGML_SSE42 "OFF")
120
+ set(GGML_STANDALONE "OFF")
121
+ set(GGML_STATIC "OFF")
122
+ set(GGML_SYCL "OFF")
123
+ set(GGML_SYCL_DEVICE_ARCH "")
124
+ set(GGML_SYCL_DNN "ON")
125
+ set(GGML_SYCL_F16 "OFF")
126
+ set(GGML_SYCL_GRAPH "ON")
127
+ set(GGML_SYCL_TARGET "INTEL")
128
+ set(GGML_VULKAN "OFF")
129
+ set(GGML_VULKAN_CHECK_RESULTS "OFF")
130
+ set(GGML_VULKAN_DEBUG "OFF")
131
+ set(GGML_VULKAN_MEMORY_DEBUG "OFF")
132
+ set(GGML_VULKAN_RUN_TESTS "OFF")
133
+ set(GGML_VULKAN_SHADERS_GEN_TOOLCHAIN "")
134
+ set(GGML_VULKAN_SHADER_DEBUG_INFO "OFF")
135
+ set(GGML_VULKAN_VALIDATE "OFF")
136
+ set(GGML_VXE "ON")
137
+ set(GGML_WEBGPU "OFF")
138
+ set(GGML_WEBGPU_DEBUG "OFF")
139
+ set(GGML_XTHEADVECTOR "OFF")
140
+
141
+
142
+ # Find all dependencies before creating any target.
143
+ include(CMakeFindDependencyMacro)
144
+ find_dependency(Threads)
145
+ if (NOT GGML_SHARED_LIB)
146
+ set(GGML_CPU_INTERFACE_LINK_LIBRARIES "")
147
+ set(GGML_CPU_INTERFACE_LINK_OPTIONS "")
148
+
149
+ if (APPLE AND GGML_ACCELERATE)
150
+ find_library(ACCELERATE_FRAMEWORK Accelerate)
151
+ if(NOT ACCELERATE_FRAMEWORK)
152
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0)
153
+ return()
154
+ endif()
155
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES ${ACCELERATE_FRAMEWORK})
156
+ endif()
157
+
158
+ if (GGML_OPENMP_ENABLED)
159
+ find_dependency(OpenMP)
160
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES OpenMP::OpenMP_C OpenMP::OpenMP_CXX)
161
+ endif()
162
+
163
+ if (GGML_CPU_HBM)
164
+ find_library(memkind memkind)
165
+ if(NOT memkind)
166
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0)
167
+ return()
168
+ endif()
169
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES memkind)
170
+ endif()
171
+
172
+ if (GGML_BLAS)
173
+ find_dependency(BLAS)
174
+ list(APPEND GGML_BLAS_INTERFACE_LINK_LIBRARIES ${BLAS_LIBRARIES})
175
+ list(APPEND GGML_BLAS_INTERFACE_LINK_OPTIONS ${BLAS_LINKER_FLAGS})
176
+ endif()
177
+
178
+ if (GGML_CUDA)
179
+ set(GGML_CUDA_INTERFACE_LINK_LIBRARIES "")
180
+ find_dependency(CUDAToolkit)
181
+ if (GGML_STATIC)
182
+ list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:CUDA::cudart_static>)
183
+ if (WIN32)
184
+ list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:CUDA::cublas> $<LINK_ONLY:CUDA::cublasLt>)
185
+ else()
186
+ list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:CUDA::cublas_static> $<LINK_ONLY:CUDA::cublasLt_static>)
187
+ endif()
188
+ endif()
189
+ if (NOT GGML_CUDA_NO_VMM)
190
+ list(APPEND GGML_CUDA_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:CUDA::cuda_driver>)
191
+ endif()
192
+ endif()
193
+
194
+ if (GGML_METAL)
195
+ find_library(FOUNDATION_LIBRARY Foundation)
196
+ find_library(METAL_FRAMEWORK Metal)
197
+ find_library(METALKIT_FRAMEWORK MetalKit)
198
+ if(NOT FOUNDATION_LIBRARY OR NOT METAL_FRAMEWORK OR NOT METALKIT_FRAMEWORK)
199
+ set(${CMAKE_FIND_PACKAGE_NAME}_FOUND 0)
200
+ return()
201
+ endif()
202
+ set(GGML_METAL_INTERFACE_LINK_LIBRARIES
203
+ ${FOUNDATION_LIBRARY} ${METAL_FRAMEWORK} ${METALKIT_FRAMEWORK})
204
+ endif()
205
+
206
+ if (GGML_OPENCL)
207
+ find_dependency(OpenCL)
208
+ set(GGML_OPENCL_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:OpenCL::OpenCL>)
209
+ endif()
210
+
211
+ if (GGML_VULKAN)
212
+ find_dependency(Vulkan)
213
+ set(GGML_VULKAN_INTERFACE_LINK_LIBRARIES $<LINK_ONLY:Vulkan::Vulkan>)
214
+ endif()
215
+
216
+ if (GGML_HIP)
217
+ find_dependency(hip)
218
+ find_dependency(hipblas)
219
+ find_dependency(rocblas)
220
+ set(GGML_HIP_INTERFACE_LINK_LIBRARIES hip::host roc::rocblas roc::hipblas)
221
+ endif()
222
+
223
+ if (GGML_SYCL)
224
+ set(GGML_SYCL_INTERFACE_LINK_LIBRARIES "")
225
+ find_package(DNNL)
226
+ if (${DNNL_FOUND} AND GGML_SYCL_TARGET STREQUAL "INTEL")
227
+ list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES DNNL::dnnl)
228
+ endif()
229
+ if (WIN32)
230
+ find_dependency(IntelSYCL)
231
+ find_dependency(MKL)
232
+ list(APPEND GGML_SYCL_INTERFACE_LINK_LIBRARIES IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
233
+ endif()
234
+ endif()
235
+ endif()
236
+
237
+ set_and_check(GGML_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
238
+ set_and_check(GGML_LIB_DIR "${PACKAGE_PREFIX_DIR}/lib")
239
+ #set_and_check(GGML_BIN_DIR "${PACKAGE_PREFIX_DIR}/bin")
240
+
241
+ if(NOT TARGET ggml::ggml)
242
+ find_package(Threads REQUIRED)
243
+
244
+ find_library(GGML_LIBRARY ggml
245
+ REQUIRED
246
+ HINTS ${GGML_LIB_DIR}
247
+ NO_CMAKE_FIND_ROOT_PATH)
248
+
249
+ add_library(ggml::ggml UNKNOWN IMPORTED)
250
+ set_target_properties(ggml::ggml
251
+ PROPERTIES
252
+ IMPORTED_LOCATION "${GGML_LIBRARY}")
253
+
254
+ find_library(GGML_BASE_LIBRARY ggml-base
255
+ REQUIRED
256
+ HINTS ${GGML_LIB_DIR}
257
+ NO_CMAKE_FIND_ROOT_PATH)
258
+
259
+ add_library(ggml::ggml-base UNKNOWN IMPORTED)
260
+ set_target_properties(ggml::ggml-base
261
+ PROPERTIES
262
+ IMPORTED_LOCATION "${GGML_BASE_LIBRARY}")
263
+
264
+ set(_ggml_all_targets "")
265
+ if (NOT GGML_BACKEND_DL)
266
+ foreach(_ggml_backend ${GGML_AVAILABLE_BACKENDS})
267
+ string(REPLACE "-" "_" _ggml_backend_pfx "${_ggml_backend}")
268
+ string(TOUPPER "${_ggml_backend_pfx}" _ggml_backend_pfx)
269
+
270
+ find_library(${_ggml_backend_pfx}_LIBRARY ${_ggml_backend}
271
+ REQUIRED
272
+ HINTS ${GGML_LIB_DIR}
273
+ NO_CMAKE_FIND_ROOT_PATH)
274
+
275
+ message(STATUS "Found ${${_ggml_backend_pfx}_LIBRARY}")
276
+
277
+ add_library(ggml::${_ggml_backend} UNKNOWN IMPORTED)
278
+ set_target_properties(ggml::${_ggml_backend}
279
+ PROPERTIES
280
+ INTERFACE_INCLUDE_DIRECTORIES "${GGML_INCLUDE_DIR}"
281
+ IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
282
+ IMPORTED_LOCATION "${${_ggml_backend_pfx}_LIBRARY}"
283
+ INTERFACE_COMPILE_FEATURES c_std_90
284
+ POSITION_INDEPENDENT_CODE ON)
285
+
286
+ string(REGEX MATCH "^ggml-cpu" is_cpu_variant "${_ggml_backend}")
287
+ if(is_cpu_variant)
288
+ list(APPEND GGML_CPU_INTERFACE_LINK_LIBRARIES "ggml::ggml-base")
289
+ set_target_properties(ggml::${_ggml_backend}
290
+ PROPERTIES
291
+ INTERFACE_LINK_LIBRARIES "${GGML_CPU_INTERFACE_LINK_LIBRARIES}")
292
+
293
+ if(GGML_CPU_INTERFACE_LINK_OPTIONS)
294
+ set_target_properties(ggml::${_ggml_backend}
295
+ PROPERTIES
296
+ INTERFACE_LINK_OPTIONS "${GGML_CPU_INTERFACE_LINK_OPTIONS}")
297
+ endif()
298
+
299
+ else()
300
+ list(APPEND ${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES "ggml::ggml-base")
301
+ set_target_properties(ggml::${_ggml_backend}
302
+ PROPERTIES
303
+ INTERFACE_LINK_LIBRARIES "${${_ggml_backend_pfx}_INTERFACE_LINK_LIBRARIES}")
304
+
305
+ if(${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS)
306
+ set_target_properties(ggml::${_ggml_backend}
307
+ PROPERTIES
308
+ INTERFACE_LINK_OPTIONS "${${_ggml_backend_pfx}_INTERFACE_LINK_OPTIONS}")
309
+ endif()
310
+ endif()
311
+
312
+ list(APPEND _ggml_all_targets ggml::${_ggml_backend})
313
+ endforeach()
314
+ endif()
315
+
316
+ list(APPEND GGML_INTERFACE_LINK_LIBRARIES ggml::ggml-base "${_ggml_all_targets}")
317
+ set_target_properties(ggml::ggml
318
+ PROPERTIES
319
+ INTERFACE_LINK_LIBRARIES "${GGML_INTERFACE_LINK_LIBRARIES}")
320
+
321
+ add_library(ggml::all INTERFACE IMPORTED)
322
+ set_target_properties(ggml::all
323
+ PROPERTIES
324
+ INTERFACE_LINK_LIBRARIES "${_ggml_all_targets}")
325
+
326
+ endif()
327
+
328
+ check_required_components(ggml)
@@ -0,0 +1,65 @@
1
+ # This is a basic version file for the Config-mode of find_package().
2
+ # It is used by write_basic_package_version_file() as input file for configure_file()
3
+ # to create a version-file which can be installed along a config.cmake file.
4
+ #
5
+ # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6
+ # the requested version string are exactly the same and it sets
7
+ # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
8
+ # but only if the requested major version is the same as the current one.
9
+ # The variable CVF_VERSION must be set before calling configure_file().
10
+
11
+
12
+ set(PACKAGE_VERSION "0.0.1")
13
+
14
+ if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
15
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
16
+ else()
17
+
18
+ if("0.0.1" MATCHES "^([0-9]+)\\.")
19
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
20
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
21
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
22
+ endif()
23
+ else()
24
+ set(CVF_VERSION_MAJOR "0.0.1")
25
+ endif()
26
+
27
+ if(PACKAGE_FIND_VERSION_RANGE)
28
+ # both endpoints of the range must have the expected major version
29
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
30
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
31
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
32
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
33
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
34
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
35
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
36
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
37
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
38
+ else()
39
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
40
+ endif()
41
+ else()
42
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
43
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
44
+ else()
45
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
46
+ endif()
47
+
48
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
49
+ set(PACKAGE_VERSION_EXACT TRUE)
50
+ endif()
51
+ endif()
52
+ endif()
53
+
54
+
55
+ # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
56
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
57
+ return()
58
+ endif()
59
+
60
+ # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
61
+ if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
62
+ math(EXPR installedBits "8 * 8")
63
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
64
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
65
+ endif()
@@ -0,0 +1,54 @@
1
+ set(LLAMA_VERSION 0.0.1)
2
+ set(LLAMA_BUILD_COMMIT 4227c9b)
3
+ set(LLAMA_BUILD_NUMBER 1)
4
+ set(LLAMA_SHARED_LIB On)
5
+
6
+
7
+ ####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
8
+ ####### Any changes to this file will be overwritten by the next CMake run ####
9
+ ####### The input file was llama-config.cmake.in ########
10
+
11
+ get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)
12
+
13
+ macro(set_and_check _var _file)
14
+ set(${_var} "${_file}")
15
+ if(NOT EXISTS "${_file}")
16
+ message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
17
+ endif()
18
+ endmacro()
19
+
20
+ macro(check_required_components _NAME)
21
+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
22
+ if(NOT ${_NAME}_${comp}_FOUND)
23
+ if(${_NAME}_FIND_REQUIRED_${comp})
24
+ set(${_NAME}_FOUND FALSE)
25
+ endif()
26
+ endif()
27
+ endforeach()
28
+ endmacro()
29
+
30
+ ####################################################################################
31
+
32
+ set_and_check(LLAMA_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
33
+ set_and_check(LLAMA_LIB_DIR "${PACKAGE_PREFIX_DIR}/lib")
34
+ set_and_check(LLAMA_BIN_DIR "${PACKAGE_PREFIX_DIR}/bin")
35
+
36
+ find_package(ggml REQUIRED HINTS ${LLAMA_LIB_DIR}/cmake)
37
+
38
+ find_library(llama_LIBRARY llama
39
+ REQUIRED
40
+ HINTS ${LLAMA_LIB_DIR}
41
+ NO_CMAKE_FIND_ROOT_PATH
42
+ )
43
+
44
+ add_library(llama UNKNOWN IMPORTED)
45
+ set_target_properties(llama
46
+ PROPERTIES
47
+ INTERFACE_INCLUDE_DIRECTORIES "${LLAMA_INCLUDE_DIR}"
48
+ INTERFACE_LINK_LIBRARIES "ggml::ggml;ggml::ggml-base;"
49
+ IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
50
+ IMPORTED_LOCATION "${llama_LIBRARY}"
51
+ INTERFACE_COMPILE_FEATURES c_std_90
52
+ POSITION_INDEPENDENT_CODE ON)
53
+
54
+ check_required_components(Llama)
@@ -0,0 +1,65 @@
1
+ # This is a basic version file for the Config-mode of find_package().
2
+ # It is used by write_basic_package_version_file() as input file for configure_file()
3
+ # to create a version-file which can be installed along a config.cmake file.
4
+ #
5
+ # The created file sets PACKAGE_VERSION_EXACT if the current version string and
6
+ # the requested version string are exactly the same and it sets
7
+ # PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
8
+ # but only if the requested major version is the same as the current one.
9
+ # The variable CVF_VERSION must be set before calling configure_file().
10
+
11
+
12
+ set(PACKAGE_VERSION "0.0.1")
13
+
14
+ if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
15
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
16
+ else()
17
+
18
+ if("0.0.1" MATCHES "^([0-9]+)\\.")
19
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
20
+ if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
21
+ string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
22
+ endif()
23
+ else()
24
+ set(CVF_VERSION_MAJOR "0.0.1")
25
+ endif()
26
+
27
+ if(PACKAGE_FIND_VERSION_RANGE)
28
+ # both endpoints of the range must have the expected major version
29
+ math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
30
+ if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
31
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
32
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
33
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
34
+ elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
35
+ AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
36
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
37
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
38
+ else()
39
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
40
+ endif()
41
+ else()
42
+ if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
43
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
44
+ else()
45
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
46
+ endif()
47
+
48
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
49
+ set(PACKAGE_VERSION_EXACT TRUE)
50
+ endif()
51
+ endif()
52
+ endif()
53
+
54
+
55
+ # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
56
+ if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
57
+ return()
58
+ endif()
59
+
60
+ # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
61
+ if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
62
+ math(EXPR installedBits "8 * 8")
63
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
64
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
65
+ endif()
lib/ggml-base.lib ADDED
Binary file
lib/ggml-cpu.lib ADDED
Binary file
lib/ggml.lib ADDED
Binary file
lib/llama.lib ADDED
Binary file
lib/mtmd.lib ADDED
Binary file
lib/pkgconfig/llama.pc ADDED
@@ -0,0 +1,10 @@
1
+ prefix=C:/Users/Srina/AppData/Local/Temp/tmpnzp1y_vn/wheel/platlib
2
+ exec_prefix=C:/Users/Srina/AppData/Local/Temp/tmpnzp1y_vn/wheel/platlib
3
+ libdir=C:/Users/Srina/AppData/Local/Temp/tmpnzp1y_vn/wheel/platlib/lib
4
+ includedir=C:/Users/Srina/AppData/Local/Temp/tmpnzp1y_vn/wheel/platlib/include
5
+
6
+ Name: llama
7
+ Description: Port of Facebook's LLaMA model in C/C++
8
+ Version: 0.0.1
9
+ Libs: -L${libdir} -lggml -lggml-base -lllama
10
+ Cflags: -I${includedir}
llama_cpp/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .llama_cpp import *
2
+ from .llama import *
3
+
4
+ __version__ = "0.3.16"
@@ -0,0 +1,131 @@
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ import os
5
+ import ctypes
6
+ import functools
7
+ import pathlib
8
+
9
+ from typing import (
10
+ Any,
11
+ Callable,
12
+ List,
13
+ Union,
14
+ Optional,
15
+ TYPE_CHECKING,
16
+ TypeVar,
17
+ Generic,
18
+ )
19
+ from typing_extensions import TypeAlias
20
+
21
+
22
+ # Load the library
23
+ def load_shared_library(lib_base_name: str, base_path: pathlib.Path):
24
+ """Platform independent shared library loader"""
25
+ # Searching for the library in the current directory under the name "libllama" (default name
26
+ # for llamacpp) and "llama" (default name for this repo)
27
+ lib_paths: List[pathlib.Path] = []
28
+ # Determine the file extension based on the platform
29
+ if sys.platform.startswith("linux") or sys.platform.startswith("freebsd"):
30
+ lib_paths += [
31
+ base_path / f"lib{lib_base_name}.so",
32
+ ]
33
+ elif sys.platform == "darwin":
34
+ lib_paths += [
35
+ base_path / f"lib{lib_base_name}.so",
36
+ base_path / f"lib{lib_base_name}.dylib",
37
+ ]
38
+ elif sys.platform == "win32":
39
+ lib_paths += [
40
+ base_path / f"{lib_base_name}.dll",
41
+ base_path / f"lib{lib_base_name}.dll",
42
+ ]
43
+ else:
44
+ raise RuntimeError("Unsupported platform")
45
+
46
+ cdll_args = dict() # type: ignore
47
+
48
+ # Add the library directory to the DLL search path on Windows (if needed)
49
+ if sys.platform == "win32":
50
+ os.add_dll_directory(str(base_path))
51
+ os.environ["PATH"] = str(base_path) + os.pathsep + os.environ["PATH"]
52
+
53
+ if sys.platform == "win32" and sys.version_info >= (3, 8):
54
+ os.add_dll_directory(str(base_path))
55
+ if "CUDA_PATH" in os.environ:
56
+ os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "bin"))
57
+ os.add_dll_directory(os.path.join(os.environ["CUDA_PATH"], "lib"))
58
+ if "HIP_PATH" in os.environ:
59
+ os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "bin"))
60
+ os.add_dll_directory(os.path.join(os.environ["HIP_PATH"], "lib"))
61
+ cdll_args["winmode"] = ctypes.RTLD_GLOBAL
62
+
63
+ # Try to load the shared library, handling potential errors
64
+ for lib_path in lib_paths:
65
+ if lib_path.exists():
66
+ try:
67
+ return ctypes.CDLL(str(lib_path), **cdll_args) # type: ignore
68
+ except Exception as e:
69
+ raise RuntimeError(f"Failed to load shared library '{lib_path}': {e}")
70
+
71
+ raise FileNotFoundError(
72
+ f"Shared library with base name '{lib_base_name}' not found"
73
+ )
74
+
75
+
76
+ # ctypes sane type hint helpers
77
+ #
78
+ # - Generic Pointer and Array types
79
+ # - PointerOrRef type with a type hinted byref function
80
+ #
81
+ # NOTE: Only use these for static type checking not for runtime checks
82
+ # no good will come of that
83
+
84
+ if TYPE_CHECKING:
85
+ CtypesCData = TypeVar("CtypesCData", bound=ctypes._CData) # type: ignore
86
+
87
+ CtypesArray: TypeAlias = ctypes.Array[CtypesCData] # type: ignore
88
+
89
+ CtypesPointer: TypeAlias = ctypes._Pointer[CtypesCData] # type: ignore
90
+
91
+ CtypesVoidPointer: TypeAlias = ctypes.c_void_p
92
+
93
+ class CtypesRef(Generic[CtypesCData]):
94
+ pass
95
+
96
+ CtypesPointerOrRef: TypeAlias = Union[
97
+ CtypesPointer[CtypesCData], CtypesRef[CtypesCData]
98
+ ]
99
+
100
+ CtypesFuncPointer: TypeAlias = ctypes._FuncPointer # type: ignore
101
+
102
+ F = TypeVar("F", bound=Callable[..., Any])
103
+
104
+
105
+ def ctypes_function_for_shared_library(lib: ctypes.CDLL):
106
+ """Decorator for defining ctypes functions with type hints"""
107
+
108
+ def ctypes_function(
109
+ name: str, argtypes: List[Any], restype: Any, enabled: bool = True
110
+ ):
111
+ def decorator(f: F) -> F:
112
+ if enabled:
113
+ func = getattr(lib, name)
114
+ func.argtypes = argtypes
115
+ func.restype = restype
116
+ functools.wraps(f)(func)
117
+ return func
118
+ else:
119
+ return f
120
+
121
+ return decorator
122
+
123
+ return ctypes_function
124
+
125
+
126
+ def _byref(obj: CtypesCData, offset: Optional[int] = None) -> CtypesRef[CtypesCData]:
127
+ """Type-annotated version of ctypes.byref"""
128
+ ...
129
+
130
+
131
+ byref = _byref if TYPE_CHECKING else ctypes.byref
llama_cpp/_ggml.py ADDED
@@ -0,0 +1,12 @@
1
+ """Internal module use at your own risk
2
+
3
+ This module provides a minimal interface for working with ggml tensors from llama-cpp-python
4
+ """
5
+ import os
6
+ import pathlib
7
+
8
+ import llama_cpp._ctypes_extensions as ctypes_ext
9
+
10
+ libggml_base_path = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) / "lib"
11
+ libggml = ctypes_ext.load_shared_library("ggml", libggml_base_path)
12
+