Skip to main content

qualia_core_db/inference/qwen/
mod.rs

1//! Qwen hybrid architecture execution and state management (Work Package F11).
2//!
3//! Implements GatedDeltaNet convolution, linear-attention recurrent updates,
4//! and dual-state checkpointing for Qwen3.6 MoE on the RTX A2000.
5
6/// Qwen4Exp MoE top-k width — shared by residency metadata (wasm-safe) and streamed MoE (native).
7pub const QWEN4EXP_TOP_EXPERTS: usize = 10;
8/// Qwen4Exp routed expert bank size (native streamed MoE geometry).
9pub const QWEN4EXP_EXPERT_COUNT: usize = 512;
10
11pub mod checkpoint;
12#[cfg(not(target_arch = "wasm32"))]
13pub mod decode;
14#[cfg(test)]
15mod etalon_compat_tests;
16pub mod expert_residency;
17#[cfg(not(target_arch = "wasm32"))]
18pub mod expert_tile;
19pub mod gated_deltanet;
20pub mod graph_contract;
21pub mod hyper_connection;
22#[cfg(not(target_arch = "wasm32"))]
23pub mod native_asset;
24#[cfg(not(target_arch = "wasm32"))]
25pub mod native_runtime;
26#[cfg(not(target_arch = "wasm32"))]
27pub mod retained;
28#[cfg(not(target_arch = "wasm32"))]
29mod metadata;
30pub mod numerics;
31#[cfg(not(target_arch = "wasm32"))]
32pub mod ple_block;
33pub mod ple_ngram;
34#[cfg(not(target_arch = "wasm32"))]
35pub mod ple_nvme;
36pub mod storage_plan;
37#[cfg(not(target_arch = "wasm32"))]
38pub mod streamed_gdn;
39#[cfg(not(target_arch = "wasm32"))]
40pub mod streamed_hyper;
41#[cfg(not(target_arch = "wasm32"))]
42pub mod streamed_layer;
43#[cfg(not(target_arch = "wasm32"))]
44pub mod streamed_moe;
45#[cfg(not(target_arch = "wasm32"))]
46pub mod streamed_qsa;
47#[cfg(not(target_arch = "wasm32"))]
48pub mod trunk_nvme;
49
50pub use checkpoint::{QwenCheckpointRegistry, QwenDualCheckpoint};
51#[cfg(not(target_arch = "wasm32"))]
52pub use decode::{
53    decode_step, decode_tokens, Qwen4ExpDecodeError, Qwen4ExpDecodeReceipt, Qwen4ExpDecodeScratch,
54    Qwen4ExpSession, Qwen4ExpTraceRecord, QWEN4EXP_TRACE_META_LAYER,
55};
56pub use expert_residency::{
57    QwenExpertAccess, QwenExpertKey, QwenExpertResidency, MAX_QWEN_EXPERT_SLOTS,
58};
59#[cfg(not(target_arch = "wasm32"))]
60pub use expert_tile::{
61    admit_expert_tile, load_expert_tile_descriptor, promote_expert_tile, QwenExpertPlane,
62    QwenExpertTileAdmission, QwenExpertTileDescriptor, QwenExpertTileError,
63    QwenExpertTilePlaneKind, QwenExpertTileReader, QWEN_EXPERT_TILE_FORMAT,
64    QWEN_EXPERT_TILE_SUFFIX,
65};
66pub use gated_deltanet::{
67    step_causal_conv1d, step_gated_deltanet, QwenStateError, CAUSAL_CONV_KERNEL,
68};
69pub use graph_contract::{
70    validate_qwen4exp_graph, Qwen4ExpGraphError, Qwen4ExpGraphReport, Qwen4ExpLayerContract,
71    QWEN4EXP_LAYER_GDN, QWEN4EXP_LAYER_HC_ATTN, QWEN4EXP_LAYER_HC_FFN, QWEN4EXP_LAYER_MOE,
72    QWEN4EXP_LAYER_PLE, QWEN4EXP_LAYER_QSA,
73};
74pub use hyper_connection::{
75    group_rms_norm_in_place, group_rms_norm_into, inject_stream_update, mix_streams_into,
76};
77#[cfg(not(target_arch = "wasm32"))]
78pub use native_asset::{
79    load_qwen4exp_native_hmc, prepare_qwen4exp_native_hmc, ExternalGgufAsset,
80    Qwen4ExpNativeAssetError, Qwen4ExpNativeDescriptor, Qwen4ExpPleSpan, QWEN4EXP_NATIVE_FORMAT,
81};
82#[cfg(not(target_arch = "wasm32"))]
83pub use native_runtime::{Qwen4ExpActivationError, Qwen4ExpNativeRuntime, Qwen4ExpTrunkResidency};
84pub use numerics::{add_assign, add_into, rms_norm_into, QwenNumericError};
85#[cfg(not(target_arch = "wasm32"))]
86pub use ple_block::{
87    execute_ple_block, PleBlockBuffers, PleBlockError, QWEN4EXP_HYPER_STREAMS, QWEN4EXP_PLE_HISTORY,
88};
89pub use ple_ngram::{
90    select_rows as select_ple_rows, sort_dedup_rows, PleNgramError, PleTokenHistory,
91};
92#[cfg(not(target_arch = "wasm32"))]
93pub use ple_nvme::{PleGatherReceipt, PleIoStats, PleNvmeError, PleNvmeReader};
94pub use storage_plan::{
95    plan_qwen4exp_storage, Qwen4ExpStorageError, Qwen4ExpStoragePlan,
96    DEFAULT_QWEN4EXP_HOST_OS_FLOOR,
97};
98#[cfg(not(target_arch = "wasm32"))]
99pub use streamed_gdn::{
100    execute_streamed_gated_delta, GatedDeltaBuffers, GatedDeltaError, GatedDeltaState,
101    QWEN4EXP_GDN_HEADS, QWEN4EXP_GDN_HEAD_DIM, QWEN4EXP_GDN_KEY_HEADS,
102};
103#[cfg(not(target_arch = "wasm32"))]
104pub use streamed_hyper::{
105    execute_streamed_final_hyper_connection, execute_streamed_hyper_connection,
106    inject_hyper_update, mix_hyper_streams, StreamedHyperBuffers, StreamedHyperError,
107};
108#[cfg(not(target_arch = "wasm32"))]
109pub use streamed_layer::{
110    execute_streamed_gdn_moe_layer, execute_streamed_qsa_moe_layer, StreamedGdnMoeLayerBuffers,
111    StreamedLayerError, StreamedMoeBuffers, StreamedQsaMoeLayerBuffers,
112};
113#[cfg(not(target_arch = "wasm32"))]
114pub use streamed_moe::{
115    execute_streamed_moe, execute_streamed_moe_with_tiles, normalize_top_experts,
116    select_top_experts, StreamedMoeError,
117};
118#[cfg(not(target_arch = "wasm32"))]
119pub use streamed_qsa::{
120    execute_streamed_qsa, QsaState, StreamedQsaBuffers, StreamedQsaError,
121    QWEN4EXP_QSA_COMPRESS_RATIO, QWEN4EXP_QSA_HEAD_DIM, QWEN4EXP_QSA_INDEXER_HEADS,
122    QWEN4EXP_QSA_INDEXER_HEAD_DIM, QWEN4EXP_QSA_KV_HEADS, QWEN4EXP_QSA_MAX_SELECTED,
123    QWEN4EXP_QSA_QUERY_HEADS, QWEN4EXP_QSA_ROTARY_DIM, QWEN4EXP_QSA_TOP_BLOCKS, QWEN4EXP_QSA_TOP_K,
124};
125#[cfg(not(target_arch = "wasm32"))]
126pub use trunk_nvme::{StreamedArgmax, TrunkIoStats, TrunkNvmeError, TrunkNvmeReader};