ec436095dd
Book-CI / test (macos-latest) (push) Has been cancelled
Book-CI / test (ubuntu-latest) (push) Has been cancelled
Book-CI / test (windows-latest) (push) Has been cancelled
Release Fake Tag / publish (push) Has been cancelled
Deploy / deploy (macos-latest) (push) Has been cancelled
Deploy / deploy (ubuntu-latest) (push) Has been cancelled
Deploy / deploy (windows-latest) (push) Has been cancelled
Release to PyPI / Build & publish sglang-kt (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.11) (push) Has been cancelled
Release to PyPI / Build kt-kernel (Python 3.12) (push) Has been cancelled
Release to PyPI / Publish kt-kernel to PyPI (push) Has been cancelled
90 lines
3.0 KiB
YAML
90 lines
3.0 KiB
YAML
- match:
|
|
class: ktransformers.models.modeling_smallthinker.SmallthinkerRotaryEmbedding
|
|
replace:
|
|
class: ktransformers.operators.RoPE.KSmallthinkerRotaryEmbedding
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
|
|
- match:
|
|
name: "^lm_head$" # regular expression
|
|
class: torch.nn.Linear # only match modules matching name and class simultaneously
|
|
replace:
|
|
class: ktransformers.operators.linear.KTransformersLinear # optimized Kernel on quantized data types
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
generate_op: "VLinearMarlin"
|
|
prefill_op: "KLinearTorch"
|
|
|
|
# - match:
|
|
# name: "^model\\.layers\\..*$" # regular expression
|
|
# class: torch.nn.Linear # only match modules matching name and class simultaneously
|
|
# replace:
|
|
# class: ktransformers.operators.linear.KTransformersLinear # optimized Kernel on quantized data types
|
|
# kwargs:
|
|
# generate_device: "cuda"
|
|
# prefill_device: "cuda"
|
|
# generate_op: "VLinearMarlin"
|
|
# prefill_op: "KLinearTorch"
|
|
- match:
|
|
name: "^model\\.layers\\.(?!.*feed_forward\\.shared_expert_gate).*$" # regular expression
|
|
class: torch.nn.Linear # only match modules matching name and class simultaneously
|
|
replace:
|
|
class: ktransformers.operators.linear.KTransformersLinear # optimized Kernel on quantized data types
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
generate_op: "KLinearMarlin"
|
|
prefill_op: "KLinearTorch"
|
|
- match:
|
|
name: "^model\\.layers\\..*\\.block_sparse_moe$"
|
|
class: ktransformers.models.modeling_smallthinker.SmallthinkerMoeBlock
|
|
replace:
|
|
class: ktransformers.operators.experts.KSmallthinkerMoeBlock
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
|
|
- match:
|
|
name: "^model\\.layers\\..*\\.block_sparse_moe\\.experts$"
|
|
replace:
|
|
class: ktransformers.operators.experts.KSmallthinkerExperts # custom MoE Kernel with expert paralleism
|
|
kwargs:
|
|
prefill_device: "cuda"
|
|
prefill_op: None
|
|
generate_device: "cpu"
|
|
generate_op: "KExpertsCPU"
|
|
out_device: "cuda"
|
|
recursive: False # don't recursively inject submodules of this module
|
|
- match:
|
|
name: "^model\\.layers\\..*\\.self_attn$"
|
|
replace:
|
|
class: ktransformers.operators.balance_serve_attention.KSmallthinkerAttention # optimized MLA implementation
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
|
|
- match:
|
|
name: "^model.embed_tokens"
|
|
replace:
|
|
class: "default"
|
|
kwargs:
|
|
generate_device: "cpu"
|
|
prefill_device: "cpu"
|
|
|
|
- match:
|
|
class: ktransformers.models.modeling_smallthinker.SmallthinkerRMSNorm
|
|
replace:
|
|
class: ktransformers.operators.layernorm.KSmallthinkerRMSNorm
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda"
|
|
|
|
- match:
|
|
class: ktransformers.models.modeling_smallthinker.SmallthinkerDenseMlpBlock
|
|
replace:
|
|
class: ktransformers.operators.mlp.KSmallthinkerDenseMlpBlock
|
|
kwargs:
|
|
generate_device: "cuda"
|
|
prefill_device: "cuda" |