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
feat: add PyTorch GPU training support and resolve thread-safety and C-API configuration bugs
b51f437 Download src/c_api.cpp from AndrewThompson1233/maba-instant-v1: direct link, hf CLI and curl.
- Browser
- Download file 4.25 kB
-
https://huggingface.co/AndrewThompson1233/maba-instant-v1/resolve/main/src/c_api.cpp
- Command line
-
hf download hf://AndrewThompson1233/maba-instant-v1/src/c_api.cpp
-
curl -L -o c_api.cpp https://huggingface.co/AndrewThompson1233/maba-instant-v1/resolve/main/src/c_api.cpp
4.25 kB
| 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; | |
| } | |
| } | |
| } | |