MCPcopy Create free account
hub / github.com/andrewkchan/deepseek.cpp / Block

Method Block

src/model.cpp:149–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147};
148
149Block::Block(
150 int layer_i,
151 const std::shared_ptr<Config> config,
152 const Tensor* rms_att_weight,
153 const Tensor* rms_ffn_weight,
154 const Tensor* w1,
155 const Tensor* s1,
156 const Tensor* w2,
157 const Tensor* s2,
158 const Tensor* w3,
159 const Tensor* s3,
160 const Tensor* shared_w1,
161 const Tensor* shared_s1,
162 const Tensor* shared_w2,
163 const Tensor* shared_s2,
164 const Tensor* shared_w3,
165 const Tensor* shared_s3,
166 const Tensor* moegate,
167 const Tensor* moegate_bias
168) : _layer_i(layer_i), _config(config) {
169 switch (config->weight_quant) {
170 case Quant::F32:
171 case Quant::F16:
172 case Quant::F8E5M2:
173 case Quant::Q2_K:
174 case Quant::Q3_K: {
175 break;
176 }
177 default: {
178 std::cerr << "FATAL: unsupported weight quantization: " << quant_to_string(config->weight_quant) << std::endl;
179 assert(false);
180 break;
181 }
182 }
183
184 _rms_att_weight = check_tensor(
185 rms_att_weight, Quant::F32, {config->dim, 0, 0, 0}, __LINE__
186 );
187 _rms_ffn_weight = check_tensor(
188 rms_ffn_weight, Quant::F32, {config->dim, 0, 0, 0}, __LINE__
189 );
190
191 bool need_block_scales = _config->weight_quant == Quant::F8E5M2;
192 int b0 = config->block_size[0];
193 int b1 = config->block_size[1];
194
195 if (config->n_routed_experts > 0 && layer_i >= config->first_k_dense_replace) {
196 _moegate = check_tensor(
197 moegate, Quant::F32, {config->n_routed_experts, config->dim, 0, 0}, __LINE__
198 );
199 if (moegate_bias != nullptr) {
200 _moegate_bias = check_tensor(
201 moegate_bias, Quant::F32, {config->n_routed_experts, 0, 0, 0}, __LINE__
202 );
203 }
204 _w1 = check_tensor(
205 w1, config->weight_quant, {config->n_routed_experts, config->moe_intermediate_size, config->dim, 0}, __LINE__
206 );

Callers

nothing calls this directly

Calls 3

quant_to_stringFunction · 0.85
check_tensorFunction · 0.85
cdivFunction · 0.85

Tested by

no test coverage detected