Text Generation
RWKV
English
maba-instant
maba
maba-instant-v1
architecture
custom-architecture
state-space-model
ssm
mamba
mamba-3
recurrent
dgda
decoupled-gated-delta-attention
gated-deltanet
linear-attention
linear-recurrence
mla
multi-head-latent-attention
deepseek
flow-matching
continuous-flow
non-autoregressive
speculative-decoding
low-latency
microsecond-latency
cpu-inference
avx-512
avx2
simd
cpp
c++
fast-exit
early-exit
rlcd
brier-score
calibration
hft
algorithmic-trading
order-book
real-time
on-device
edge-ai
efficient-inference
zero-kv-cache
arena-allocator
sub-quadratic
llm
nlp
Instructions to use AndrewThompson1233/maba-instant-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- RWKV
How to use AndrewThompson1233/maba-instant-v1 with RWKV:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
File size: 4,251 Bytes
9ceb2d7 b51f437 9ceb2d7 b51f437 9ceb2d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | #include "maba_instant/c_api.h"
#include "maba_instant/pipeline.hpp"
#include <cstdlib>
#include <cstring>
#include <vector>
extern "C" {
maba_c_config_t maba_default_config(void) {
maba_c_config_t cfg;
cfg.dim_model = 256;
cfg.ssm_state_dim = 32;
cfg.canvas_len = 32;
cfg.canvas_dim = 128;
cfg.vocab_size = 512;
cfg.exit_threshold = 0.85f;
cfg.entropy_threshold = 0.05f;
cfg.entropy_stop = 0.01f;
cfg.temperature = 1.0f;
cfg.recurrence_kind = 1;
cfg.dgda_heads = 4;
cfg.dgda_dk = 32;
cfg.dgda_dv = 32;
cfg.mla_latent_dim = 64;
cfg.indexer_block_size = 16;
cfg.num_choices = 4;
return cfg;
}
maba_handle_t maba_create(const maba_c_config_t* c_cfg) {
if (!c_cfg) return nullptr;
maba::Config cfg;
cfg.dim_model = c_cfg->dim_model;
cfg.ssm_state_dim = c_cfg->ssm_state_dim;
cfg.canvas_len = c_cfg->canvas_len;
cfg.canvas_dim = c_cfg->canvas_dim;
cfg.vocab_size = c_cfg->vocab_size;
cfg.exit_threshold = c_cfg->exit_threshold;
cfg.entropy_threshold = c_cfg->entropy_threshold;
cfg.entropy_stop = c_cfg->entropy_stop;
cfg.temperature = c_cfg->temperature;
cfg.recurrence = static_cast<maba::RecurrenceKind>(c_cfg->recurrence_kind);
cfg.dgda_heads = c_cfg->dgda_heads > 0 ? c_cfg->dgda_heads : 4;
cfg.dgda_dk = c_cfg->dgda_dk > 0 ? c_cfg->dgda_dk : 32;
cfg.dgda_dv = c_cfg->dgda_dv > 0 ? c_cfg->dgda_dv : 32;
cfg.mla_latent_dim = c_cfg->mla_latent_dim > 0 ? c_cfg->mla_latent_dim : 64;
cfg.indexer_block_size = c_cfg->indexer_block_size > 0 ? c_cfg->indexer_block_size : 16;
cfg.num_choices = c_cfg->num_choices > 0 ? c_cfg->num_choices : 4;
try {
auto* pipe = new maba::MabaPipeline(cfg);
return static_cast<maba_handle_t>(pipe);
} catch (...) {
return nullptr;
}
}
void maba_destroy(maba_handle_t handle) {
if (handle) {
auto* pipe = static_cast<maba::MabaPipeline*>(handle);
delete pipe;
}
}
void maba_reset(maba_handle_t handle) {
if (handle) {
auto* pipe = static_cast<maba::MabaPipeline*>(handle);
pipe->reset_state();
}
}
int maba_process(
maba_handle_t handle,
const float* input_vec,
int schema_kind,
int force_generate,
maba_c_output_t* out
) {
if (!handle || !input_vec || !out) return -1;
auto* pipe = static_cast<maba::MabaPipeline*>(handle);
const auto& res = pipe->process(
input_vec,
static_cast<maba::SchemaKind>(schema_kind),
force_generate != 0
);
out->decision.kind = static_cast<int>(res.decision.kind);
out->decision.choice_idx = res.decision.choice_idx;
out->decision.score = res.decision.score;
out->decision.noul = res.decision.noul ? 1 : 0;
out->decision.confidence = res.decision.confidence;
out->decision.fast_exit = res.decision.fast_exit ? 1 : 0;
out->latency.tier0_us = res.latency.tier0_us;
out->latency.tier1_us = res.latency.tier1_us;
out->latency.tier2_us = res.latency.tier2_us;
out->latency.total_us = res.latency.total_us;
out->latency.per_token_us = res.latency.per_token_us;
out->latency.tok_per_sec = res.latency.tok_per_sec;
size_t len = res.span.token_ids.size();
out->span.length = len;
out->span.mean_entropy = res.span.mean_entropy;
out->span.flow_steps = res.span.flow_steps;
if (len > 0) {
out->span.token_ids = static_cast<int32_t*>(std::malloc(len * sizeof(int32_t)));
out->span.entropies = static_cast<float*>(std::malloc(len * sizeof(float)));
for (size_t i = 0; i < len; ++i) {
out->span.token_ids[i] = static_cast<int32_t>(res.span.token_ids[i]);
out->span.entropies[i] = res.span.entropies[i];
}
} else {
out->span.token_ids = nullptr;
out->span.entropies = nullptr;
}
return 0;
}
void maba_free_output(maba_c_output_t* out) {
if (out) {
if (out->span.token_ids) {
std::free(out->span.token_ids);
out->span.token_ids = nullptr;
}
if (out->span.entropies) {
std::free(out->span.entropies);
out->span.entropies = nullptr;
}
out->span.length = 0;
}
}
}
|