16 Logger::error(
"Token ID out of bounds in lookup_embedding: " +
17 std::to_string(token_id));
18 return std::vector<float>(
hs, 0.0f);
26 ") is not divisible by GGML_QK_K (" +
27 std::to_string(
GGML_QK_K) +
") for Q4_K embedding lookup.");
37 "Calculated block index out of bounds for Q4_K embedding table. "
39 std::to_string(token_id) +
63 ") is not divisible by GGML_QK8_0 (" +
65 ") for Q8_0 embedding lookup.");
74 "Calculated block index out of bounds for Q8_0 embedding table. "
76 std::to_string(token_id) +
97 for (
int i = 0;
i <
hs; ++
i) {
102 Logger::info(
"[Q8_0_EMBED_FINAL] Token " + std::to_string(token_id) +
103 " embedding stats: sum=" + std::to_string(
sum) +
104 ", mean=" + std::to_string(
sum /
hs) +
105 ", min=" + std::to_string(
min_val) +
106 ", max=" + std::to_string(
max_val) +
118 ") is not divisible by GGML_QK_K (" +
119 std::to_string(
GGML_QK_K) +
") for Q6_K embedding lookup.");
128 "Calculated block index out of bounds for Q6_K embedding table. "
130 std::to_string(token_id) +
152 Logger::error(
"Q5_K embedding table: hidden size " + std::to_string(
hs) +
" or token " +
153 std::to_string(token_id) +
" does not fit its " + std::to_string(
embed_tokens_q5k.size()) +
162 size_t offset = (
size_t)token_id *
hs;
164 Logger::error(
"Embedding offset out of bounds in F32 lookup for token: " +
165 std::to_string(token_id));
174 size_t offset = (
size_t)token_id *
hs;
177 "Embedding offset out of bounds in BF16 lookup for token: " +
178 std::to_string(token_id));
189 "No valid embedding table found (Q4_K, Q8_0, Q6_K, F32, BF16) for token: " +
190 std::to_string(token_id));
197 Logger::info(
"[ROPE_FREQ_ENTRY] Entered initialize_rope_freqs.");
201 Logger::error(
"Cannot initialize RoPE frequencies: num_attention_heads is zero.");
207 Logger::error(
"Cannot initialize RoPE frequencies: calculated head_dim is zero.");
212 Logger::error(
"Cannot initialize RoPE frequencies: head_dim must be even.");
226 Logger::warning(
"RoPE precomputation resulted in zero size. Max seq len: " +
236 float freq = 1.0f / std::pow(rope_theta,
float(
i) /
head_dim);
static void warning(const std::string &message)
static void info(const std::string &message)
static void error(const std::string &message)
std::vector< block_q6_K > embed_tokens_q6k
std::vector< float > lookup_embedding(int token_id)
Lookup the embedding vector for a given token ID.
void initialize_rope_freqs()
int get_vocab_size() const
Get the vocabulary size for the model.
std::vector< std::pair< float, float > > precomputed_freqs_cis_
std::vector< block_q8_0 > embed_tokens_q8_0
std::vector< block_q4_K > embed_tokens_q4k
std::vector< block_q5_K > embed_tokens_q5k
std::vector< uint16_t > embed_tokens
std::vector< float > embed_tokens_f32
constexpr size_t GGML_QK8_0
constexpr size_t GGML_QK_K
Block size constants for different quantization formats.
Logging utilities for the TinyLlama implementation.
Constants used throughout the TinyLlama model implementation.
constexpr float ROPE_THETA
constexpr int MAX_SEQUENCE_LENGTH
void dequantize_q4_k_m(const block_q4_K *qblock, float *output, int num_weights_in_block, bool log_this_block)
void dequantize_q5_k(const block_q5_K *qblock, float *output)
void dequantize_q8_0_block(const block_q8_0 *qblock, float *output)
Dequantizes a Q8_0 block to float32.
void dequantize_q6_k(const block_q6_K *qblock, float *output, int num_weights_in_block, bool log_this_block)
Weight quantization structures and functions for model compression.
int max_position_embeddings
std::vector< float > bf16vec_to_float_vec(const std::vector< uint16_t > &v_bf16)