Repository navigation
chat: add tts_dict for kokoro G2P template - #32397
Conversation
| lines.append(key + "\t" + json.dumps(value[key], ensure_ascii=False, separators=(",", ":"))) | ||
| self.add_string(Keys.Tokenizer.TTS_DICT_N.format(name=name), "\n".join(lines)) |
There was a problem hiding this comment.
Guess it had to happen some day, a little scary to embed JSON though. :)
There was a problem hiding this comment.
Fair enough, I was avoiding adding a new llama.h api
With a new llama_model_meta_arr_str/_n API (similar to the existing meta_val_str), I can have one array for key and another array for value
Pushing a new commit now
| // double to int64, saturating and with nan as 0; a plain cast is undefined outside the int64 range | ||
| inline int64_t float_to_int(double v) { |
There was a problem hiding this comment.
yeah I'm quite lazy to do so, it's actually a little bit related to this PR, the test case "big\t123456789012345678901234567890\n"
but given the change is not too big, you think it's still fine to keep in this PR?
| for (int i = 0; i < gguf_get_n_kv(ctx); i++) { | ||
| gguf_type type = gguf_get_kv_type(ctx, i); | ||
| if (type == GGUF_TYPE_ARRAY) { | ||
| // only the string arrays listed here are kept, see llama_model_meta_arr_str() |
There was a problem hiding this comment.
This has actually always annoyed me, wish there was a better way than just copying stuff here.
There was a problem hiding this comment.
you mean it's copying the full array to llama_model ?
There was a problem hiding this comment.
I don't think we can do better here, since gguf_context is to be destroyed after reading
but I agree that these is an extra copy from llama_model to the downstream code. honestly don't want it but I don't have other choice for now (it need to go round-trip const char* --> std:string in downstream code)
There was a problem hiding this comment.
Yeah, I know, I'm just wishing it was different (like f.ex. if we could have kept gguf_context internally).
* origin/master: (138 commits) qwen4exp : fix graph reallocation from the n-gram table scale (ggml-org#32483) server : return 400 when grammar and ignore_eos are on (ggml-org#32377) ggml-cuda: disable quantized matvec fusion on all Pascal GPUs (ggml-org#32239) Title: CUDA: few-row MMQ for MUL_MAT_ID (ggml-org#32065) ui: turn the live markdown preview off by default (ggml-org#32469) CUDA: use block reductions for whole-row pool_1d (ggml-org#31855) ggml : decode F8_E4M3 to fp32 without ldexpf (ggml-org#32477) llama : keep the k-pool layout prefix on sequence edits (ggml-org#32137) vocab : speed up PLaMo-2/3 tokenizer table build (ggml-org#32249) convert : fix FP8 qwen4exp checkpoints (n-gram table scale, block-scaled FP8) (ggml-org#32476) ui: Llama UI design system: tokens, surfaces and fonts (ggml-org#32468) mtmd: support Minimax-Music3 (ggml-org#32435) chat: add tts_dict for kokoro G2P template (ggml-org#32397) Rotate K/V read order for better L2 cache hit rates (ggml-org#32407) ui: turn conversation tabs off by default (ggml-org#32402) ui: move Llama Chat to SvelteKit 3 and its built-in service worker (ggml-org#32463) qwen3next : apply output projection weight scale (ggml-org#32393) cuda : raise shared mem limit only for the launched kernel (ggml-org#32392) nix: expose a SYCL package (ggml-org#31066) vulkan: disable flip Flash Attention shader on AMD Windows due to a driver bug (ggml-org#32415) ...
…о обеим сторонам Мера glm/scripts/piece9_push_repos_2026-11-18.py показала: у прежнего варианта «перезаписать» force-with-lease стёр бы 2031 строку чужой работы - origin/master уехал на 393a233 (behind 7), пока локальная голова стояла на 49a5e3c. Перезапись поэтому отклонена, правильный путь - мерж, после которого пуш становится fast-forward. Рабочее дерево не сдвинуто: коммит собран commit-tree'ом и запушен хешем, refs/heads/master остаётся на 49a5e3c до окна сборки - в этом же дереве соседний диалог собирает llama-ногу, и переезд файлов под ней изменил бы вход сборки. Что изменено? - дерево мержа e153ac3, родители 49a5e3c (мои 3 коммита) и 393a233 (голова origin/master), общая база 72b8ab1: относительно HEAD мерж приносит ровно входящую дельту - 36 путей, +2031/-144; - mtmd: Minimax-Music3 (ggml-org#32435, d92ea9b) - 21 путь, +1636/-108: новые `tools/mtmd/mtmd-helper-gen.cpp` (+462/-0), `tools/mtmd/models/music3-gen.cpp` (+224/-0), `conversion/minimax_music3.py` (+285/-0), `models/templates/MiniMaxAI-MiniMax-Music3-tts.jinja` (+52/-0); `tools/mtmd/models/yue2-gen.cpp` при этом losing 56 строк (-56) в общий helper; - chat: tts_dict для kokoro G2P (ggml-org#32397, 8d1599f) - 15 путей, +330/-19: `common/chat-tts-norm.cpp` (+29/-1), `common/jinja/value.h` (+20/-2), `include/llama.h` (+11/-0), `tests/test-jinja.cpp` (+165/-2); - ggml: поворот порядка чтения K/V ради попаданий в L2 (ggml-org#32407, 054a1ba) - ровно один путь `ggml/src/ggml-cuda/fattn-mma-f16.cuh` (+64/-16). Это единственное входящее изменение в CUDA-пути, и именно оно обязано попасть в пересборку llama-ноги; - ui: conversation tabs по умолчанию выключены (ggml-org#32402, 513ad7a) - один путь `ui/apps/chat/src/lib/constants/settings.constants.ts` (+1/-1); - три входящих мержа (393a233, 38e21fa, b2c7263) собственного патча не несут - покрыты родителями; - моя сторона сохранена без правок: `LOCAL.ru.md` (blob a98c09e) и `LOCAL.en.md` (blob 5ca52ca) в дереве мержа побайтово равны HEAD, по мне - 2 пути, +66/-0. Зачем? Пока llama.cpp не вмержен, форк-мастер и локальная голова расходятся: приёмка комплекта описывает одно дерево, а живёт другое, и любой «сдвиг кода» в такой паре нечитаем. Мерж закрывает расхождение, не переписывая историю, - откат после него это обычный возврат refs на 393a233. Замеры? Числа секции «Что изменено?» взяты из `git diff --numstat 72b8ab1 393a233` и `git show --numstat <коммит>`, а не из `show --numstat` самого мержа: у мерж-коммита он пуст. - носитель гейта: `glm/scripts/piece10_llama_sync_merge_2026-11-18.py --check` (rc=0): путей пересечения сторон 0, потерянных путей 0 с обеих сторон, 36 входящих и 2 моих пути сверены побайтово по blob; машинный снимок - `glm/2026-11-18_session/piece10-llama-merge-gate.json`; - саботаж-контроль той же меры: `--selftest` (rc=0) - на подставном дереве `ba31391215` (дерево HEAD) гейт находит 36 потерянных входящих путей и 0 потерянных моих, то есть «покрытие полное» не может получиться из пустого сравнения; - `ls-remote` в том же прогоне: refs/heads/master = 393a233 (ожидание записи), merge-base 72b8ab1; страховки `backup/master-remote-2026-11-18` и `backup/master-local-2026-11-18` на месте; - engine к этому вечеру: `git push origin main:main` дал `6d81f011a..7a546bad8`, rc=0 (fast-forward, потеря при перезаписи не измерялась - behind 0). Принятый остаток? - checkout llama.cpp остаётся на 49a5e3c: переезд на голову мержа - в окне сборки, вместе с пересборкой llama-ноги и приёмкой маркеров (Fattn K/V-поворот входит в CUDA-путь); - `bin/` и архив комплекта этим пушем не меняются; - аппрув публикации архива и пересъём сетки 64k-160k - за пользователем. Итог Расхождение форка закрыто мержем, а не перезаписью: пуш был fast-forward, ни одна строка ни с одной стороны не потеряна, что доказано побайтовой сверкой 38 путей и саботаж-контролем той же меры. --- EN: sync: master absorbed origin/master (7 commits), merge without losses on either side The measure `glm/scripts/piece9_push_repos_2026-11-18.py` showed that the previous "overwrite" plan - force-with-lease - would have erased 2031 lines of someone else's work: origin/master had moved to 393a233 (behind 7) while the local head stayed at 49a5e3c. Overwriting is therefore refused; the correct route is a merge, after which the push becomes a fast-forward. The working tree is not moved: the commit was built with commit-tree and pushed by hash, and refs/heads/master stays at 49a5e3c until the build window - a neighbouring dialog builds the llama leg in this very tree, and shifting files under it would change the build input. What changed? - merge tree e153ac3, parents 49a5e3c (my 3 commits) and 393a233 (the origin/master head), common base 72b8ab1: relative to HEAD the merge brings exactly the incoming delta - 36 paths, +2031/-144; - mtmd: Minimax-Music3 (ggml-org#32435, d92ea9b) - 21 paths, +1636/-108: new `tools/mtmd/mtmd-helper-gen.cpp` (+462/-0), `tools/mtmd/models/music3-gen.cpp` (+224/-0), `conversion/minimax_music3.py` (+285/-0), `models/templates/MiniMaxAI-MiniMax-Music3-tts.jinja` (+52/-0); `tools/mtmd/models/yue2-gen.cpp` loses 56 lines (-56) into the shared helper; - chat: tts_dict for the kokoro G2P (ggml-org#32397, 8d1599f) - 15 paths, +330/-19: `common/chat-tts-norm.cpp` (+29/-1), `common/jinja/value.h` (+20/-2), `include/llama.h` (+11/-0), `tests/test-jinja.cpp` (+165/-2); - ggml: rotated K/V read order for better L2 cache hits (ggml-org#32407, 054a1ba) - exactly one path `ggml/src/ggml-cuda/fattn-mma-f16.cuh` (+64/-16). This is the only incoming change inside the CUDA path, and it is precisely what the llama-leg rebuild has to pick up; - ui: conversation tabs off by default (ggml-org#32402, 513ad7a) - one path `ui/apps/chat/src/lib/constants/settings.constants.ts` (+1/-1); - the three incoming merges (393a233, 38e21fa, b2c7263) carry no patch of their own - they are covered by their parents; - my side is preserved untouched: `LOCAL.ru.md` (blob a98c09e) and `LOCAL.en.md` (blob 5ca52ca) are byte-identical to HEAD in the merge tree; my side totals 2 paths, +66/-0. Why? Until llama.cpp is merged, the fork master and the local head diverge: kit acceptance describes one tree while another one lives, and any "code shift" measured across such a pair is unreadable. The merge closes the divergence without rewriting history - rolling it back is a plain refs reset to 393a233. Verified The numbers in "What changed?" come from `git diff --numstat 72b8ab1 393a233` and `git show --numstat <commit>`, not from `show --numstat` of the merge itself, which is empty for a merge commit. - gate carrier: `glm/scripts/piece10_llama_sync_merge_2026-11-18.py --check` (rc=0): 0 overlapping paths, 0 lost paths on either side, 36 incoming and 2 of my paths compared byte-wise by blob; the machine snapshot is `glm/2026-11-18_session/piece10-llama-merge-gate.json`; - sabotage control of the same measure: `--selftest` (rc=0) - against a fake tree `ba31391215` (the HEAD tree) the gate finds 36 lost incoming paths and 0 lost paths of mine, so "coverage complete" cannot come out of an empty comparison; - `ls-remote` in the same run: refs/heads/master = 393a233 (the expectation for the write), merge-base 72b8ab1; the insurance tags `backup/master-remote-2026-11-18` and `backup/master-local-2026-11-18` are in place; - engine earlier this evening: `git push origin main:main` gave `6d81f011a..7a546bad8`, rc=0 (fast-forward; no overwrite loss to measure - behind 0). Accepted remainder - the llama.cpp checkout stays at 49a5e3c: moving onto the merge head belongs to the build window, together with rebuilding the llama leg and marker acceptance (the Fattn K/V rotation is inside the CUDA path); - `bin/` and the kit archive are not touched by this push; - approving the archive publication and re-shooting the 64k-160k grid remain with the user. Result The fork divergence is closed by a merge rather than an overwrite: the push was a fast-forward and not a single line from either side was lost, proven by a byte-wise comparison of 38 paths and by the sabotage control of the same measure.
* chat: add tts_dict for kokoro G2P template * more testing * value_float_t range check * no json-in-meta, add llama_model_meta_arr_str/_n
* chat: add tts_dict for kokoro G2P template * more testing * value_float_t range check * no json-in-meta, add llama_model_meta_arr_str/_n
* chat: add tts_dict for kokoro G2P template * more testing * value_float_t range check * no json-in-meta, add llama_model_meta_arr_str/_n
Overview
Add a built-in function
tts_dictthat allows storing pronunciation lexicon in GGUF (usually a large array)Planned for G2P (grapheme-to-phoneme) jinja template for kokoro TTS model
Requirements