mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-01-27 01:29:51 +00:00
* gmp-oss: common * gpt-oss: attnetion sinks, swiglu_oai * gpt-oss: WIP llama Model loads and runs (CPU only), but PPL is much to high (~1500 for 1st batch vs ~200 in mainline). Is it because of SWA, because of vocab, or did I introduce a bug somewhere? * gpt-oss: CPU seems to be working It was the SWA thta was missing in the previous commit. There are issues with EOG tokens, so this still needs to be added. * CUDA: ADD_ID Just a copy from mainline * gpt-oss: Seems to be working on CUDA * gpt-oss: add sinks to the attn-vec kernels * CUDA: add head size of 64 to new mma Haven't turned it on yet, but observe slightly better PP and slightly worse TG performance with that. * gpt-oss: add ability to use -fmoe (only CUDA for now) * Move row sums to the write place * Add sinks to iqk flash attention * gpt_oss: Implement -fmoe on the CPU * Simdify swiglu_oai Turning it off for now as performance becomes more variable, so perhaps I'm running into thermal trottling imore often because of making the CPU work too hard. * llama: factor out model loader * Builds successfully * It runs, but mmap does not work * Fix llama_mmap so mmap works * Minor * Fix CUDA after latest changes * Attempt to use CUDA graphs with MoE models - not working * CUDA graphs WIP - still not working * CUDA graphs - seems to be working Likely not all MLA variants are working. I no longer remember why I added the q8_0 cpy that transposes the tensor, but if really needed, this is now missing. Also missing is q6_0. * Make q8_0 cache work for DeepSeek models with CUDA graphs * cuda: cpy for q6_0 * Fix llama_mmap on non-Linux platforms * Adding forgotten file * Iterating on Windows build failures * cuda: re-add q8_0 -> q8_0 transpose so mla = 2 can be used with CUDA graphs and q8_0 cache. * Disable graphs without -fmoe * Minor * Turn graphs on by default --------- Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
69 lines
2.2 KiB
C++
69 lines
2.2 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
struct unicode_cpt_flags {
|
|
enum {
|
|
UNDEFINED = 0x0001,
|
|
NUMBER = 0x0002, // regex: \p{N}
|
|
LETTER = 0x0004, // regex: \p{L}
|
|
SEPARATOR = 0x0008, // regex: \p{Z}
|
|
ACCENT_MARK = 0x0010, // regex: \p{M}
|
|
PUNCTUATION = 0x0020, // regex: \p{P}
|
|
SYMBOL = 0x0040, // regex: \p{S}
|
|
CONTROL = 0x0080, // regex: \p{C}
|
|
MASK_CATEGORIES = 0x00FF,
|
|
};
|
|
|
|
// codepoint type
|
|
uint16_t is_undefined : 1;
|
|
uint16_t is_number : 1; // regex: \p{N}
|
|
uint16_t is_letter : 1; // regex: \p{L}
|
|
uint16_t is_separator : 1; // regex: \p{Z}
|
|
uint16_t is_accent_mark : 1; // regex: \p{M}
|
|
uint16_t is_punctuation : 1; // regex: \p{P}
|
|
uint16_t is_symbol : 1; // regex: \p{S}
|
|
uint16_t is_control : 1; // regex: \p{C}
|
|
// helper flags
|
|
uint16_t is_whitespace : 1; // regex: \s
|
|
uint16_t is_lowercase : 1;
|
|
uint16_t is_uppercase : 1;
|
|
uint16_t is_nfd : 1;
|
|
|
|
// decode from uint16
|
|
inline unicode_cpt_flags(const uint16_t flags = 0) {
|
|
*reinterpret_cast<uint16_t*>(this) = flags;
|
|
}
|
|
|
|
inline uint16_t as_uint() const {
|
|
return *reinterpret_cast<const uint16_t*>(this);
|
|
}
|
|
|
|
inline uint16_t category_flag() const {
|
|
return this->as_uint() & MASK_CATEGORIES;
|
|
}
|
|
};
|
|
|
|
size_t unicode_len_utf8(char src);
|
|
|
|
std::string unicode_cpt_to_utf8 (uint32_t cpt);
|
|
uint32_t unicode_cpt_from_utf8(const std::string & utf8, size_t & offset);
|
|
|
|
std::vector<uint32_t> unicode_cpts_from_utf8(const std::string & utf8);
|
|
|
|
std::vector<uint32_t> unicode_cpts_normalize_nfd(const std::vector<uint32_t> & cpts);
|
|
|
|
unicode_cpt_flags unicode_cpt_flags_from_cpt (uint32_t cpt);
|
|
unicode_cpt_flags unicode_cpt_flags_from_utf8(const std::string & utf8);
|
|
|
|
std::string unicode_byte_to_utf8(uint8_t byte);
|
|
uint8_t unicode_utf8_to_byte(const std::string & utf8);
|
|
|
|
uint32_t unicode_tolower(uint32_t cpt);
|
|
|
|
bool unicode_cpt_is_han(uint32_t cpt);
|
|
|
|
std::vector<std::string> unicode_regex_split(const std::string & text, const std::vector<std::string> & regex_exprs);
|