@novastera-oss/llamarn 0.3.1 → 0.4.1
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.
- package/README.md +86 -3
- package/RNLlamaCpp.podspec +1 -1
- package/android/CMakeLists.txt +11 -3
- package/android/generated/jni/react/renderer/components/RNLlamaCppSpec/RNLlamaCppSpecJSI.h +49 -4
- package/android/src/main/cpp/include/llama.h +53 -114
- package/android/src/main/jniLibs/arm64-v8a/libggml-base.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libggml.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libllama.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml-base.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libggml.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libllama.so +0 -0
- package/android/src/main/jniLibs/x86/libggml-base.so +0 -0
- package/android/src/main/jniLibs/x86/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/x86/libggml.so +0 -0
- package/android/src/main/jniLibs/x86/libllama.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml-base.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml-cpu.so +0 -0
- package/android/src/main/jniLibs/x86_64/libggml.so +0 -0
- package/android/src/main/jniLibs/x86_64/libllama.so +0 -0
- package/cpp/LlamaCppModel.cpp +2 -10
- package/cpp/PureCppImpl.cpp +71 -4
- package/cpp/SystemUtils.cpp +3 -7
- package/cpp/build-info.cpp +2 -2
- package/cpp/llama.cpp/CMakeLists.txt +2 -0
- package/cpp/llama.cpp/CODEOWNERS +1 -1
- package/cpp/llama.cpp/Makefile +6 -1605
- package/cpp/llama.cpp/README.md +5 -1
- package/cpp/llama.cpp/common/arg.cpp +230 -51
- package/cpp/llama.cpp/common/chat-parser.cpp +9 -1
- package/cpp/llama.cpp/common/chat.cpp +539 -8
- package/cpp/llama.cpp/common/chat.h +8 -1
- package/cpp/llama.cpp/common/common.cpp +60 -15
- package/cpp/llama.cpp/common/common.h +64 -15
- package/cpp/llama.cpp/common/speculative.cpp +135 -54
- package/cpp/llama.cpp/common/speculative.h +8 -1
- package/cpp/llama.cpp/convert_hf_to_gguf.py +1216 -109
- package/cpp/llama.cpp/convert_hf_to_gguf_update.py +19 -6
- package/cpp/llama.cpp/convert_lora_to_gguf.py +1 -1
- package/cpp/llama.cpp/flake.nix +0 -5
- package/cpp/llama.cpp/ggml/CMakeLists.txt +6 -3
- package/cpp/llama.cpp/ggml/cmake/ggml-config.cmake.in +71 -70
- package/cpp/llama.cpp/ggml/include/ggml-opt.h +25 -6
- package/cpp/llama.cpp/ggml/include/ggml-zdnn.h +16 -0
- package/cpp/llama.cpp/ggml/include/ggml.h +90 -3
- package/cpp/llama.cpp/ggml/src/CMakeLists.txt +13 -1
- package/cpp/llama.cpp/ggml/src/ggml-alloc.c +1 -0
- package/cpp/llama.cpp/ggml/src/ggml-backend-reg.cpp +10 -0
- package/cpp/llama.cpp/ggml/src/ggml-backend.cpp +113 -17
- package/cpp/llama.cpp/ggml/src/ggml-blas/ggml-blas.cpp +4 -4
- package/cpp/llama.cpp/ggml/src/ggml-cann/CMakeLists.txt +14 -0
- package/cpp/llama.cpp/ggml/src/ggml-cann/aclnn_ops.cpp +701 -585
- package/cpp/llama.cpp/ggml/src/ggml-cann/aclnn_ops.h +13 -3
- package/cpp/llama.cpp/ggml/src/ggml-cann/common.h +52 -0
- package/cpp/llama.cpp/ggml/src/ggml-cann/ggml-cann.cpp +274 -91
- package/cpp/llama.cpp/ggml/src/ggml-common.h +17 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/CMakeLists.txt +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/arm/quants.c +132 -596
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/arm/repack.cpp +14 -286
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/loongarch/quants.c +90 -569
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/powerpc/quants.c +162 -589
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/riscv/quants.c +55 -341
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/riscv/repack.cpp +3 -58
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/s390/quants.c +371 -298
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/wasm/quants.c +54 -314
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/x86/quants.c +184 -675
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch/x86/repack.cpp +4679 -1657
- package/cpp/llama.cpp/ggml/src/ggml-cpu/arch-fallback.h +33 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu-impl.h +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.c +26 -1
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ggml-cpu.cpp +21 -24
- package/cpp/llama.cpp/ggml/src/ggml-cpu/kleidiai/kleidiai.cpp +16 -7
- package/cpp/llama.cpp/ggml/src/ggml-cpu/llamafile/sgemm.cpp +232 -123
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ops.cpp +428 -23
- package/cpp/llama.cpp/ggml/src/ggml-cpu/ops.h +4 -8
- package/cpp/llama.cpp/ggml/src/ggml-cpu/quants.c +35 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/quants.h +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/repack.cpp +458 -46
- package/cpp/llama.cpp/ggml/src/ggml-cpu/repack.h +22 -0
- package/cpp/llama.cpp/ggml/src/ggml-cpu/simd-mappings.h +39 -14
- package/cpp/llama.cpp/ggml/src/ggml-cpu/traits.cpp +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-cpu/traits.h +1 -1
- package/cpp/llama.cpp/ggml/src/ggml-cpu/vec.cpp +20 -1
- package/cpp/llama.cpp/ggml/src/ggml-cpu/vec.h +122 -5
- package/cpp/llama.cpp/ggml/src/ggml-cuda/CMakeLists.txt +9 -11
- package/cpp/llama.cpp/ggml/src/ggml-cuda/add-id.cu +58 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/add-id.cuh +3 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/binbcast.cu +275 -170
- package/cpp/llama.cpp/ggml/src/ggml-cuda/binbcast.cuh +2 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/common.cuh +103 -65
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv-transpose-1d.cu +1 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d.cu +171 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/conv2d.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/convert.cu +33 -7
- package/cpp/llama.cpp/ggml/src/ggml-cuda/convert.cuh +13 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/cpy-utils.cuh +2 -10
- package/cpp/llama.cpp/ggml/src/ggml-cuda/cpy.cu +3 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/dequantize.cuh +14 -40
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-common.cuh +83 -27
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-mma-f16.cuh +116 -57
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-tile-f16.cu +45 -18
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-tile-f32.cu +56 -29
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-vec-f16.cuh +61 -39
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-vec-f32.cuh +70 -49
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn-wmma-f16.cu +70 -21
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn.cu +162 -50
- package/cpp/llama.cpp/ggml/src/ggml-cuda/fattn.cuh +2 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/getrows.cu +5 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/ggml-cuda.cu +208 -97
- package/cpp/llama.cpp/ggml/src/ggml-cuda/im2col.cu +46 -35
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mean.cu +56 -2
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mma.cuh +95 -51
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmf.cu +427 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmf.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmq.cu +204 -57
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmq.cuh +252 -168
- package/cpp/llama.cpp/ggml/src/ggml-cuda/{mmv.cu → mmvf.cu} +53 -53
- package/cpp/llama.cpp/ggml/src/ggml-cuda/{mmv.cuh → mmvf.cuh} +3 -3
- package/cpp/llama.cpp/ggml/src/ggml-cuda/mmvq.cu +10 -5
- package/cpp/llama.cpp/ggml/src/ggml-cuda/norm.cu +192 -19
- package/cpp/llama.cpp/ggml/src/ggml-cuda/norm.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/opt-step-sgd.cu +49 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/opt-step-sgd.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/pad_reflect_1d.cu +82 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/pad_reflect_1d.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/reduce_rows.cuh +53 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/roll.cu +67 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/roll.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/set-rows.cu +1 -8
- package/cpp/llama.cpp/ggml/src/ggml-cuda/softcap.cu +34 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/softcap.cuh +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/softmax.cu +16 -10
- package/cpp/llama.cpp/ggml/src/ggml-cuda/ssm-scan.cu +153 -71
- package/cpp/llama.cpp/ggml/src/ggml-cuda/sum.cu +6 -10
- package/cpp/llama.cpp/ggml/src/ggml-cuda/sumrows.cu +21 -4
- package/cpp/llama.cpp/ggml/src/ggml-cuda/template-instances/mmq-instance-mxfp4.cu +5 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/unary.cu +75 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/unary.cuh +2 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/vecdotq.cuh +110 -22
- package/cpp/llama.cpp/ggml/src/ggml-cuda/vendors/cuda.h +4 -0
- package/cpp/llama.cpp/ggml/src/ggml-cuda/vendors/hip.h +14 -25
- package/cpp/llama.cpp/ggml/src/ggml-cuda/vendors/musa.h +2 -1
- package/cpp/llama.cpp/ggml/src/ggml-hip/CMakeLists.txt +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-impl.h +61 -0
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal-impl.h +31 -20
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal.m +342 -131
- package/cpp/llama.cpp/ggml/src/ggml-metal/ggml-metal.metal +464 -134
- package/cpp/llama.cpp/ggml/src/ggml-musa/CMakeLists.txt +0 -4
- package/cpp/llama.cpp/ggml/src/ggml-opencl/CMakeLists.txt +8 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/ggml-opencl.cpp +1108 -176
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/add.cl +107 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/add_id.cl +42 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/div.cl +66 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/flash_attn_f16.cl +343 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/flash_attn_f32.cl +343 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/flash_attn_f32_f16.cl +346 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/glu.cl +41 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/group_norm.cl +49 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul.cl +73 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul_mm_f16_f32_l4_lm.cl +132 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul_mm_f32_f32_l4_lm.cl +133 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul_mv_id_mxfp4_f32.cl +189 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/mul_mv_mxfp4_f32.cl +144 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/norm.cl +80 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f16.cl +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_4_f32.cl +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_f16.cl +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/softmax_f32.cl +10 -2
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/sub.cl +66 -0
- package/cpp/llama.cpp/ggml/src/ggml-opencl/kernels/transpose.cl +20 -0
- package/cpp/llama.cpp/ggml/src/ggml-opt.cpp +97 -41
- package/cpp/llama.cpp/ggml/src/ggml-quants.c +110 -16
- package/cpp/llama.cpp/ggml/src/ggml-quants.h +6 -0
- package/cpp/llama.cpp/ggml/src/ggml-rpc/ggml-rpc.cpp +22 -9
- package/cpp/llama.cpp/ggml/src/ggml-sycl/backend.hpp +1 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/cpy.cpp +0 -212
- package/cpp/llama.cpp/ggml/src/ggml-sycl/cpy.hpp +213 -1
- package/cpp/llama.cpp/ggml/src/ggml-sycl/ggml-sycl.cpp +117 -238
- package/cpp/llama.cpp/ggml/src/ggml-sycl/quantize.hpp +133 -0
- package/cpp/llama.cpp/ggml/src/ggml-sycl/set_rows.cpp +94 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/ggml-vulkan.cpp +1666 -633
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/add.comp +41 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/add_id.comp +42 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/argmax.comp +13 -4
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/argsort.comp +39 -29
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/conv2d_mm.comp +107 -43
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/copy_from_quant.comp +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs.comp +18 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_funcs_cm2.comp +21 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/dequant_mxfp4.comp +32 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/exp.comp +20 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn.comp +21 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_base.comp +16 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm1.comp +44 -8
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_cm2.comp +44 -16
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/flash_attn_split_k_reduce.comp +26 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/generic_binary_head.comp +2 -17
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/glu_head.comp +2 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_base.comp +37 -1
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_nc.comp +11 -7
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm.comp +109 -55
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mm_cm2.comp +71 -41
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/mul_mmq_funcs.comp +6 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/multi_add.comp +111 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/opt_step_sgd.comp +22 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm.comp +49 -11
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/rms_norm_partials.comp +65 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/soft_max.comp +9 -3
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sqrt.comp +17 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/sum_rows.comp +38 -5
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/swiglu_oai.comp +14 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/types.comp +55 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/utils.comp +25 -0
- package/cpp/llama.cpp/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +75 -20
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/CMakeLists.txt +2 -2
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/ggml-webgpu.cpp +807 -412
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/wgsl-shaders/embed_wgsl.py +72 -22
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/wgsl-shaders/memset.wgsl +8 -8
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat.tmpl.wgsl +1794 -0
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/wgsl-shaders/set_rows.wgsl +82 -0
- package/cpp/llama.cpp/ggml/src/ggml-zdnn/CMakeLists.txt +36 -0
- package/cpp/llama.cpp/ggml/src/ggml-zdnn/ggml-zdnn-impl.h +97 -0
- package/cpp/llama.cpp/ggml/src/ggml-zdnn/ggml-zdnn.cpp +846 -0
- package/cpp/llama.cpp/ggml/src/ggml.c +204 -50
- package/cpp/llama.cpp/gguf-py/gguf/constants.py +187 -2
- package/cpp/llama.cpp/gguf-py/gguf/gguf_writer.py +11 -2
- package/cpp/llama.cpp/gguf-py/gguf/quants.py +53 -4
- package/cpp/llama.cpp/gguf-py/gguf/scripts/gguf_convert_endian.py +67 -63
- package/cpp/llama.cpp/gguf-py/gguf/scripts/gguf_new_metadata.py +7 -1
- package/cpp/llama.cpp/gguf-py/gguf/tensor_mapping.py +120 -16
- package/cpp/llama.cpp/gguf-py/gguf/utility.py +5 -1
- package/cpp/llama.cpp/gguf-py/gguf/vocab.py +284 -1
- package/cpp/llama.cpp/gguf-py/tests/test_quants.py +14 -5
- package/cpp/llama.cpp/include/llama.h +53 -114
- package/cpp/llama.cpp/models/templates/ByteDance-Seed-OSS.jinja +171 -0
- package/cpp/llama.cpp/models/templates/README.md +2 -1
- package/cpp/llama.cpp/models/templates/ibm-granite-granite-3.3-2B-Instruct.jinja +59 -0
- package/cpp/llama.cpp/models/templates/openai-gpt-oss-120b.jinja +331 -0
- package/cpp/llama.cpp/models/templates/unsloth-mistral-Devstral-Small-2507.jinja +105 -0
- package/cpp/llama.cpp/requirements/requirements-convert_hf_to_gguf.txt +3 -1
- package/cpp/llama.cpp/requirements/requirements-convert_hf_to_gguf_update.txt +0 -6
- package/cpp/llama.cpp/requirements/requirements-pydantic.txt +1 -1
- package/cpp/llama.cpp/src/CMakeLists.txt +2 -2
- package/cpp/llama.cpp/src/llama-adapter.cpp +68 -4
- package/cpp/llama.cpp/src/llama-adapter.h +3 -0
- package/cpp/llama.cpp/src/llama-arch.cpp +192 -2
- package/cpp/llama.cpp/src/llama-arch.h +18 -0
- package/cpp/llama.cpp/src/llama-batch.cpp +2 -2
- package/cpp/llama.cpp/src/llama-chat.cpp +47 -6
- package/cpp/llama.cpp/src/llama-chat.h +3 -0
- package/cpp/llama.cpp/src/llama-context.cpp +61 -252
- package/cpp/llama.cpp/src/llama-context.h +10 -15
- package/cpp/llama.cpp/src/llama-cparams.h +0 -1
- package/cpp/llama.cpp/src/llama-graph.cpp +180 -85
- package/cpp/llama.cpp/src/llama-graph.h +90 -51
- package/cpp/llama.cpp/src/llama-hparams.cpp +34 -3
- package/cpp/llama.cpp/src/llama-hparams.h +21 -6
- package/cpp/llama.cpp/src/{llama-kv-cache-unified-iswa.cpp → llama-kv-cache-iswa.cpp} +79 -56
- package/cpp/llama.cpp/src/{llama-kv-cache-unified-iswa.h → llama-kv-cache-iswa.h} +30 -28
- package/cpp/llama.cpp/src/{llama-kv-cache-unified.cpp → llama-kv-cache.cpp} +240 -632
- package/cpp/llama.cpp/src/{llama-kv-cache-unified.h → llama-kv-cache.h} +39 -74
- package/cpp/llama.cpp/src/llama-kv-cells.h +21 -21
- package/cpp/llama.cpp/src/llama-memory-hybrid.cpp +41 -35
- package/cpp/llama.cpp/src/llama-memory-hybrid.h +26 -29
- package/cpp/llama.cpp/src/llama-memory-recurrent.cpp +13 -9
- package/cpp/llama.cpp/src/llama-memory-recurrent.h +10 -14
- package/cpp/llama.cpp/src/llama-memory.h +13 -10
- package/cpp/llama.cpp/src/llama-model-loader.cpp +2 -0
- package/cpp/llama.cpp/src/llama-model-loader.h +3 -2
- package/cpp/llama.cpp/src/llama-model.cpp +1959 -419
- package/cpp/llama.cpp/src/llama-model.h +28 -4
- package/cpp/llama.cpp/src/llama-quant.cpp +40 -4
- package/cpp/llama.cpp/src/llama-vocab.cpp +51 -2
- package/cpp/llama.cpp/src/llama-vocab.h +1 -0
- package/cpp/llama.cpp/vendor/minja/chat-template.hpp +16 -7
- package/cpp/llama.cpp/vendor/minja/minja.hpp +47 -12
- package/cpp/rn-completion.cpp +3 -27
- package/ios/generated/RNLlamaCppSpec/RNLlamaCppSpec.h +30 -0
- package/ios/generated/RNLlamaCppSpecJSI.h +49 -4
- package/ios/include/chat.h +8 -1
- package/ios/include/common/minja/chat-template.hpp +16 -7
- package/ios/include/common/minja/minja.hpp +47 -12
- package/ios/include/common.h +64 -15
- package/ios/include/llama.h +53 -114
- package/ios/include/speculative.h +8 -1
- package/ios/libs/llama.xcframework/Info.plist +18 -18
- package/ios/libs/llama.xcframework/ios-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5557 -5267
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/ios-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5520 -5238
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +4241 -4014
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/ios-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5519 -5238
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +4242 -4016
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/A/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/Versions/Current/llama +0 -0
- package/ios/libs/llama.xcframework/macos-arm64_x86_64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5556 -5267
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/tvos-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5519 -5238
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +4241 -4014
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/tvos-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5553 -5303
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/xros-arm64/llama.framework/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/DWARF/llama +0 -0
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/aarch64/llama.yml +5515 -5274
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/dSYMs/llama.dSYM/Contents/Resources/Relocations/x86_64/llama.yml +4238 -4044
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/ggml-opt.h +25 -6
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/ggml.h +90 -3
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/Headers/llama.h +53 -114
- package/ios/libs/llama.xcframework/xros-arm64_x86_64-simulator/llama.framework/llama +0 -0
- package/lib/module/NativeRNLlamaCpp.js.map +1 -1
- package/lib/typescript/src/NativeRNLlamaCpp.d.ts +5 -0
- package/lib/typescript/src/NativeRNLlamaCpp.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/NativeRNLlamaCpp.ts +7 -0
- package/cpp/llama.cpp/ggml/src/ggml-webgpu/wgsl-shaders/mul_mat.wgsl +0 -56
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{#- Copyright 2025-present the Unsloth team. All rights reserved. #}
|
|
2
|
+
{#- Licensed under the Apache License, Version 2.0 (the "License") #}
|
|
3
|
+
{#- Edits made by Unsloth #}
|
|
4
|
+
{%- set default_system_message = 'You are Devstral, a helpful agentic model trained by Mistral AI and using the OpenHands scaffold. You can interact with a computer to solve tasks.\n\n<ROLE>\nYour primary role is to assist users by executing commands, modifying code, and solving technical problems effectively. You should be thorough, methodical, and prioritize quality over speed.\n* If the user asks a question, like \"why is X happening\", don\'t try to fix the problem. Just give an answer to the question.\n</ROLE>\n\n<EFFICIENCY>\n* Each action you take is somewhat expensive. Wherever possible, combine multiple actions into a single action, e.g. combine multiple bash commands into one, using sed and grep to edit/view multiple files at once.\n* When exploring the codebase, use efficient tools like find, grep, and git commands with appropriate filters to minimize unnecessary operations.\n</EFFICIENCY>\n\n<FILE_SYSTEM_GUIDELINES>\n* When a user provides a file path, do NOT assume it\'s relative to the current working directory. First explore the file system to locate the file before working on it.\n* If asked to edit a file, edit the file directly, rather than creating a new file with a different filename.\n* For global search-and-replace operations, consider using `sed` instead of opening file editors multiple times.\n</FILE_SYSTEM_GUIDELINES>\n\n<CODE_QUALITY>\n* Write clean, efficient code with minimal comments. Avoid redundancy in comments: Do not repeat information that can be easily inferred from the code itself.\n* When implementing solutions, focus on making the minimal changes needed to solve the problem.\n* Before implementing any changes, first thoroughly understand the codebase through exploration.\n* If you are adding a lot of code to a function or file, consider splitting the function or file into smaller pieces when appropriate.\n</CODE_QUALITY>\n\n<VERSION_CONTROL>\n* When configuring git credentials, use \"openhands\" as the user.name and \"openhands@all-hands.dev\" as the user.email by default, unless explicitly instructed otherwise.\n* Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so.\n* When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible.\n* Do NOT commit files that typically shouldn\'t go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.\n* If unsure about committing certain files, check for the presence of .gitignore files or ask the user for clarification.\n</VERSION_CONTROL>\n\n<PULL_REQUESTS>\n* When creating pull requests, create only ONE per session/issue unless explicitly instructed otherwise.\n* When working with an existing PR, update it with new commits rather than creating additional PRs for the same issue.\n* When updating a PR, preserve the original PR title and purpose, updating description only when necessary.\n</PULL_REQUESTS>\n\n<PROBLEM_SOLVING_WORKFLOW>\n1. EXPLORATION: Thoroughly explore relevant files and understand the context before proposing solutions\n2. ANALYSIS: Consider multiple approaches and select the most promising one\n3. TESTING:\n * For bug fixes: Create tests to verify issues before implementing fixes\n * For new features: Consider test-driven development when appropriate\n * If the repository lacks testing infrastructure and implementing tests would require extensive setup, consult with the user before investing time in building testing infrastructure\n * If the environment is not set up to run tests, consult with the user first before investing time to install all dependencies\n4. IMPLEMENTATION: Make focused, minimal changes to address the problem\n5. VERIFICATION: If the environment is set up to run tests, test your implementation thoroughly, including edge cases. If the environment is not set up to run tests, consult with the user first before investing time to run tests.\n</PROBLEM_SOLVING_WORKFLOW>\n\n<SECURITY>\n* Only use GITHUB_TOKEN and other credentials in ways the user has explicitly requested and would expect.\n* Use APIs to work with GitHub or other platforms, unless the user asks otherwise or your task requires browsing.\n</SECURITY>\n\n<ENVIRONMENT_SETUP>\n* When user asks you to run an application, don\'t stop if the application is not installed. Instead, please install the application and run the command again.\n* If you encounter missing dependencies:\n 1. First, look around in the repository for existing dependency files (requirements.txt, pyproject.toml, package.json, Gemfile, etc.)\n 2. If dependency files exist, use them to install all dependencies at once (e.g., `pip install -r requirements.txt`, `npm install`, etc.)\n 3. Only install individual packages directly if no dependency files are found or if only specific packages are needed\n* Similarly, if you encounter missing dependencies for essential tools requested by the user, install them when possible.\n</ENVIRONMENT_SETUP>\n\n<TROUBLESHOOTING>\n* If you\'ve made repeated attempts to solve a problem but tests still fail or the user reports it\'s still broken:\n 1. Step back and reflect on 5-7 different possible sources of the problem\n 2. Assess the likelihood of each possible cause\n 3. Methodically address the most likely causes, starting with the highest probability\n 4. Document your reasoning process\n* When you run into any major issue while executing a plan from the user, please don\'t try to directly work around it. Instead, propose a new plan and confirm with the user before proceeding.\n</TROUBLESHOOTING>' %}
|
|
5
|
+
|
|
6
|
+
{{- bos_token }}
|
|
7
|
+
|
|
8
|
+
{%- if messages[0]['role'] == 'system' %}
|
|
9
|
+
{%- if messages[0]['content'] is string %}
|
|
10
|
+
{%- set system_message = messages[0]['content'] %}
|
|
11
|
+
{%- else %}
|
|
12
|
+
{%- set system_message = messages[0]['content'][0]['text'] %}
|
|
13
|
+
{%- endif %}
|
|
14
|
+
{%- set loop_messages = messages[1:] %}
|
|
15
|
+
{%- else %}
|
|
16
|
+
{%- set system_message = default_system_message %}
|
|
17
|
+
{%- set loop_messages = messages %}
|
|
18
|
+
{%- endif %}
|
|
19
|
+
{{- '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT]' }}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
{#- Tool description appended ONLY to last user message. Edits made by Unsloth #}
|
|
23
|
+
{#- Tool description appended also if last message is tool. Edits made by Unsloth #}
|
|
24
|
+
{%- set tools_description = "" %}
|
|
25
|
+
{%- set has_tools = false %}
|
|
26
|
+
|
|
27
|
+
{%- if tools is defined and tools is not none and tools|length > 0 %}
|
|
28
|
+
|
|
29
|
+
{%- set has_tools = true %}
|
|
30
|
+
{%- set tools_description = "[AVAILABLE_TOOLS]" + (tools | tojson) + "[/AVAILABLE_TOOLS]" %}
|
|
31
|
+
|
|
32
|
+
{{- tools_description }}
|
|
33
|
+
|
|
34
|
+
{%- endif %}
|
|
35
|
+
|
|
36
|
+
{%- for message in loop_messages %}
|
|
37
|
+
{%- if message['role'] == 'user' %}
|
|
38
|
+
|
|
39
|
+
{%- if message['content'] is string %}
|
|
40
|
+
{{- '[INST]' + message['content'] + '[/INST]' }}
|
|
41
|
+
{%- else %}
|
|
42
|
+
{{- '[INST]' }}
|
|
43
|
+
{%- for block in message['content'] %}
|
|
44
|
+
{%- if block['type'] == 'text' %}
|
|
45
|
+
|
|
46
|
+
{#- Original did not have content which is weird. Added by Un-sloth. #}
|
|
47
|
+
{%- if block['text'] is defined %}
|
|
48
|
+
{{- block['text'] }}
|
|
49
|
+
{%- else %}
|
|
50
|
+
{{- block['content'] }}
|
|
51
|
+
{%- endif %}
|
|
52
|
+
|
|
53
|
+
{%- elif block['type'] in ['image', 'image_url'] %}
|
|
54
|
+
{{- '[IMG]' }}
|
|
55
|
+
{%- else %}
|
|
56
|
+
{{- raise_exception('Only text and image blocks are supported in message content!') }}
|
|
57
|
+
{%- endif %}
|
|
58
|
+
{%- endfor %}
|
|
59
|
+
{{- '[/INST]' }}
|
|
60
|
+
{%- endif %}
|
|
61
|
+
|
|
62
|
+
{%- elif message['role'] == 'system' %}
|
|
63
|
+
{%- if message['content'] is string %}
|
|
64
|
+
{{- '[SYSTEM_PROMPT]' + message['content'] + '[/SYSTEM_PROMPT]' }}
|
|
65
|
+
{%- else %}
|
|
66
|
+
{{- '[SYSTEM_PROMPT]' + message['content'][0]['text'] + '[/SYSTEM_PROMPT]' }}
|
|
67
|
+
{%- endif %}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
{%- elif message['role'] == 'assistant' %}
|
|
71
|
+
{%- if message['content'] is string %}
|
|
72
|
+
{{- message['content'] }}
|
|
73
|
+
{%- else %}
|
|
74
|
+
{{- message['content'][0]['text'] }}
|
|
75
|
+
{%- endif %}
|
|
76
|
+
|
|
77
|
+
{#- If User,Assistant,Tool,Tool we also need to append tools_description. Edits made by Unsloth #}
|
|
78
|
+
|
|
79
|
+
{%- if message['tool_calls'] is defined and message['tool_calls'] is not none %}
|
|
80
|
+
{%- for tool in message['tool_calls'] %}
|
|
81
|
+
{%- set arguments = tool['function']['arguments'] %}
|
|
82
|
+
{%- if arguments is not string %}
|
|
83
|
+
{%- set arguments = arguments|tojson %}
|
|
84
|
+
{%- endif %}
|
|
85
|
+
{#- Must list tool calls AFTER assistant. Edits made by Un-sloth #}
|
|
86
|
+
{{- "[TOOL_CALLS]" + tool['function']['name'] + "[ARGS]" + arguments }}
|
|
87
|
+
{%- endfor %}
|
|
88
|
+
{%- endif %}
|
|
89
|
+
|
|
90
|
+
{{- eos_token }}
|
|
91
|
+
|
|
92
|
+
{%- elif message["role"] == "tool_results" or message["role"] == "tool" %}
|
|
93
|
+
{%- if message.content is defined and message.content.content is defined %}
|
|
94
|
+
{%- set content = message.content.content %}
|
|
95
|
+
{%- else %}
|
|
96
|
+
{%- set content = message.content %}
|
|
97
|
+
{%- endif %}
|
|
98
|
+
{{- "[TOOL_RESULTS]" + content|string + "[/TOOL_RESULTS]" }}
|
|
99
|
+
|
|
100
|
+
{%- else %}
|
|
101
|
+
{{- raise_exception('Only user, systemm assistant and tool roles are supported in the custom template made by Unsloth!') }}
|
|
102
|
+
{%- endif %}
|
|
103
|
+
{%- endfor %}
|
|
104
|
+
{#- Copyright 2025-present the Unsloth team. All rights reserved. #}
|
|
105
|
+
{#- Licensed under the Apache License, Version 2.0 (the "License") #}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
mistral-common>=1.8.3
|
|
2
|
+
|
|
1
3
|
-r ./requirements-convert_legacy_llama.txt
|
|
2
4
|
--extra-index-url https://download.pytorch.org/whl/cpu
|
|
3
|
-
torch~=2.
|
|
5
|
+
torch~=2.4.0; platform_machine != "s390x"
|
|
4
6
|
|
|
5
7
|
# torch s390x packages can only be found from nightly builds
|
|
6
8
|
--extra-index-url https://download.pytorch.org/whl/nightly
|
|
@@ -1,7 +1 @@
|
|
|
1
1
|
-r ./requirements-convert_legacy_llama.txt
|
|
2
|
-
--extra-index-url https://download.pytorch.org/whl/cpu
|
|
3
|
-
torch~=2.2.1; platform_machine != "s390x"
|
|
4
|
-
|
|
5
|
-
# torch s390x packages can only be found from nightly builds
|
|
6
|
-
--extra-index-url https://download.pytorch.org/whl/nightly
|
|
7
|
-
torch>=0.0.0.dev0; platform_machine == "s390x"
|
|
@@ -20,8 +20,8 @@ add_library(llama
|
|
|
20
20
|
llama-hparams.cpp
|
|
21
21
|
llama-impl.cpp
|
|
22
22
|
llama-io.cpp
|
|
23
|
-
llama-kv-cache
|
|
24
|
-
llama-kv-cache-
|
|
23
|
+
llama-kv-cache.cpp
|
|
24
|
+
llama-kv-cache-iswa.cpp
|
|
25
25
|
llama-memory.cpp
|
|
26
26
|
llama-memory-hybrid.cpp
|
|
27
27
|
llama-memory-recurrent.cpp
|
|
@@ -163,13 +163,38 @@ static void llama_adapter_lora_init_impl(llama_model & model, const char * path_
|
|
|
163
163
|
|
|
164
164
|
// check metadata
|
|
165
165
|
{
|
|
166
|
+
const gguf_context * gguf_ctx = ctx_gguf.get();
|
|
167
|
+
|
|
168
|
+
LLAMA_LOG_INFO("%s: Dumping metadata keys/values.\n", __func__);
|
|
169
|
+
|
|
170
|
+
// get metadata as string
|
|
171
|
+
for (int i = 0; i < gguf_get_n_kv(gguf_ctx); i++) {
|
|
172
|
+
gguf_type type = gguf_get_kv_type(gguf_ctx, i);
|
|
173
|
+
const std::string type_name =
|
|
174
|
+
type == GGUF_TYPE_ARRAY
|
|
175
|
+
? format("%s[%s,%zu]", gguf_type_name(type), gguf_type_name(gguf_get_arr_type(gguf_ctx, i)), gguf_get_arr_n(gguf_ctx, i))
|
|
176
|
+
: gguf_type_name(type);
|
|
177
|
+
const char * name = gguf_get_key(gguf_ctx, i);
|
|
178
|
+
const std::string value = gguf_kv_to_str(gguf_ctx, i);
|
|
179
|
+
|
|
180
|
+
if (type != GGUF_TYPE_ARRAY) {
|
|
181
|
+
adapter.gguf_kv.emplace(name, value);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const size_t MAX_VALUE_LEN = 40;
|
|
185
|
+
std::string print_value = value.size() > MAX_VALUE_LEN ? format("%s...", value.substr(0, MAX_VALUE_LEN - 3).c_str()) : value;
|
|
186
|
+
replace_all(print_value, "\n", "\\n");
|
|
187
|
+
|
|
188
|
+
LLAMA_LOG_INFO("%s: - kv %3d: %42s %-16s = %s\n", __func__, i, name, type_name.c_str(), print_value.c_str());
|
|
189
|
+
}
|
|
190
|
+
|
|
166
191
|
auto get_kv_str = [&](const std::string & key) -> std::string {
|
|
167
|
-
int id = gguf_find_key(
|
|
168
|
-
return id < 0 ? "" : std::string(gguf_get_val_str(
|
|
192
|
+
int id = gguf_find_key(gguf_ctx, key.c_str());
|
|
193
|
+
return id < 0 ? "" : std::string(gguf_get_val_str(gguf_ctx, id));
|
|
169
194
|
};
|
|
170
195
|
auto get_kv_f32 = [&](const std::string & key) -> float {
|
|
171
|
-
int id = gguf_find_key(
|
|
172
|
-
return id < 0 ? 0.0f : gguf_get_val_f32(
|
|
196
|
+
int id = gguf_find_key(gguf_ctx, key.c_str());
|
|
197
|
+
return id < 0 ? 0.0f : gguf_get_val_f32(gguf_ctx, id);
|
|
173
198
|
};
|
|
174
199
|
LLM_KV llm_kv = LLM_KV(LLM_ARCH_UNKNOWN);
|
|
175
200
|
|
|
@@ -383,6 +408,45 @@ llama_adapter_lora * llama_adapter_lora_init(llama_model * model, const char * p
|
|
|
383
408
|
return nullptr;
|
|
384
409
|
}
|
|
385
410
|
|
|
411
|
+
int32_t llama_adapter_meta_val_str(const llama_adapter_lora * adapter, const char * key, char * buf, size_t buf_size) {
|
|
412
|
+
const auto & it = adapter->gguf_kv.find(key);
|
|
413
|
+
if (it == adapter->gguf_kv.end()) {
|
|
414
|
+
if (buf_size > 0) {
|
|
415
|
+
buf[0] = '\0';
|
|
416
|
+
}
|
|
417
|
+
return -1;
|
|
418
|
+
}
|
|
419
|
+
return snprintf(buf, buf_size, "%s", it->second.c_str());
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
int32_t llama_adapter_meta_count(const llama_adapter_lora * adapter) {
|
|
423
|
+
return (int)adapter->gguf_kv.size();
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
int32_t llama_adapter_meta_key_by_index(const llama_adapter_lora * adapter, int i, char * buf, size_t buf_size) {
|
|
427
|
+
if (i < 0 || i >= (int)adapter->gguf_kv.size()) {
|
|
428
|
+
if (buf_size > 0) {
|
|
429
|
+
buf[0] = '\0';
|
|
430
|
+
}
|
|
431
|
+
return -1;
|
|
432
|
+
}
|
|
433
|
+
auto it = adapter->gguf_kv.begin();
|
|
434
|
+
std::advance(it, i);
|
|
435
|
+
return snprintf(buf, buf_size, "%s", it->first.c_str());
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
int32_t llama_adapter_meta_val_str_by_index(const llama_adapter_lora * adapter, int32_t i, char * buf, size_t buf_size) {
|
|
439
|
+
if (i < 0 || i >= (int)adapter->gguf_kv.size()) {
|
|
440
|
+
if (buf_size > 0) {
|
|
441
|
+
buf[0] = '\0';
|
|
442
|
+
}
|
|
443
|
+
return -1;
|
|
444
|
+
}
|
|
445
|
+
auto it = adapter->gguf_kv.begin();
|
|
446
|
+
std::advance(it, i);
|
|
447
|
+
return snprintf(buf, buf_size, "%s", it->second.c_str());
|
|
448
|
+
}
|
|
449
|
+
|
|
386
450
|
void llama_adapter_lora_free(llama_adapter_lora * adapter) {
|
|
387
451
|
delete adapter;
|
|
388
452
|
}
|
|
@@ -22,6 +22,7 @@ static const std::map<llm_arch, const char *> LLM_ARCH_NAMES = {
|
|
|
22
22
|
{ LLM_ARCH_NOMIC_BERT_MOE, "nomic-bert-moe" },
|
|
23
23
|
{ LLM_ARCH_NEO_BERT, "neo-bert" },
|
|
24
24
|
{ LLM_ARCH_JINA_BERT_V2, "jina-bert-v2" },
|
|
25
|
+
{ LLM_ARCH_JINA_BERT_V3, "jina-bert-v3" },
|
|
25
26
|
{ LLM_ARCH_BLOOM, "bloom" },
|
|
26
27
|
{ LLM_ARCH_STABLELM, "stablelm" },
|
|
27
28
|
{ LLM_ARCH_QWEN, "qwen" },
|
|
@@ -62,11 +63,13 @@ static const std::map<llm_arch, const char *> LLM_ARCH_NAMES = {
|
|
|
62
63
|
{ LLM_ARCH_DEEPSEEK2, "deepseek2" },
|
|
63
64
|
{ LLM_ARCH_CHATGLM, "chatglm" },
|
|
64
65
|
{ LLM_ARCH_GLM4, "glm4" },
|
|
66
|
+
{ LLM_ARCH_GLM4_MOE, "glm4moe" },
|
|
65
67
|
{ LLM_ARCH_BITNET, "bitnet" },
|
|
66
68
|
{ LLM_ARCH_T5, "t5" },
|
|
67
69
|
{ LLM_ARCH_T5ENCODER, "t5encoder" },
|
|
68
70
|
{ LLM_ARCH_JAIS, "jais" },
|
|
69
71
|
{ LLM_ARCH_NEMOTRON, "nemotron" },
|
|
72
|
+
{ LLM_ARCH_NEMOTRON_H, "nemotron_h" },
|
|
70
73
|
{ LLM_ARCH_EXAONE, "exaone" },
|
|
71
74
|
{ LLM_ARCH_EXAONE4, "exaone4" },
|
|
72
75
|
{ LLM_ARCH_RWKV6, "rwkv6" },
|
|
@@ -85,9 +88,14 @@ static const std::map<llm_arch, const char *> LLM_ARCH_NAMES = {
|
|
|
85
88
|
{ LLM_ARCH_ERNIE4_5, "ernie4_5" },
|
|
86
89
|
{ LLM_ARCH_ERNIE4_5_MOE, "ernie4_5-moe" },
|
|
87
90
|
{ LLM_ARCH_HUNYUAN_MOE, "hunyuan-moe" },
|
|
91
|
+
{ LLM_ARCH_HUNYUAN_DENSE, "hunyuan-dense" },
|
|
88
92
|
{ LLM_ARCH_SMOLLM3, "smollm3" },
|
|
93
|
+
{ LLM_ARCH_OPENAI_MOE, "gpt-oss" },
|
|
89
94
|
{ LLM_ARCH_LFM2, "lfm2" },
|
|
90
95
|
{ LLM_ARCH_DREAM, "dream" },
|
|
96
|
+
{ LLM_ARCH_SMALLTHINKER, "smallthinker" },
|
|
97
|
+
{ LLM_ARCH_LLADA, "llada" },
|
|
98
|
+
{ LLM_ARCH_SEED_OSS, "seed_oss" },
|
|
91
99
|
{ LLM_ARCH_UNKNOWN, "(unknown)" },
|
|
92
100
|
};
|
|
93
101
|
|
|
@@ -124,6 +132,7 @@ static const std::map<llm_kv, const char *> LLM_KV_NAMES = {
|
|
|
124
132
|
{ LLM_KV_EXPERT_WEIGHTS_NORM, "%s.expert_weights_norm" },
|
|
125
133
|
{ LLM_KV_EXPERT_GATING_FUNC, "%s.expert_gating_func" },
|
|
126
134
|
{ LLM_KV_MOE_EVERY_N_LAYERS, "%s.moe_every_n_layers" },
|
|
135
|
+
{ LLM_KV_NEXTN_PREDICT_LAYERS, "%s.nextn_predict_layers" },
|
|
127
136
|
{ LLM_KV_POOLING_TYPE, "%s.pooling_type" },
|
|
128
137
|
{ LLM_KV_LOGIT_SCALE, "%s.logit_scale" },
|
|
129
138
|
{ LLM_KV_DECODER_START_TOKEN_ID, "%s.decoder_start_token_id" },
|
|
@@ -227,8 +236,10 @@ static const std::map<llm_kv, const char *> LLM_KV_NAMES = {
|
|
|
227
236
|
{ LLM_KV_TOKENIZER_FIM_REP_ID, "tokenizer.ggml.fim_rep_token_id" },
|
|
228
237
|
{ LLM_KV_TOKENIZER_FIM_SEP_ID, "tokenizer.ggml.fim_sep_token_id" },
|
|
229
238
|
|
|
230
|
-
{ LLM_KV_ADAPTER_TYPE,
|
|
231
|
-
{ LLM_KV_ADAPTER_LORA_ALPHA,
|
|
239
|
+
{ LLM_KV_ADAPTER_TYPE, "adapter.type" },
|
|
240
|
+
{ LLM_KV_ADAPTER_LORA_ALPHA, "adapter.lora.alpha" },
|
|
241
|
+
{ LLM_KV_ADAPTER_LORA_TASK_NAME, "adapter.lora.task_name" },
|
|
242
|
+
{ LLM_KV_ADAPTER_LORA_PROMPT_PREFIX, "adapter.lora.prompt_prefix" },
|
|
232
243
|
|
|
233
244
|
// deprecated
|
|
234
245
|
{ LLM_KV_TOKENIZER_PREFIX_ID, "tokenizer.ggml.prefix_token_id" },
|
|
@@ -568,6 +579,20 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
568
579
|
{ LLM_TENSOR_CLS, "cls" },
|
|
569
580
|
},
|
|
570
581
|
},
|
|
582
|
+
{
|
|
583
|
+
LLM_ARCH_JINA_BERT_V3,
|
|
584
|
+
{
|
|
585
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
586
|
+
{ LLM_TENSOR_TOKEN_EMBD_NORM, "token_embd_norm" },
|
|
587
|
+
{ LLM_TENSOR_TOKEN_TYPES, "token_types" },
|
|
588
|
+
{ LLM_TENSOR_ATTN_OUT_NORM, "blk.%d.attn_output_norm" },
|
|
589
|
+
{ LLM_TENSOR_ATTN_QKV, "blk.%d.attn_qkv" },
|
|
590
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
591
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
592
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
593
|
+
{ LLM_TENSOR_LAYER_OUT_NORM, "blk.%d.layer_output_norm" },
|
|
594
|
+
},
|
|
595
|
+
},
|
|
571
596
|
{
|
|
572
597
|
LLM_ARCH_BLOOM,
|
|
573
598
|
{
|
|
@@ -1388,6 +1413,40 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1388
1413
|
{ LLM_TENSOR_FFN_POST_NORM, "blk.%d.post_ffw_norm" },
|
|
1389
1414
|
},
|
|
1390
1415
|
},
|
|
1416
|
+
{
|
|
1417
|
+
LLM_ARCH_GLM4_MOE,
|
|
1418
|
+
{
|
|
1419
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
1420
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
1421
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
1422
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
1423
|
+
{ LLM_TENSOR_ATTN_POST_NORM, "blk.%d.post_attention_norm" },
|
|
1424
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
1425
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
1426
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
1427
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
1428
|
+
{ LLM_TENSOR_ATTN_Q_NORM, "blk.%d.attn_q_norm" },
|
|
1429
|
+
{ LLM_TENSOR_ATTN_K_NORM, "blk.%d.attn_k_norm" },
|
|
1430
|
+
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
|
|
1431
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
1432
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1433
|
+
{ LLM_TENSOR_FFN_GATE_INP, "blk.%d.ffn_gate_inp" },
|
|
1434
|
+
{ LLM_TENSOR_FFN_GATE_EXPS, "blk.%d.ffn_gate_exps" },
|
|
1435
|
+
{ LLM_TENSOR_FFN_DOWN_EXPS, "blk.%d.ffn_down_exps" },
|
|
1436
|
+
{ LLM_TENSOR_FFN_UP_EXPS, "blk.%d.ffn_up_exps" },
|
|
1437
|
+
{ LLM_TENSOR_FFN_GATE_SHEXP, "blk.%d.ffn_gate_shexp" },
|
|
1438
|
+
{ LLM_TENSOR_FFN_DOWN_SHEXP, "blk.%d.ffn_down_shexp" },
|
|
1439
|
+
{ LLM_TENSOR_FFN_UP_SHEXP, "blk.%d.ffn_up_shexp" },
|
|
1440
|
+
{ LLM_TENSOR_FFN_EXP_PROBS_B, "blk.%d.exp_probs_b" },
|
|
1441
|
+
// NextN/MTP tensors - preserved but unused (in final layer, dynamic layer number)
|
|
1442
|
+
{ LLM_TENSOR_NEXTN_EH_PROJ, "blk.%d.nextn.eh_proj" },
|
|
1443
|
+
{ LLM_TENSOR_NEXTN_EMBED_TOKENS, "blk.%d.nextn.embed_tokens" },
|
|
1444
|
+
{ LLM_TENSOR_NEXTN_ENORM, "blk.%d.nextn.enorm" },
|
|
1445
|
+
{ LLM_TENSOR_NEXTN_HNORM, "blk.%d.nextn.hnorm" },
|
|
1446
|
+
{ LLM_TENSOR_NEXTN_SHARED_HEAD_HEAD, "blk.%d.nextn.shared_head_head" },
|
|
1447
|
+
{ LLM_TENSOR_NEXTN_SHARED_HEAD_NORM, "blk.%d.nextn.shared_head_norm" },
|
|
1448
|
+
},
|
|
1449
|
+
},
|
|
1391
1450
|
{
|
|
1392
1451
|
LLM_ARCH_BITNET,
|
|
1393
1452
|
{
|
|
@@ -1492,6 +1551,31 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1492
1551
|
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1493
1552
|
},
|
|
1494
1553
|
},
|
|
1554
|
+
{
|
|
1555
|
+
LLM_ARCH_NEMOTRON_H,
|
|
1556
|
+
{
|
|
1557
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
1558
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
1559
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
1560
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
1561
|
+
// mamba(2) ssm layers
|
|
1562
|
+
{ LLM_TENSOR_SSM_IN, "blk.%d.ssm_in" },
|
|
1563
|
+
{ LLM_TENSOR_SSM_CONV1D, "blk.%d.ssm_conv1d" },
|
|
1564
|
+
{ LLM_TENSOR_SSM_DT, "blk.%d.ssm_dt" },
|
|
1565
|
+
{ LLM_TENSOR_SSM_A, "blk.%d.ssm_a" },
|
|
1566
|
+
{ LLM_TENSOR_SSM_D, "blk.%d.ssm_d" },
|
|
1567
|
+
{ LLM_TENSOR_SSM_NORM, "blk.%d.ssm_norm" },
|
|
1568
|
+
{ LLM_TENSOR_SSM_OUT, "blk.%d.ssm_out" },
|
|
1569
|
+
// attention layers
|
|
1570
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
1571
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
1572
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
1573
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
1574
|
+
// dense FFN
|
|
1575
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
1576
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1577
|
+
},
|
|
1578
|
+
},
|
|
1495
1579
|
{
|
|
1496
1580
|
LLM_ARCH_EXAONE,
|
|
1497
1581
|
{
|
|
@@ -1895,6 +1979,26 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1895
1979
|
{ LLM_TENSOR_FFN_UP_EXPS, "blk.%d.ffn_up_exps" },
|
|
1896
1980
|
},
|
|
1897
1981
|
},
|
|
1982
|
+
{
|
|
1983
|
+
LLM_ARCH_HUNYUAN_DENSE,
|
|
1984
|
+
{
|
|
1985
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
1986
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
1987
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
1988
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
1989
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
1990
|
+
{ LLM_TENSOR_ATTN_Q_NORM, "blk.%d.attn_q_norm" },
|
|
1991
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
1992
|
+
{ LLM_TENSOR_ATTN_K_NORM, "blk.%d.attn_k_norm" },
|
|
1993
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
1994
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
1995
|
+
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
|
|
1996
|
+
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
|
|
1997
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
1998
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1999
|
+
|
|
2000
|
+
},
|
|
2001
|
+
},
|
|
1898
2002
|
{
|
|
1899
2003
|
LLM_ARCH_SMOLLM3,
|
|
1900
2004
|
{
|
|
@@ -1912,6 +2016,25 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1912
2016
|
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1913
2017
|
},
|
|
1914
2018
|
},
|
|
2019
|
+
{
|
|
2020
|
+
LLM_ARCH_OPENAI_MOE,
|
|
2021
|
+
{
|
|
2022
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
2023
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
2024
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
2025
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
2026
|
+
{ LLM_TENSOR_ATTN_POST_NORM, "blk.%d.post_attention_norm" },
|
|
2027
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
2028
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
2029
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
2030
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
2031
|
+
{ LLM_TENSOR_ATTN_SINKS, "blk.%d.attn_sinks" },
|
|
2032
|
+
{ LLM_TENSOR_FFN_GATE_INP, "blk.%d.ffn_gate_inp" },
|
|
2033
|
+
{ LLM_TENSOR_FFN_GATE_EXPS, "blk.%d.ffn_gate_exps" },
|
|
2034
|
+
{ LLM_TENSOR_FFN_DOWN_EXPS, "blk.%d.ffn_down_exps" },
|
|
2035
|
+
{ LLM_TENSOR_FFN_UP_EXPS, "blk.%d.ffn_up_exps" },
|
|
2036
|
+
},
|
|
2037
|
+
},
|
|
1915
2038
|
{
|
|
1916
2039
|
LLM_ARCH_LFM2,
|
|
1917
2040
|
{
|
|
@@ -1931,8 +2054,30 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1931
2054
|
{ LLM_TENSOR_SHORTCONV_OUTPROJ, "blk.%d.shortconv.out_proj" },
|
|
1932
2055
|
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
1933
2056
|
{ LLM_TENSOR_TOKEN_EMBD_NORM, "token_embd_norm" },
|
|
2057
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
1934
2058
|
}
|
|
1935
2059
|
},
|
|
2060
|
+
{
|
|
2061
|
+
LLM_ARCH_SMALLTHINKER,
|
|
2062
|
+
{
|
|
2063
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
2064
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
2065
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
2066
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
2067
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
2068
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
2069
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
2070
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
2071
|
+
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
|
|
2072
|
+
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
|
|
2073
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
2074
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
2075
|
+
{ LLM_TENSOR_FFN_GATE_INP, "blk.%d.ffn_gate_inp" },
|
|
2076
|
+
{ LLM_TENSOR_FFN_GATE_EXPS, "blk.%d.ffn_gate_exps" },
|
|
2077
|
+
{ LLM_TENSOR_FFN_DOWN_EXPS, "blk.%d.ffn_down_exps" },
|
|
2078
|
+
{ LLM_TENSOR_FFN_UP_EXPS, "blk.%d.ffn_up_exps" }
|
|
2079
|
+
},
|
|
2080
|
+
},
|
|
1936
2081
|
{
|
|
1937
2082
|
LLM_ARCH_DREAM,
|
|
1938
2083
|
{
|
|
@@ -1950,6 +2095,40 @@ static const std::map<llm_arch, std::map<llm_tensor, const char *>> LLM_TENSOR_N
|
|
|
1950
2095
|
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
1951
2096
|
},
|
|
1952
2097
|
},
|
|
2098
|
+
{
|
|
2099
|
+
LLM_ARCH_LLADA,
|
|
2100
|
+
{
|
|
2101
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
2102
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
2103
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
2104
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
2105
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
2106
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
2107
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
2108
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
2109
|
+
{ LLM_TENSOR_FFN_NORM, "blk.%d.ffn_norm" },
|
|
2110
|
+
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
|
|
2111
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
2112
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
2113
|
+
},
|
|
2114
|
+
},
|
|
2115
|
+
{
|
|
2116
|
+
LLM_ARCH_SEED_OSS,
|
|
2117
|
+
{
|
|
2118
|
+
{ LLM_TENSOR_TOKEN_EMBD, "token_embd" },
|
|
2119
|
+
{ LLM_TENSOR_OUTPUT_NORM, "output_norm" },
|
|
2120
|
+
{ LLM_TENSOR_OUTPUT, "output" },
|
|
2121
|
+
{ LLM_TENSOR_ATTN_NORM, "blk.%d.attn_norm" },
|
|
2122
|
+
{ LLM_TENSOR_ATTN_Q, "blk.%d.attn_q" },
|
|
2123
|
+
{ LLM_TENSOR_ATTN_K, "blk.%d.attn_k" },
|
|
2124
|
+
{ LLM_TENSOR_ATTN_V, "blk.%d.attn_v" },
|
|
2125
|
+
{ LLM_TENSOR_ATTN_OUT, "blk.%d.attn_output" },
|
|
2126
|
+
{ LLM_TENSOR_ATTN_POST_NORM, "blk.%d.post_attention_norm" },
|
|
2127
|
+
{ LLM_TENSOR_FFN_GATE, "blk.%d.ffn_gate" },
|
|
2128
|
+
{ LLM_TENSOR_FFN_DOWN, "blk.%d.ffn_down" },
|
|
2129
|
+
{ LLM_TENSOR_FFN_UP, "blk.%d.ffn_up" },
|
|
2130
|
+
},
|
|
2131
|
+
},
|
|
1953
2132
|
{
|
|
1954
2133
|
LLM_ARCH_UNKNOWN,
|
|
1955
2134
|
{
|
|
@@ -1989,6 +2168,7 @@ static const std::map<llm_tensor, llm_tensor_info> LLM_TENSOR_INFOS = {
|
|
|
1989
2168
|
{LLM_TENSOR_ATTN_KV_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
1990
2169
|
{LLM_TENSOR_ATTN_K_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
1991
2170
|
{LLM_TENSOR_ATTN_V_B, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
2171
|
+
{LLM_TENSOR_ATTN_SINKS, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_SCALE}},
|
|
1992
2172
|
{LLM_TENSOR_DEC_ATTN_Q, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
1993
2173
|
{LLM_TENSOR_DEC_ATTN_K, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
1994
2174
|
{LLM_TENSOR_DEC_ATTN_V, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
@@ -2120,6 +2300,14 @@ static const std::map<llm_tensor, llm_tensor_info> LLM_TENSOR_INFOS = {
|
|
|
2120
2300
|
{LLM_TENSOR_SHORTCONV_CONV, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_SSM_CONV}},
|
|
2121
2301
|
{LLM_TENSOR_SHORTCONV_INPROJ, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
2122
2302
|
{LLM_TENSOR_SHORTCONV_OUTPROJ, {LLM_TENSOR_LAYER_REPEATING, GGML_OP_MUL_MAT}},
|
|
2303
|
+
// NextN/MTP tensors are currently ignored (reserved for future MTP support)
|
|
2304
|
+
// These tensors only exist in the last layer(s) and are treated as output tensors
|
|
2305
|
+
{LLM_TENSOR_NEXTN_EH_PROJ, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL_MAT}},
|
|
2306
|
+
{LLM_TENSOR_NEXTN_EMBED_TOKENS, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_GET_ROWS}},
|
|
2307
|
+
{LLM_TENSOR_NEXTN_ENORM, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_GET_ROWS}},
|
|
2308
|
+
{LLM_TENSOR_NEXTN_HNORM, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL}},
|
|
2309
|
+
{LLM_TENSOR_NEXTN_SHARED_HEAD_HEAD, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL_MAT}},
|
|
2310
|
+
{LLM_TENSOR_NEXTN_SHARED_HEAD_NORM, {LLM_TENSOR_LAYER_OUTPUT, GGML_OP_MUL}},
|
|
2123
2311
|
};
|
|
2124
2312
|
|
|
2125
2313
|
LLM_KV::LLM_KV(llm_arch arch, const char * suffix) : arch(arch), suffix(suffix) {}
|
|
@@ -2193,6 +2381,7 @@ bool llm_arch_is_hybrid(const llm_arch & arch) {
|
|
|
2193
2381
|
case LLM_ARCH_PLAMO2:
|
|
2194
2382
|
case LLM_ARCH_GRANITE_HYBRID:
|
|
2195
2383
|
case LLM_ARCH_LFM2:
|
|
2384
|
+
case LLM_ARCH_NEMOTRON_H:
|
|
2196
2385
|
return true;
|
|
2197
2386
|
default:
|
|
2198
2387
|
return false;
|
|
@@ -2202,6 +2391,7 @@ bool llm_arch_is_hybrid(const llm_arch & arch) {
|
|
|
2202
2391
|
bool llm_arch_is_diffusion(const llm_arch & arch) {
|
|
2203
2392
|
switch (arch) {
|
|
2204
2393
|
case LLM_ARCH_DREAM:
|
|
2394
|
+
case LLM_ARCH_LLADA:
|
|
2205
2395
|
return true;
|
|
2206
2396
|
default:
|
|
2207
2397
|
return false;
|
|
@@ -26,6 +26,7 @@ enum llm_arch {
|
|
|
26
26
|
LLM_ARCH_NOMIC_BERT_MOE,
|
|
27
27
|
LLM_ARCH_NEO_BERT,
|
|
28
28
|
LLM_ARCH_JINA_BERT_V2,
|
|
29
|
+
LLM_ARCH_JINA_BERT_V3,
|
|
29
30
|
LLM_ARCH_BLOOM,
|
|
30
31
|
LLM_ARCH_STABLELM,
|
|
31
32
|
LLM_ARCH_QWEN,
|
|
@@ -66,11 +67,13 @@ enum llm_arch {
|
|
|
66
67
|
LLM_ARCH_DEEPSEEK2,
|
|
67
68
|
LLM_ARCH_CHATGLM,
|
|
68
69
|
LLM_ARCH_GLM4,
|
|
70
|
+
LLM_ARCH_GLM4_MOE,
|
|
69
71
|
LLM_ARCH_BITNET,
|
|
70
72
|
LLM_ARCH_T5,
|
|
71
73
|
LLM_ARCH_T5ENCODER,
|
|
72
74
|
LLM_ARCH_JAIS,
|
|
73
75
|
LLM_ARCH_NEMOTRON,
|
|
76
|
+
LLM_ARCH_NEMOTRON_H,
|
|
74
77
|
LLM_ARCH_EXAONE,
|
|
75
78
|
LLM_ARCH_EXAONE4,
|
|
76
79
|
LLM_ARCH_RWKV6,
|
|
@@ -89,9 +92,14 @@ enum llm_arch {
|
|
|
89
92
|
LLM_ARCH_ERNIE4_5,
|
|
90
93
|
LLM_ARCH_ERNIE4_5_MOE,
|
|
91
94
|
LLM_ARCH_HUNYUAN_MOE,
|
|
95
|
+
LLM_ARCH_HUNYUAN_DENSE,
|
|
92
96
|
LLM_ARCH_SMOLLM3,
|
|
97
|
+
LLM_ARCH_OPENAI_MOE,
|
|
93
98
|
LLM_ARCH_LFM2,
|
|
94
99
|
LLM_ARCH_DREAM,
|
|
100
|
+
LLM_ARCH_SMALLTHINKER,
|
|
101
|
+
LLM_ARCH_LLADA,
|
|
102
|
+
LLM_ARCH_SEED_OSS,
|
|
95
103
|
LLM_ARCH_UNKNOWN,
|
|
96
104
|
};
|
|
97
105
|
|
|
@@ -128,6 +136,7 @@ enum llm_kv {
|
|
|
128
136
|
LLM_KV_EXPERT_WEIGHTS_NORM,
|
|
129
137
|
LLM_KV_EXPERT_GATING_FUNC,
|
|
130
138
|
LLM_KV_MOE_EVERY_N_LAYERS,
|
|
139
|
+
LLM_KV_NEXTN_PREDICT_LAYERS,
|
|
131
140
|
LLM_KV_POOLING_TYPE,
|
|
132
141
|
LLM_KV_LOGIT_SCALE,
|
|
133
142
|
LLM_KV_DECODER_START_TOKEN_ID,
|
|
@@ -223,6 +232,8 @@ enum llm_kv {
|
|
|
223
232
|
|
|
224
233
|
LLM_KV_ADAPTER_TYPE,
|
|
225
234
|
LLM_KV_ADAPTER_LORA_ALPHA,
|
|
235
|
+
LLM_KV_ADAPTER_LORA_TASK_NAME,
|
|
236
|
+
LLM_KV_ADAPTER_LORA_PROMPT_PREFIX,
|
|
226
237
|
|
|
227
238
|
LLM_KV_POSNET_EMBEDDING_LENGTH,
|
|
228
239
|
LLM_KV_POSNET_BLOCK_COUNT,
|
|
@@ -260,6 +271,7 @@ enum llm_tensor {
|
|
|
260
271
|
LLM_TENSOR_ATTN_OUT_NORM,
|
|
261
272
|
LLM_TENSOR_ATTN_POST_NORM,
|
|
262
273
|
LLM_TENSOR_ATTN_ROT_EMBD,
|
|
274
|
+
LLM_TENSOR_ATTN_SINKS,
|
|
263
275
|
LLM_TENSOR_FFN_GATE_INP,
|
|
264
276
|
LLM_TENSOR_FFN_GATE_INP_SHEXP,
|
|
265
277
|
LLM_TENSOR_FFN_NORM,
|
|
@@ -406,6 +418,12 @@ enum llm_tensor {
|
|
|
406
418
|
LLM_TENSOR_SHORTCONV_CONV,
|
|
407
419
|
LLM_TENSOR_SHORTCONV_INPROJ,
|
|
408
420
|
LLM_TENSOR_SHORTCONV_OUTPROJ,
|
|
421
|
+
LLM_TENSOR_NEXTN_EH_PROJ,
|
|
422
|
+
LLM_TENSOR_NEXTN_EMBED_TOKENS,
|
|
423
|
+
LLM_TENSOR_NEXTN_ENORM,
|
|
424
|
+
LLM_TENSOR_NEXTN_HNORM,
|
|
425
|
+
LLM_TENSOR_NEXTN_SHARED_HEAD_HEAD,
|
|
426
|
+
LLM_TENSOR_NEXTN_SHARED_HEAD_NORM,
|
|
409
427
|
};
|
|
410
428
|
|
|
411
429
|
enum llm_tensor_layer {
|
|
@@ -59,7 +59,7 @@ bool llama_batch_allocr::init(
|
|
|
59
59
|
for (int32_t i = 0; i < batch.n_tokens; ++i) {
|
|
60
60
|
for (int32_t s = 0; s < batch.n_seq_id[i]; ++s) {
|
|
61
61
|
if (batch.seq_id && (batch.seq_id[i][s] < 0 || batch.seq_id[i][s] >= (llama_seq_id) n_seq_max)) {
|
|
62
|
-
LLAMA_LOG_ERROR("%s: invalid seq_id[%d][%d] = %d
|
|
62
|
+
LLAMA_LOG_ERROR("%s: invalid seq_id[%d][%d] = %d >= %d\n", __func__, i, s, batch.seq_id[i][s], (llama_seq_id) n_seq_max);
|
|
63
63
|
return false;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -477,7 +477,7 @@ llama_ubatch llama_batch_allocr::split_simple(uint32_t n_ubatch) {
|
|
|
477
477
|
|
|
478
478
|
llama_ubatch llama_batch_allocr::split_equal(uint32_t n_ubatch, bool sequential) {
|
|
479
479
|
if (sequential && has_cpl) {
|
|
480
|
-
LLAMA_LOG_ERROR("%s: sequential split is not supported when there are coupled sequences in the input batch\n", __func__);
|
|
480
|
+
LLAMA_LOG_ERROR("%s: sequential split is not supported when there are coupled sequences in the input batch (you may need to use the -kvu flag)\n", __func__);
|
|
481
481
|
|
|
482
482
|
return {};
|
|
483
483
|
}
|