codec: drop the fused streaming tail

The fused mode appended the codec stream tail to the predictor frame
graph, so one compute produced both a frame's codes and its 80 ms of
audio with no host round trip. The experiment applied to max_batch 1
with a streaming synthesis only, it cost throughput against the
buffered flush that stays the default, and it kept a second frame
graph, its ring inputs and an init flag alive for that single case. It
is not worth keeping.

Remove the tail helpers, the fused graph of CodePredGraphSet, the
codec_fused field of qt_init_params, the --codec-fused flag of both
tools and the harness switch that exercised it. The predictor frame
unroll and the in graph sampler are untouched.
This commit is contained in:
Pascal
2026-08-05 18:20:08 +02:00
parent abab6b3bf3
commit 7b6ed4f6db
13 changed files with 20 additions and 344 deletions
-91
View File
@@ -687,97 +687,6 @@ bool pipeline_codec_decode_stream_batch(PipelineCodec * pc, const int32_t * code
return codec_stream_run(pc, sg, codes, T, M, 0, audio_out);
}
// Append the fused streaming tail: ring inputs created here, the chain
// appended over the lane sets [set0 = 0, M). The caller owns gctx/gf
// and allocates the whole graph afterwards.
bool pipeline_codec_stream_tail_append(PipelineCodec * pc,
struct ggml_context * gctx,
struct ggml_cgraph * gf,
struct ggml_tensor * codes_in,
int T,
int M,
CodecStreamTail * tail) {
const int ring = CODEC_STREAM_RING;
if (!pc->stream_ready) {
qt_log(QT_LOG_ERROR, "[Pipeline] stream tail append before stream state init");
return false;
}
if (pc->transformer.sliding_window + T > ring) {
qt_log(QT_LOG_ERROR, "[Pipeline] sliding window %d plus chunk %d exceeds KV ring %d",
pc->transformer.sliding_window, T, ring);
return false;
}
if (M < 1 || M > pc->stream_sets - 1) {
qt_log(QT_LOG_ERROR, "[Pipeline] invalid stream tail lane count %d", M);
return false;
}
tail->T = T;
tail->M = M;
tail->pos = ggml_new_tensor_1d(gctx, GGML_TYPE_I32, T * M);
tail->rows = ggml_new_tensor_3d(gctx, GGML_TYPE_I64, T, 1, M);
tail->mask = ggml_new_tensor_4d(gctx, GGML_TYPE_F32, ring, T, 1, M);
ggml_set_name(tail->pos, "codec_positions");
ggml_set_name(tail->rows, "codec_kv_rows");
ggml_set_name(tail->mask, "codec_ring_mask");
ggml_set_input(tail->pos);
ggml_set_input(tail->rows);
ggml_set_input(tail->mask);
tail->out = codec_stream_chain_append(pc, gctx, gf, codes_in, tail->pos, tail->rows, tail->mask, 0, M);
return tail->out != NULL;
}
// Upload the per frame ring inputs of the fused tail from the lane
// positions at [set0, set0 + M).
bool pipeline_codec_stream_tail_upload(PipelineCodec * pc, CodecStreamTail * tail, int set0) {
const int T = tail->T;
const int M = tail->M;
const int ring = CODEC_STREAM_RING;
if (!tail->out) {
return false;
}
tail->pos_buf.resize((size_t) T * (size_t) M);
tail->rows_buf.resize((size_t) T * (size_t) M);
static thread_local std::vector<int> pos0;
pos0.assign((size_t) M, 0);
for (int m = 0; m < M; m++) {
int p = pc->stream_pos[(size_t) (set0 + m)];
pos0[m] = p;
for (int t = 0; t < T; t++) {
tail->pos_buf[(size_t) m * (size_t) T + (size_t) t] = p + t;
tail->rows_buf[(size_t) m * (size_t) T + (size_t) t] = (int64_t) ((p + t) % ring);
}
}
ggml_backend_tensor_set(tail->pos, tail->pos_buf.data(), 0, tail->pos_buf.size() * sizeof(int32_t));
ggml_backend_tensor_set(tail->rows, tail->rows_buf.data(), 0, tail->rows_buf.size() * sizeof(int64_t));
tok_trans_build_stream_mask(pos0.data(), T, M, ring, pc->transformer.sliding_window, tail->mask_buf);
ggml_backend_tensor_set(tail->mask, tail->mask_buf.data(), 0, tail->mask_buf.size() * sizeof(float));
return true;
}
// Read every non NULL lane's audio from the fused tail output and
// advance the lane positions. The caller has computed the graph.
bool pipeline_codec_stream_tail_read(PipelineCodec * pc, CodecStreamTail * tail, int set0, float ** audio_out) {
const int T = tail->T;
const int M = tail->M;
if (!tail->out) {
return false;
}
const size_t lane_samples = (size_t) T * (size_t) TOKENIZER_HOP_LENGTH;
for (int m = 0; m < M; m++) {
if (audio_out && audio_out[m]) {
ggml_backend_tensor_get(tail->out, audio_out[m], (size_t) m * lane_samples * sizeof(float),
lane_samples * sizeof(float));
}
pc->stream_pos[(size_t) (set0 + m)] += T;
}
return true;
}
bool pipeline_codec_decode_stream(PipelineCodec * pc, const int32_t * codes, int T, float * audio_out) {
int cls = 0;
while ((1 << cls) < T) {
-30
View File
@@ -194,36 +194,6 @@ bool pipeline_codec_stream_reset(PipelineCodec * pc, int set);
// NULL discards that lane's audio. Every lane's position advances.
bool pipeline_codec_decode_stream_batch(PipelineCodec * pc, const int32_t * codes, int T, int M, float ** audio_out);
// Fused streaming tail: the decode chain appended to a caller owned
// graph, codes read in graph from a caller provided [T, K, M] i32
// tensor instead of a host upload. The caller allocates the graph,
// uploads the per frame ring inputs with
// pipeline_codec_stream_tail_upload before each compute, and reads the
// audio and advances the lane positions with
// pipeline_codec_stream_tail_read after it. Lanes bind the state sets
// [set0, set0 + M).
struct CodecStreamTail {
struct ggml_tensor * pos = nullptr; // [T * M] i32
struct ggml_tensor * rows = nullptr; // [T, 1, M] i64
struct ggml_tensor * mask = nullptr; // [ring, T, 1, M] f32
struct ggml_tensor * out = nullptr; // [T * 1920, 1, M] f32
int T = 0;
int M = 0;
std::vector<int32_t> pos_buf;
std::vector<int64_t> rows_buf;
std::vector<float> mask_buf;
};
bool pipeline_codec_stream_tail_append(PipelineCodec * pc,
struct ggml_context * gctx,
struct ggml_cgraph * gf,
struct ggml_tensor * codes_in,
int T,
int M,
CodecStreamTail * tail);
bool pipeline_codec_stream_tail_upload(PipelineCodec * pc, CodecStreamTail * tail, int set0);
bool pipeline_codec_stream_tail_read(PipelineCodec * pc, CodecStreamTail * tail, int set0, float ** audio_out);
// Decode one chunk of T frames through the STAGING set (the last
// one). codes is [T, K]; audio_out receives T * TOKENIZER_HOP_LENGTH
// samples, NULL discards the audio (ICL reference priming). The
+12 -152
View File
@@ -105,122 +105,16 @@ static void parse_generation_defaults(const GGUFModel & gf, GenerationDefaults &
g.max_new_tokens = (int) gf_get_u32(gf, "generation.max_new_tokens");
}
// Build the fused frame graph for the single slot mode: the unrolled
// predictor passes followed by the codec stream tail at T=1 over lane
// set 0, one cgraph, one compute per frame. The codec reads the codes
// straight from the sampler accumulator through a device view, so the
// codes never round trip the host between the predictor and the
// decode. Requires the codec stream state (reset at slot admit) to be
// allocated, which holds by the time the first frame builds this.
static bool pipeline_tts_fused_graph_build(PipelineTTS * pt, CodePredGraphSet & s) {
const CodePredictorWeights * cw = &pt->code_predictor;
KVCache * kv = &pt->code_predictor_kv;
const int n_layers = cw->num_hidden_layers;
const int n_acoustic = cw->num_acoustic_codebooks;
const int n_codes = n_acoustic + 1;
const int max_nodes = code_predictor_frame_graph_max_nodes(n_layers, n_acoustic) + 4096;
if (n_codes != TOKENIZER_NUM_CODEBOOKS) {
qt_log(QT_LOG_ERROR, "[Pipeline] fused tail codebook mismatch: %d vs %d", n_codes, TOKENIZER_NUM_CODEBOOKS);
return false;
}
CodePredGraph * cp = &s.fused;
const size_t bytes =
ggml_tensor_overhead() * (size_t) max_nodes + ggml_graph_overhead_custom((size_t) max_nodes, false);
struct ggml_init_params gp = { bytes, NULL, true };
cp->ctx = ggml_init(gp);
if (!cp->ctx) {
qt_log(QT_LOG_ERROR, "[Pipeline] fused graph ctx allocation failed");
return false;
}
struct ggml_cgraph * gf = ggml_new_graph_custom(cp->ctx, max_nodes, false);
std::vector<CodePredPassBake> bake;
bake.reserve((size_t) n_acoustic);
struct ggml_tensor * logits = NULL;
code_predictor_pass_append(cp->ctx, gf, cw, kv, pt->talker.codec_embedding, pt->hidden_bridge, &s.sampler, 0, 1,
pt->use_flash_attn, pt->clamp_fp16, &logits, bake);
for (int g = 1; g < n_acoustic; g++) {
code_predictor_pass_append(cp->ctx, gf, cw, kv, cw->codec_embedding[(size_t) (g - 1)], NULL, &s.sampler, g, 1,
pt->use_flash_attn, pt->clamp_fp16, &logits, bake);
}
// Codes bridge: the [1, 16] accumulator is 16 contiguous i32, c0
// first, exactly the [T=1, K=16, M=1] layout the quantizer reads.
struct ggml_tensor * codes_in = ggml_view_3d(cp->ctx, s.sampler.codes, 1, n_codes, 1, s.sampler.codes->nb[1],
(size_t) n_codes * s.sampler.codes->nb[1], 0);
ggml_set_name(codes_in, "fused_codes_bridge");
if (!pipeline_codec_stream_tail_append(&pt->codec, cp->ctx, gf, codes_in, 1, 1, &s.tail)) {
code_predictor_graph_free(cp);
s.tail = {};
return false;
}
cp->galloc = ggml_gallocr_new(ggml_backend_get_default_buffer_type(pt->backend));
if (!cp->galloc || !ggml_gallocr_alloc_graph(cp->galloc, gf)) {
qt_log(QT_LOG_ERROR, "[Pipeline] fused graph allocation failed");
code_predictor_graph_free(cp);
s.tail = {};
return false;
}
code_predictor_bake_upload(bake, 1, kv->max_seq_len);
cp->gf = gf;
cp->logits = logits;
cp->N = 1;
return true;
}
// Run one fused frame for the single slot: sampler upload, codec ring
// upload, one compute, codes readback, then audio readback with the
// lane position advance. Mirrors code_predictor_frame_step for N=1
// plus the codec side of the graph.
static bool pipeline_tts_fused_frame_step(PipelineTTS * pt,
CodePredGraphSet & gs,
const int32_t * c0,
const float * temperature,
const int64_t * seed,
const int64_t * subseq_base,
float * audio,
CodePredictorOutput * out) {
SamplerInputs * sp = &gs.sampler;
const int n_codes = pt->num_code_groups;
ggml_backend_tensor_set(sp->codes, c0, 0, sizeof(int32_t));
sampler_inputs_upload(sp, temperature, seed, subseq_base, 1);
if (!pipeline_codec_stream_tail_upload(&pt->codec, &gs.tail, 0)) {
return false;
}
if (ggml_backend_graph_compute(pt->backend, gs.fused.gf) != GGML_STATUS_SUCCESS) {
qt_log(QT_LOG_ERROR, "[Pipeline] fused frame graph compute failed");
return false;
}
// N=1: the accumulator rows are single scalars, so the slot major
// output equals the row major readback.
out->codes.resize((size_t) n_codes);
ggml_backend_tensor_get(sp->codes, out->codes.data(), 0, (size_t) n_codes * sizeof(int32_t));
float * outs[1] = { audio };
return pipeline_codec_stream_tail_read(&pt->codec, &gs.tail, 0, outs);
}
// Ensure the static predictor graph set for batch width N exists: the
// frame graph, or its fused flavor carrying the codec stream tail,
// over one persistent sampler state. Built lazily on the first frame
// at a given width, then replayed for the process lifetime.
static bool pipeline_tts_cp_graphs_ensure(PipelineTTS * pt, int N, bool fused) {
// frame graph over one persistent sampler state. Built lazily on the
// first frame at a given width, then replayed for the process
// lifetime.
static bool pipeline_tts_cp_graphs_ensure(PipelineTTS * pt, int N) {
if ((int) pt->cp_graphs.size() < N) {
pt->cp_graphs.resize((size_t) N);
}
CodePredGraphSet & s = pt->cp_graphs[(size_t) (N - 1)];
if (fused ? s.fused.ctx != NULL : s.frame.ctx != NULL) {
if (s.frame.ctx != NULL) {
return true;
}
@@ -246,10 +140,6 @@ static bool pipeline_tts_cp_graphs_ensure(PipelineTTS * pt, int N, bool fused) {
ggml_backend_buffer_clear(s.sampler_buf, 0);
}
if (fused) {
return pipeline_tts_fused_graph_build(pt, s);
}
return code_predictor_frame_graph_build(&pt->code_predictor, &pt->code_predictor_kv, pt->backend,
pt->talker.codec_embedding, pt->hidden_bridge, &s.sampler, N,
pt->use_flash_attn, pt->clamp_fp16, &s.frame);
@@ -262,8 +152,7 @@ bool pipeline_tts_load(PipelineTTS * pt,
bool use_fa,
bool clamp_fp16,
int max_batch,
float codec_chunk_sec,
bool codec_fused) {
float codec_chunk_sec) {
pt->bp = bp;
pt->backend = bp.backend;
pt->sched = NULL;
@@ -284,10 +173,6 @@ bool pipeline_tts_load(PipelineTTS * pt,
pt->use_flash_attn = use_fa && bp.has_gpu;
pt->clamp_fp16 = clamp_fp16;
// Fused codec tail: the frame graph decodes its own audio chunk,
// single slot latency mode, effective at max_batch 1 only.
pt->codec_fused = codec_fused && pt->max_batch == 1;
if (!gf_load(&pt->gguf_talker, talker_gguf_path)) {
qt_log(QT_LOG_ERROR, "[Pipeline] failed to load talker GGUF: %s", talker_gguf_path);
return false;
@@ -444,7 +329,7 @@ bool pipeline_tts_load(PipelineTTS * pt,
// on first use.
pt->talker_decode_graphs.resize(((size_t) pt->talker_kv.max_seq_len + 255) / 256);
bool graphs_ok = graph_arena_init(&pt->talker_arena, talker_graph_max_nodes(pt->talker.num_hidden_layers)) &&
pipeline_tts_cp_graphs_ensure(pt, 1, false);
pipeline_tts_cp_graphs_ensure(pt, 1);
if (!graphs_ok) {
for (size_t n = 0; n < pt->cp_graphs.size(); n++) {
code_predictor_graph_set_free(&pt->cp_graphs[n]);
@@ -1325,17 +1210,10 @@ void tts_engine_step(TtsEngine * e, std::vector<TtsJob *> * retired) {
for (int i = 0; i < N; i++) {
any_live = any_live || e->slots[(size_t) i].has_frame;
}
bool fused_frame = false;
if (any_live) {
CodePredictorOutput cp;
std::vector<float> fused_audio;
// Fused single slot mode: predictor and codec run in one graph,
// gated on the slot actually streaming (codec_set 0 reset at
// admit) so the stream state and the audio consumer both exist.
fused_frame = pt->codec_fused && N == 1 && e->slots[0].has_frame && e->slots[0].codec_set == 0;
if (!pipeline_tts_cp_graphs_ensure(pt, N, fused_frame)) {
if (!pipeline_tts_cp_graphs_ensure(pt, N)) {
qt_set_error("pipeline_tts_synthesize: code predictor graph build failed (N=%d)", N);
for (TtsSlot & s : e->slots) {
s.finished = true;
@@ -1364,16 +1242,9 @@ void tts_engine_step(TtsEngine * e, std::vector<TtsJob *> * retired) {
}
}
Timer t_pred;
bool pred_ok;
if (fused_frame) {
fused_audio.resize((size_t) TOKENIZER_HOP_LENGTH);
pred_ok = pipeline_tts_fused_frame_step(pt, gs, c0s.data(), temps.data(), seeds.data(), subseqs.data(),
fused_audio.data(), &cp);
} else {
pred_ok =
code_predictor_frame_step(&pt->code_predictor, pt->backend, &gs.frame, &gs.sampler, c0s.data(), N,
temps.data(), seeds.data(), subseqs.data(), cp_dump, &cp);
}
bool pred_ok =
code_predictor_frame_step(&pt->code_predictor, pt->backend, &gs.frame, &gs.sampler, c0s.data(), N,
temps.data(), seeds.data(), subseqs.data(), cp_dump, &cp);
if (!pred_ok) {
for (TtsSlot & s : e->slots) {
s.finished = true;
@@ -1404,17 +1275,6 @@ void tts_engine_step(TtsEngine * e, std::vector<TtsJob *> * retired) {
s.all_codes.push_back(codes);
s.talker_history.push_back(s.pending_c0);
// Fused mode: this frame's audio came out of the
// same compute, dispatch it now instead of staging
// through the shared codec flush below.
if (fused_frame && p->on_chunk && s.fin_status != QT_STATUS_CANCELLED) {
if (!p->on_chunk(fused_audio.data(), TOKENIZER_HOP_LENGTH, p->on_chunk_user_data)) {
qt_log(QT_LOG_INFO, "[Pipeline] on_chunk callback aborted the synthesis (fused)");
s.finished = true;
s.fin_status = QT_STATUS_CANCELLED;
}
}
// Streaming slots stage this frame through
// all_codes.back() and has_frame; the shared codec
// flush after this loop decodes every lane in one
@@ -1488,7 +1348,7 @@ void tts_engine_step(TtsEngine * e, std::vector<TtsJob *> * retired) {
// every retiring lane leaves with its audio fully dispatched before
// the swap remove below. Zero rows only ever exist in that single
// row flush, which keeps the per lane audio blocks free of padding.
if (e->codec_M > 0 && !fused_frame) {
if (e->codec_M > 0) {
const int num_cg = pt->num_code_groups;
bool any_finish = false;
bool any_stage = false;
+5 -11
View File
@@ -93,14 +93,12 @@ struct PromptCache {
// One set of static predictor graphs for a given batch width: the
// frame graph replays the prefill and every acoustic step in one
// compute, the fused flavor appends the codec stream tail. The
// sampler inputs and the codes accumulator live in their own context
// backed by a persistent backend buffer: every graph of the set reads
// and writes them across replays, so they never enter gallocr pools.
// compute. The sampler inputs and the codes accumulator live in their
// own context backed by a persistent backend buffer: every graph of
// the set reads and writes them across replays, so they never enter
// gallocr pools.
struct CodePredGraphSet {
CodePredGraph frame; // prefill and every acoustic step in one cgraph
CodePredGraph fused; // frame graph with the codec stream tail appended
CodecStreamTail tail; // codec side of the fused graph, tensors live in fused.ctx
SamplerInputs sampler;
struct ggml_context * sampler_ctx = nullptr;
ggml_backend_buffer_t sampler_buf = nullptr;
@@ -108,8 +106,6 @@ struct CodePredGraphSet {
static inline void code_predictor_graph_set_free(CodePredGraphSet * s) {
code_predictor_graph_free(&s->frame);
code_predictor_graph_free(&s->fused);
s->tail = {};
if (s->sampler_buf) {
ggml_backend_buffer_free(s->sampler_buf);
s->sampler_buf = nullptr;
@@ -170,7 +166,6 @@ struct PipelineTTS {
// on sub Ampere CUDA targets.
bool use_flash_attn;
bool clamp_fp16;
bool codec_fused; // frame graph carries the codec stream tail, single slot latency mode
// Persistent KV caches, one set per slot: the talker holds the LM
// contexts, the predictor holds one frame's 16 sub-steps per slot,
@@ -215,8 +210,7 @@ bool pipeline_tts_load(PipelineTTS * pt,
bool use_fa,
bool clamp_fp16,
int max_batch,
float codec_chunk_sec,
bool codec_fused);
float codec_chunk_sec);
void pipeline_tts_free(PipelineTTS * pt);
+1 -2
View File
@@ -225,7 +225,6 @@ void qt_init_default_params(struct qt_init_params * p) {
p->max_batch = 1;
p->codec_chunk_sec = QT_CODEC_CHUNK_SEC_DEFAULT;
p->codec_fused = false;
}
void qt_tts_default_params(struct qt_tts_params * p) {
@@ -363,7 +362,7 @@ struct qt_context * qt_init(const struct qt_init_params * params) {
}
if (!pipeline_tts_load(&q->pt, params->talker_path, params->codec_path, q->bp, params->use_fa,
params->clamp_fp16, max_batch, chunk_sec, params->codec_fused)) {
params->clamp_fp16, max_batch, chunk_sec)) {
qt_throw("qt_init: pipeline_tts_load failed for '%s' / '%s'", params->talker_path, params->codec_path);
}
+1 -9
View File
@@ -157,19 +157,11 @@ struct qt_init_params {
// frames at 12.5 Hz). The streaming path frames its own chunks
// through the persistent codec stream state and reads none of this.
float codec_chunk_sec;
// Fuse the codec streaming tail into the predictor frame graph:
// one compute per frame delivers its 80 ms audio chunk with no
// host round trip between the predictor and the decode. Single
// slot latency mode: requires max_batch 1 and a streaming
// synthesis (on_chunk); throughput drops against the buffered
// flush, which stays the default.
bool codec_fused;
};
// Initialise to the standard defaults: both paths NULL (caller must set
// them before calling qt_init), use_fa true, clamp_fp16 false,
// max_batch 1, codec_chunk_sec 24.0, codec_fused false.
// max_batch 1, codec_chunk_sec 24.0.
QT_API void qt_init_default_params(struct qt_init_params * p);
// Allocate every module described by params. Returns NULL on any
Executable → Regular
-33
View File
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
"""Shared helpers for the qwentts.cpp cossim debug scripts.
Provides Philox uniform stream, dump load and save, install_hooks for the
@@ -396,35 +395,3 @@ GEN_KWARGS_GREEDY = dict(
subtalker_dosample = False,
repetition_penalty = 1.0,
)
def fused_pass(cmd, text, dump_cpp):
"""Re-run the C++ side with --codec-fused (streaming, wav on stdout)
and gate on codes equality against the buffered run: the decode path
cannot change the predictor, so codes-full.bin must match exactly.
The fused audio itself is not scored here, greedy amplitudes vanish
in the streamed PCM_16 and the fused FP envelope has its own
validation against the stream path."""
import subprocess
dump_fused = dump_cpp + "-fused"
os.makedirs(dump_fused, exist_ok=True)
cmd_f = list(cmd)
cmd_f[cmd_f.index("--dump") + 1] = dump_fused
cmd_f[cmd_f.index("-o") + 1] = "-"
cmd_f.append("--codec-fused")
print(f"[GGML] Cmd: {' '.join(cmd_f)}")
r = subprocess.run(cmd_f, input=text.encode(), capture_output=True)
if r.returncode != 0:
sys.stderr.write(r.stderr.decode(errors="replace"))
sys.exit(r.returncode)
# surface the fused run's perf lines next to the buffered ones
# already in the log, so every grid cell carries the comparison
for line in r.stderr.decode(errors="replace").splitlines():
if "[Perf]" in line:
print(line.replace("[Perf]", "[Perf Fused]"))
compare_exact_i32("codes-full.bin", dump_fused, dump_cpp, "CodesFullFused")
-1
View File
@@ -155,7 +155,6 @@ def main():
n = min(aa.size, ab.size)
print(f"[Cossim] WAV stft_cos: {cc.stft_cos(aa.ravel()[:n], ab.ravel()[:n]):.6f} samples: {n}")
cc.fused_pass(cmd, text, DUMP_CPP)
if __name__ == "__main__":
main()
-1
View File
@@ -485,7 +485,6 @@ def main():
n = min(aa.size, ab.size)
print(f"[Cossim] WAV stft_cos: {cc.stft_cos(aa.ravel()[:n], ab.ravel()[:n]):.6f} samples: {n}")
cc.fused_pass(cmd, text, DUMP_CPP)
if __name__ == "__main__":
main()
-1
View File
@@ -181,7 +181,6 @@ def main():
n = min(aa.size, ab.size)
print(f"[Cossim] WAV stft_cos: {cc.stft_cos(aa.ravel()[:n], ab.ravel()[:n]):.6f} samples: {n}")
cc.fused_pass(cmd, text, DUMP_CPP)
if __name__ == "__main__":
main()
-1
View File
@@ -169,7 +169,6 @@ def main():
n = min(aa.size, ab.size)
print(f"[Cossim] WAV stft_cos: {cc.stft_cos(aa.ravel()[:n], ab.ravel()[:n]):.6f} samples: {n}")
cc.fused_pass(cmd, text, DUMP_CPP)
if __name__ == "__main__":
main()
-6
View File
@@ -54,7 +54,6 @@ static void print_usage(const char * prog) {
" --ref-text <path> Transcript file for the reference (enables ICL clone mode)\n"
" --max-new <n> Max new audio frames (default: 2048)\n"
" --codec-chunk-dur <f> Codec decode chunk duration in seconds (default: 24.0)\n"
" --codec-fused Decode each frame's audio inside the predictor graph (streaming only)\n"
" --stream-by-line Flush synthesis at each newline, one WAV header per line (-o '-')\n\n"
"Sampling:\n"
" --seed <int> Sampling seed (default: -1 for random)\n"
@@ -101,7 +100,6 @@ struct Args {
bool clamp_fp16;
bool stream_by_line;
float codec_chunk_sec;
bool codec_fused;
};
// Read all of stdin into a string. Binary mode on Windows so UTF-16 input
@@ -200,7 +198,6 @@ static bool parse_args(int argc, char ** argv, Args & a) {
// Chunk sentinel : qt_init resolves a non positive value to the
// library default.
a.codec_chunk_sec = 0.0f;
a.codec_fused = false;
for (int i = 1; i < argc; i++) {
const char * arg = argv[i];
if (std::strcmp(arg, "-h") == 0 || std::strcmp(arg, "--help") == 0) {
@@ -260,8 +257,6 @@ static bool parse_args(int argc, char ** argv, Args & a) {
a.clamp_fp16 = true;
} else if (std::strcmp(arg, "--stream-by-line") == 0) {
a.stream_by_line = true;
} else if (std::strcmp(arg, "--codec-fused") == 0) {
a.codec_fused = true;
} else if (std::strcmp(arg, "--codec-chunk-dur") == 0 && i + 1 < argc) {
a.codec_chunk_sec = (float) std::atof(argv[++i]);
} else if (std::strcmp(arg, "-o") == 0 && i + 1 < argc) {
@@ -286,7 +281,6 @@ static int run(const Args & a) {
iparams.use_fa = a.use_fa;
iparams.clamp_fp16 = a.clamp_fp16;
iparams.codec_chunk_sec = a.codec_chunk_sec;
iparams.codec_fused = a.codec_fused;
qt_context * q = qt_init(&iparams);
if (!q) {
+1 -6
View File
@@ -52,8 +52,7 @@ static void print_usage(const char * prog) {
" --max-batch <n> Concurrent requests batched on the GPU (default: 1)\n"
" --no-fa Disable flash attention\n"
" --clamp-fp16 Clamp hidden states to FP16 range\n"
" --codec-chunk-dur <f> Codec decode chunk duration in seconds, wav responses (default: 24.0)\n"
" --codec-fused Decode each frame's audio inside the predictor graph (max-batch 1, streaming)\n",
" --codec-chunk-dur <f> Codec decode chunk duration in seconds, wav responses (default: 24.0)\n",
prog);
}
@@ -72,7 +71,6 @@ int main(int argc, char ** argv) {
server_config cfg;
bool use_fa = true;
bool clamp_fp16 = false;
bool codec_fused = false;
int max_batch = 1;
// Chunk sentinel : qt_init resolves a non positive value to the
// library default.
@@ -98,8 +96,6 @@ int main(int argc, char ** argv) {
clamp_fp16 = true;
} else if (!std::strcmp(arg, "--max-batch") && i + 1 < argc) {
max_batch = std::atoi(argv[++i]);
} else if (!std::strcmp(arg, "--codec-fused")) {
codec_fused = true;
} else if (!std::strcmp(arg, "--codec-chunk-dur") && i + 1 < argc) {
codec_chunk_dur = (float) std::atof(argv[++i]);
} else if (!std::strcmp(arg, "--help") || !std::strcmp(arg, "-h")) {
@@ -125,7 +121,6 @@ int main(int argc, char ** argv) {
iparams.clamp_fp16 = clamp_fp16;
iparams.max_batch = max_batch;
iparams.codec_chunk_sec = codec_chunk_dur;
iparams.codec_fused = codec_fused;
struct qt_context * q = qt_init(&iparams);
if (!q) {