char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
fa88ae936
char/aliceai-t5-moe
1from __future__import annotations 2 3from typing import TYPE_CHECKING 4 5if TYPE_CHECKING : 6from torch import Tensor 7 8from .base import ModelBase ,gguf 9 10from .qwen import Qwen2MoeModel 11 12 13@ ModelBase . register ( "Dots1ForCausalLM" ) 14@ ModelBase . example ( "rednote-hilab/dots.llm1.inst" ) 15class Dots1Model (Qwen2MoeModel ): 16model_arch = gguf .MODEL_ARCH .DOTS1 17 18def __init__ (self ,* args ,** kwargs ): 19super ().__init__ (* args ,** kwargs ) 20self .hparams ["num_experts" ]= self .hparams ["n_routed_experts" ] 21 22def set_gguf_parameters (self ): 23super ().set_gguf_parameters () 24self .gguf_writer .add_leading_dense_block_count (self .hparams ["first_k_dense_replace" ]) 25self .gguf_writer .add_expert_shared_count (self .hparams ["n_shared_experts" ]) 26self .gguf_writer .add_expert_weights_scale (self .hparams ["routed_scaling_factor" ]) 27self .gguf_writer .add_expert_weights_norm (self .hparams ["norm_topk_prob" ]) 28 29def modify_tensors (self ,data_torch :Tensor ,name :str ,bid :int | None ): 30if "shared_experts" in name : 31yield from ModelBase .modify_tensors (self ,data_torch ,name ,bid ) 32else : 33yield from super ().modify_tensors (data_torch ,name ,bid )