Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.
Python cliconsumer-gpudpofine-tuningggufhuggingfacellmllmopslocal-ailocal-llmloralow-vrammachine-learningollamapeftpythonpytorchqlorasfttransformers
- Layer streaming admits Kimi K2 (
model_type: kimi_k2). Kimi-K2-Base and Kimi-K2-Instruct are DeepSeek-V3's decoder in DeepSeek-V3's FP8 block format, but theirconfig.jsondeclaresmodel_type: kimi_k2with anauto_maponto the repository's own code, soAutoConfigrefused them as custom code before the architecture list was reached (layer streaming never runs a repository's model code). The streamed model's config is now read from that file as plain data into transformers' ownDeepseekV3Config(model_typeset todeepseek_v3,auto_mapdropped), after a guard that admits a K2 config only where that class computes what K2's own code computes:noaux_tcsigmoid routing with one expert group, top-k of at least 2 under renormalisation, every layer pastfirst_k_dense_replacean MoE layer,num_key_value_headsequal to the head count, only the yarn rope keys K2 reads, unquantised or DeepSeek-V3 block FP8 weights, every top-level field of the published K2-Base / K2-Instructconfig.jsonpresent (onlyauto_mapandquantization_configmay be left out: a missingrope_thetawould otherwise take the native default 10000.0), and no field outside it (besides three metadata keys). A config that fails any of them is refused before the tokenizer or any weight is loaded, naming every such field and its value and saying that other K2 releases are out of scope for now; Kimi-K2-Thinking (compressed-tensors INT4) is refused asquantization_config.quant_method='compressed-tensors', and Kimi-K2-Instruct-0905 for the fields its file adds (ep_size,pad_token_idand serialised defaults). In the gate (benchmarks/gate-kimi-k2-admission.md) the field-by-field config check fails as registered on one field: transformers addsrope_thetaandrope_typetorope_scaling, as it does for any DeepSeek-V3 config. The other checks pass. A tiny K2-like checkpoint (the published config with tiny dimensions) streams bit for bit like a residentDeepseekV3ForCausalLMon the same weights (logits, loss, LoRA gradients;fusedandper_expert; bf16 and FP8 block), and the disk pre-flight sizes the published Base layout exactly: 533.2 GB per_expert and 2.04 TB fused underquantization: 4bit(benchmarks/gate-kimi-k2-admission.md; CPU only, no K2 weights downloaded, nothing trained on K2). K2's tokenizer is repository code: it needs--trust-remote-code, which reaches the tokenizer only, andpip install tiktoken, which Soup does not install; a failed tokenizer load on a K2 base now says so. The streamed tokenizer load is handed the config already loaded: before, with--trust-remote-code,AutoTokenizerread the config again with that flag and, for a repository with anauto_map, imported and ran its configuration module (configuration_deepseek.pyon K2, and on Moonlight-16B since #1933). Known differences from K2's own code remain: the MoE combine's rounding and eager versus sdpa attention. Known limit: on a full-size K2, transformers'DeepseekV3NaiveMoebriefly allocatestorch.empty(384, 4096, 7168)bf16 on the CPU per MoE layer (about 22.5 GB of commit) before accelerate moves it to meta, in the setup's NF4 /moe_loraprobe and inbuild_streamed_model; RSS barely moves, but a box without that commit headroom fails with a rawDefaultCPUAllocatorerror (DeepSeek-V3 had the same before, at about 15 GB). (#2107)