Archived
LoRA for image and video generators: - civitai and Hugging Face adapter files as published: kohya, ComfyUI and diffusers/PEFT key names; LoRA, LoCon, LoHa, LoKr and full-weight diffs; DoRA, OFT and Tucker are refused by name - stacked per request with a strength each, through the `loras` field or <lora:name:strength> tags in the prompt; --lora-dir serves every file in a directory, GET /v1/loras lists them, and --max-loras / --max-lora-rank size the slots on the card (generators default to rank 64) - Krea 2, Qwen-Image 2.1, FLUX.3 [klein], MiniMax H3, LTX-2.5, Anima and SDXL New models: - Anima (base, aesthetic and turbo): Cosmos-Predict2 DiT with the Qwen3-0.6B text encoder and the Qwen-Image VAE, on one card - Stable Diffusion XL and its single-file finetunes (Illustrious, NoobAI including V-Pred, Pony), read as civitai ships them, with the Euler, Euler a and DPM++ 2M samplers Recipes: - q38-27b-mxfp4-df2: any bf16 Qwen3.8-27B or finetune at MXFP4 with the DFlash2 drafter - Krea 2 finetunes from civitai: scripts/krea2_native.py reads Krea's own key names, and krea-2-fp8-unscaled keeps a plain-fp8 file's codes exactly Changes: --max-num-batched-tokens defaults to 2048 (was 8192). Plugin ABI 25: out-of-tree plugins must be rebuilt.
77 lines
3.1 KiB
Python
77 lines
3.1 KiB
Python
"""gen_grapheme_ucd.py -- writes core/text/tokenizer_grapheme_ucd.cpp, the Unicode properties the
|
|
extended grapheme cluster rules (UAX #29) read.
|
|
|
|
HuggingFace tokenizers' `Precompiled` normaliser walks its text by extended grapheme clusters
|
|
(the unicode-segmentation crate, Unicode 16.0.0), so the cluster boundaries are part of what a
|
|
SentencePiece-derived tokenizer.json means. The tables come from the UCD files of that version:
|
|
|
|
https://www.unicode.org/Public/16.0.0/ucd/auxiliary/GraphemeBreakProperty.txt
|
|
https://www.unicode.org/Public/16.0.0/ucd/emoji/emoji-data.txt
|
|
https://www.unicode.org/Public/16.0.0/ucd/DerivedCoreProperties.txt
|
|
|
|
python3 tools/gen_grapheme_ucd.py <dir holding the three files> > core/text/tokenizer_grapheme_ucd.cpp
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
GCB = ["Other", "CR", "LF", "Control", "Extend", "ZWJ", "Regional_Indicator", "Prepend",
|
|
"SpacingMark", "L", "V", "T", "LV", "LVT"]
|
|
INCB = ["None", "Linker", "Consonant", "Extend"]
|
|
|
|
|
|
def ranges(path, want):
|
|
"""(first, last, value) for every line whose property is `want(prop)` (a value or None)."""
|
|
out = []
|
|
for line in open(path, encoding="utf-8"):
|
|
line = line.split("#", 1)[0].strip()
|
|
if not line:
|
|
continue
|
|
f = [x.strip() for x in line.split(";")]
|
|
v = want(f[1:])
|
|
if v is None:
|
|
continue
|
|
a = f[0].split("..")
|
|
lo = int(a[0], 16)
|
|
hi = int(a[1], 16) if len(a) > 1 else lo
|
|
out.append((lo, hi, v))
|
|
out.sort()
|
|
merged = []
|
|
for lo, hi, v in out:
|
|
if merged and merged[-1][2] == v and merged[-1][1] + 1 == lo:
|
|
merged[-1] = (merged[-1][0], hi, v)
|
|
else:
|
|
merged.append((lo, hi, v))
|
|
return merged
|
|
|
|
|
|
def main():
|
|
d = sys.argv[1]
|
|
gcb = ranges(os.path.join(d, "GraphemeBreakProperty.txt"),
|
|
lambda f: GCB.index(f[0]) if f[0] in GCB else None)
|
|
pict = ranges(os.path.join(d, "emoji-data.txt"),
|
|
lambda f: 1 if f[0] == "Extended_Pictographic" else None)
|
|
incb = ranges(os.path.join(d, "DerivedCoreProperties.txt"),
|
|
lambda f: INCB.index(f[1]) if f[0] == "InCB" and f[1] in INCB else None)
|
|
w = sys.stdout.write
|
|
w("/* tokenizer_grapheme_ucd.cpp -- GENERATED by tools/gen_grapheme_ucd.py from the Unicode "
|
|
"16.0.0 UCD;\n * do not edit. The properties UAX #29's extended grapheme cluster rules read "
|
|
"(tokenizer_grapheme.h). */\n")
|
|
w('#include "text/tokenizer_grapheme.h"\n\nnamespace rad {\nnamespace ucd {\n\n')
|
|
w("const GbRange k_gcb[] = {\n")
|
|
for lo, hi, v in gcb:
|
|
w(" { 0x%X, 0x%X, %d },\n" % (lo, hi, v))
|
|
w("};\nconst size_t k_gcb_n = sizeof k_gcb / sizeof k_gcb[0];\n\n")
|
|
w("const GbRange k_ext_pict[] = {\n")
|
|
for lo, hi, v in pict:
|
|
w(" { 0x%X, 0x%X, %d },\n" % (lo, hi, v))
|
|
w("};\nconst size_t k_ext_pict_n = sizeof k_ext_pict / sizeof k_ext_pict[0];\n\n")
|
|
w("const GbRange k_incb[] = {\n")
|
|
for lo, hi, v in incb:
|
|
w(" { 0x%X, 0x%X, %d },\n" % (lo, hi, v))
|
|
w("};\nconst size_t k_incb_n = sizeof k_incb / sizeof k_incb[0];\n\n")
|
|
w("} /* namespace ucd */\n} /* namespace rad */\n")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|