align symbol naming on omnivoice convention

This commit is contained in:
Pascal
2026-05-14 18:09:07 +02:00
parent e55ba50b75
commit 259e7059f6
21 changed files with 562 additions and 590 deletions
+40 -40
View File
@@ -9,7 +9,7 @@
* 2. Every public qwen_* symbol has C linkage and links from a C
* translation unit.
* 3. The structs are POD and zero-initialisable with `{0}` from C.
* 4. The qwen_log_set callback routes formatted messages from the lib
* 4. The qt_log_set callback routes formatted messages from the lib
* to the user, and abi_version validation rejects future structs.
*
* If this test stops compiling or stops linking, the public ABI has
@@ -24,12 +24,12 @@
/* Counter incremented by the stub log callback. The probe checks that at
* least one log line was routed through the callback by triggering a
* qwen_init failure (which emits a [qwen] ERROR line via qt_log). */
* qt_init failure (which emits a [qwen] ERROR line via qt_log). */
static int g_log_lines = 0;
static enum qwen_log_level g_last_log_level = QWEN_LOG_DEBUG;
static enum qt_log_level g_last_log_level = QT_LOG_DEBUG;
static char g_last_log_msg[512] = { 0 };
static void stub_log(enum qwen_log_level level, const char * msg, void * user_data) {
static void stub_log(enum qt_log_level level, const char * msg, void * user_data) {
(void) user_data;
g_log_lines++;
g_last_log_level = level;
@@ -45,100 +45,100 @@ static void stub_log(enum qwen_log_level level, const char * msg, void * user_da
int main(void) {
/* Static version string, always reachable. */
const char * version = qwen_version();
const char * version = qt_version();
printf("[Probe] %s\n", version);
/* Default-initialise the public structs from C. */
struct qwen_init_params iparams;
qwen_init_default_params(&iparams);
struct qt_init_params iparams;
qt_init_default_params(&iparams);
struct qwen_tts_params params;
qwen_tts_default_params(&params);
struct qt_tts_params params;
qt_tts_default_params(&params);
/* Sanity-check a few default values, including the abi_version. */
if (params.max_new_tokens != 2048 || params.temperature != 0.9f) {
fprintf(stderr, "[Probe] default values do not match\n");
return 1;
}
if (iparams.abi_version != QWEN_ABI_VERSION || params.abi_version != QWEN_ABI_VERSION) {
if (iparams.abi_version != QT_ABI_VERSION || params.abi_version != QT_ABI_VERSION) {
fprintf(stderr, "[Probe] abi_version not set by qwen_*_default_params\n");
return 1;
}
/* Touch every output struct field so the compiler validates the
* layout end-to-end without ever needing a model. */
struct qwen_audio audio = { 0 };
qwen_audio_free(&audio);
struct qt_audio audio = { 0 };
qt_audio_free(&audio);
/* Install the log callback before the failing init so the [qwen]
* ERROR line lands on stub_log instead of stderr. */
qwen_log_set(stub_log, NULL);
qt_log_set(stub_log, NULL);
/* Call every entry through its early-return path. qwen_init returns
* NULL on missing talker_path / codec_path, qwen_synthesize fails on
* NULL handle, qwen_free is safe on NULL. None of these load a model,
/* Call every entry through its early-return path. qt_init returns
* NULL on missing talker_path / codec_path, qt_synthesize fails on
* NULL handle, qt_free is safe on NULL. None of these load a model,
* but the linker must resolve every name to satisfy the call. */
struct qwen_context * dummy = qwen_init(NULL);
struct qt_context * dummy = qt_init(NULL);
if (dummy != NULL) {
fprintf(stderr, "[Probe] qwen_init(NULL) was supposed to return NULL\n");
qwen_free(dummy);
fprintf(stderr, "[Probe] qt_init(NULL) was supposed to return NULL\n");
qt_free(dummy);
return 2;
}
/* qwen_init(NULL) just failed -> qwen_last_error() must point to a
/* qt_init(NULL) just failed -> qt_last_error() must point to a
* non-empty thread-local string. Pointer is always valid (c_str on
* an empty std::string still gives a NUL byte), so we only need to
* check the first byte to confirm an error was actually recorded. */
const char * err = qwen_last_error();
const char * err = qt_last_error();
if (err == NULL || err[0] == '\0') {
fprintf(stderr, "[Probe] qwen_last_error() empty after a known failure\n");
fprintf(stderr, "[Probe] qt_last_error() empty after a known failure\n");
return 5;
}
/* The same failure must have surfaced through the log callback at
* ERROR level. */
if (g_log_lines == 0) {
fprintf(stderr, "[Probe] qwen_log_set callback never invoked\n");
fprintf(stderr, "[Probe] qt_log_set callback never invoked\n");
return 6;
}
if (g_last_log_level != QWEN_LOG_ERROR) {
if (g_last_log_level != QT_LOG_ERROR) {
fprintf(stderr, "[Probe] last log level was %d, expected %d\n", (int) g_last_log_level,
(int) QWEN_LOG_ERROR);
(int) QT_LOG_ERROR);
return 7;
}
printf("[Probe] qwen_log_set routed %d line(s), last: '%s'\n", g_log_lines, g_last_log_msg);
printf("[Probe] qwen_last_error reads '%s'\n", err);
printf("[Probe] qt_log_set routed %d line(s), last: '%s'\n", g_log_lines, g_last_log_msg);
printf("[Probe] qt_last_error reads '%s'\n", err);
/* abi_version validation : a struct claiming a future ABI must be
* rejected up front, before any allocation. Both paths are filled
* with placeholders so the NULL guard does not short-circuit the
* abi_version branch. */
struct qwen_init_params future_iparams;
qwen_init_default_params(&future_iparams);
struct qt_init_params future_iparams;
qt_init_default_params(&future_iparams);
future_iparams.talker_path = "irrelevant.gguf";
future_iparams.codec_path = "irrelevant.gguf";
future_iparams.abi_version = QWEN_ABI_VERSION + 1;
struct qwen_context * rejected = qwen_init(&future_iparams);
future_iparams.abi_version = QT_ABI_VERSION + 1;
struct qt_context * rejected = qt_init(&future_iparams);
if (rejected != NULL) {
fprintf(stderr, "[Probe] qwen_init accepted a future abi_version\n");
qwen_free(rejected);
fprintf(stderr, "[Probe] qt_init accepted a future abi_version\n");
qt_free(rejected);
return 8;
}
enum qwen_status rc = qwen_synthesize(NULL, &params, &audio);
if (rc != QWEN_STATUS_INVALID_PARAMS) {
fprintf(stderr, "[Probe] qwen_synthesize(NULL) returned %d, expected %d\n", (int) rc,
(int) QWEN_STATUS_INVALID_PARAMS);
enum qt_status rc = qt_synthesize(NULL, &params, &audio);
if (rc != QT_STATUS_INVALID_PARAMS) {
fprintf(stderr, "[Probe] qt_synthesize(NULL) returned %d, expected %d\n", (int) rc,
(int) QT_STATUS_INVALID_PARAMS);
return 3;
}
/* Restore the default stderr fallback before exit so the trailing
* [qwen] log lines from the cleanup paths land where the user
* expects them. */
qwen_log_set(NULL, NULL);
qt_log_set(NULL, NULL);
qwen_free(NULL);
qwen_audio_free(&audio);
qt_free(NULL);
qt_audio_free(&audio);
return 0;
}
+1 -1
View File
@@ -116,7 +116,7 @@ def install_clone_hooks(model, dump_dir):
# [4] resnet, [5] ELU, [6] down 5x, [7] resnet, [8] ELU, [9] down 6x,
# [10] resnet, [11] ELU, [12] down 8x, [13] ELU, [14] last MimiConv1d.
# We hook the init conv and the three downsample convs the C++ side
# exposes as out-params in qwen_seanet_encoder_forward.
# exposes as out-params in seanet_encoder_forward.
sn_layers = enc.encoder.layers
seen_sn_init = {"done": False}