#pragma once
#include "causal_lm/causal_lm.h"
#include "transcribe-backend.h"
#include "transcribe-session.h"
#include "transcribe-mel.h"
#include "transcribe-model.h"
#include "transcribe-tokenizer.h"
#include "weights.h"
#include "ggml.h"
#include "ggml-backend.h"
#include <cstdint>
#include <optional>
#include <string>
#include <vector>
struct ggml_context;
struct ggml_tensor;
struct ggml_backend_buffer;
struct ggml_backend_sched;
typedef struct ggml_backend_buffer * ggml_backend_buffer_t;
typedef struct ggml_backend_sched * ggml_backend_sched_t;
namespace transcribe::voxtral_realtime {
void apply_family_invariants(transcribe_model & model);
struct PromptSpecials {
int32_t bos = -1;
int32_t streaming_pad = -1; int32_t eos = -1;
int32_t n_left_pad = 32; };
struct Model final : public transcribe_model {
Tokenizer tok;
HParams hparams;
Weights weights;
ggml_context * ctx_meta = nullptr;
transcribe::BackendPlan plan;
ggml_backend_buffer_t backend_buffer = nullptr;
transcribe::causal_lm::PackedGateUpHandles packed_gate_up;
std::optional<transcribe::MelFrontend> mel;
PromptSpecials specials;
Model() = default;
~Model() override;
const transcribe::Tokenizer * tokenizer() const override { return &tok; }
};
struct Session final : public transcribe_session {
ggml_context * compute_ctx = nullptr;
ggml_backend_sched_t sched = nullptr;
transcribe::causal_lm::KvCache kv_cache;
transcribe::causal_lm::KvCache kv_cache_batch;
int kv_batch_cap = 0; int kv_batch_n_ctx = 0;
std::vector<float> mel_buf;
std::vector<float> enc_host;
ggml_context * ada_ctx = nullptr;
ggml_backend_buffer_t ada_buffer = nullptr;
ggml_tensor * ada_scale_all = nullptr; std::vector<ggml_tensor *> ada_scale; int ada_num_delay = -1;
bool encoder_use_flash = false;
bool decoder_use_flash = true;
std::vector<float> stream_pcm; int stream_num_delay = -1; int stream_min_decode_ms = -1; int64_t stream_last_decode_samples = 0;
transcribe::causal_lm::KvCache enc_kv; int stream_enc_slot = 0; int stream_enc_abs_base = 0; int stream_n_enc_committed = 0; std::vector<float> stream_conv0_cache; std::vector<float> stream_conv1_cache; int stream_n_mel_committed = 0; int64_t stream_pcm_drop = 0; int stream_audio_base = 0; std::vector<float> stream_audio_embeds; int stream_n_tok_ready = 0; bool stream_prompt_done = false; int stream_dec_pos = 0; int32_t stream_next_tok = 0; bool stream_eos = false;
std::vector<int32_t> stream_generated; int stream_n_audio_clamp = -1;
std::vector<float> stream_gen0_logits;
std::vector<float> stream_gen8_logits;
int64_t stream_t_mel_us = 0; int64_t stream_t_conv_us = 0; int64_t stream_t_enc_us = 0; int64_t stream_t_enc_compute_us = 0; int64_t stream_t_dec_us = 0;
Session() = default;
~Session() override;
};
}