Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

1011 B
Raw Blame
#pragma once

#include <ATen/Tensor.h>
#include <vector>
#include <pybind11/pybind11.h>
namespace py = pybind11;

struct BC_GatedRMSNorm
{
    at::Tensor weight;
    float rms_norm_eps;
    float constant_bias;
    int w_groups;       // Mamba2 group norm: weight row selected by (row % w_groups)
    bool gate_first;    // Mamba2 style: y = norm(x * silu(g)) * w
    int gate_act;       // 0 = silu, 1 = sigmoid (KDA)

    BC_GatedRMSNorm
    (
        at::Tensor _weight,
        float _rms_norm_eps,
        float _constant_bias,
        int _w_groups = 1,
        bool _gate_first = false,
        int _gate_act = 0
    ) :
        weight(std::move(_weight)),
        rms_norm_eps(_rms_norm_eps),
        constant_bias(_constant_bias),
        w_groups(_w_groups),
        gate_first(_gate_first),
        gate_act(_gate_act)
    {}

    void run(const at::Tensor& x, at::Tensor& y, const at::Tensor& gate);
    void run_gr(const at::Tensor& x, at::Tensor& y, const at::Tensor& gate, class Graph* graph);
};