114
114
115
115
// bump if necessary
116
116
#define LLAMA_MAX_NODES 8192
117
- #define LLAMA_MAX_LAYERS 256
117
+ #define LLAMA_MAX_LAYERS 512
118
118
#define LLAMA_MAX_EXPERTS 160 // DeepSeekV2
119
119
120
120
//
@@ -4008,7 +4008,9 @@ struct llama_model_loader {
4008
4008
throw std::runtime_error(format("%s is not a float32, int32 array", key.c_str()));
4009
4009
}
4010
4010
4011
- GGML_ASSERT(arr_info.length <= N_MAX);
4011
+ if (arr_info.length > N_MAX) {
4012
+ throw std::runtime_error(format("array length %u for key %s exceeds max %u", (uint32_t) arr_info.length, key.c_str(), (uint32_t) N_MAX));
4013
+ }
4012
4014
4013
4015
std::copy((const T*)arr_info.data, (const T *)arr_info.data + arr_info.length, result.begin());
4014
4016
@@ -4044,8 +4046,6 @@ struct llama_model_loader {
4044
4046
// get array of n <= N_MAX elements, or a single element repeated n times
4045
4047
template<typename T, size_t N_MAX>
4046
4048
bool get_key_or_arr(const std::string & key, std::array<T, N_MAX> & result, uint32_t n, const bool required = true) {
4047
- GGML_ASSERT(n <= N_MAX);
4048
-
4049
4049
const int kid = gguf_find_key(meta, key.c_str());
4050
4050
4051
4051
if (kid < 0) {
@@ -4055,6 +4055,10 @@ struct llama_model_loader {
4055
4055
return false;
4056
4056
}
4057
4057
4058
+ if (n > N_MAX) {
4059
+ throw std::runtime_error(format("n > N_MAX: %u > %u for key %s", (uint32_t) n, (uint32_t) N_MAX, key.c_str()));
4060
+ }
4061
+
4058
4062
if (gguf_get_kv_type(meta, kid) == GGUF_TYPE_ARRAY) {
4059
4063
struct GGUFMeta::ArrayInfo arr_info =
4060
4064
GGUFMeta::GKV<GGUFMeta::ArrayInfo>::get_kv(meta, kid);
@@ -19920,7 +19924,7 @@ size_t llama_state_get_size(const struct llama_context * ctx) {
19920
19924
);
19921
19925
19922
19926
// on session change it is very likely that the state size has changed - so we need to update this function
19923
- static_assert(LLAMA_SESSION_VERSION == 6 , "So you just bumped the session version - good. But did you remember to update llama_state_get_size?");
19927
+ static_assert(LLAMA_SESSION_VERSION == 7 , "So you just bumped the session version - good. But did you remember to update llama_state_get_size?");
19924
19928
19925
19929
return s_total;
19926
19930
}
0 commit comments