qualia_core_db/gguf_bridge/
projection_adapter.rs1use super::*;
2use etalon_inference::projections::ProjectionProvider;
3impl ProjectionProvider for QTensorEngine {
4 type Index = crate::gguf_sharder::GgufTensorIndex;
5 type Mask = crate::neuro_symbolic_sieve::SieveStateMask;
6 fn logits(index: &Self::Index) -> Option<GgufTensorInfo> {
7 index.logits_projection_info().copied()
8 }
9 fn output_norm(index: &Self::Index) -> Option<GgufTensorInfo> {
10 index.output_norm_info().copied()
11 }
12 fn data_start(index: &Self::Index) -> u64 {
13 index.tensor_data_start
14 }
15 fn embedding_dim(index: &Self::Index) -> usize {
16 index.hyperparams.n_embd as usize
17 }
18 fn model_bytes(&self) -> Option<&[u8]> {
19 QTensorEngine::model_bytes(self)
20 }
21 fn nvfp4_output(&self) -> Option<(&[u8], &[u8], &[u8])> {
22 #[cfg(not(target_arch = "wasm32"))]
23 if let Some(pkg) = self.ftw_package.as_ref() {
24 return Some((
25 pkg.fetch_tensor_bytes("lm_head.weight")?,
26 pkg.fetch_tensor_bytes("lm_head.weight_scale")?,
27 pkg.fetch_tensor_bytes("lm_head.weight_global")?,
28 ));
29 }
30 None
31 }
32 fn fetch_tensor_raw_bytes(&self, info: &GgufTensorInfo) -> Option<&[u8]> {
33 QTensorEngine::fetch_tensor_raw_bytes(self, info)
34 }
35 fn gemm(
36 &self,
37 info: &GgufTensorInfo,
38 raw: &[u8],
39 input: &[f32],
40 out: &mut [f32],
41 n_in: usize,
42 n_out: usize,
43 ) -> bool {
44 self.dispatch_gemm_raw_into(info, raw, input, out, n_in, n_out)
45 }
46 fn allows(mask: &Self::Mask, token: u32) -> bool {
47 mask.allows(token)
48 }
49 fn scrub(&self, values: &mut [f32], n: usize) {
50 scrub_f32_volatile(values, n)
51 }
52}