Skip to content

test: fix MOSS live sample path - #351

Merged
CrispStrobe merged 6 commits into
mainfrom
fix/344-moss-valid-frame-metadata
Aug 13, 2026
Merged

test: fix MOSS live sample path#351
CrispStrobe merged 6 commits into
mainfrom
fix/344-moss-valid-frame-metadata

Conversation

@CrispStrobe

Copy link
Copy Markdown
Owner

Fixes the Kaggle live-test harness: the binary runs outside the repository, so the relative samples/jfk.wav path produced an empty PCM buffer. The test now receives the absolute source-tree sample directory from CMake.

Local targeted build and formatting checks pass. This is a follow-up to #349.

jajmangold and others added 6 commits August 11, 2026 20:54
Additive MOSS-Audio/MOSS-Music encoder/tap/adapter metadata for the
downstream MOSS-Music-8B-Thinking feature pipeline. All existing
moss_audio_* symbols and behaviour are preserved.

- moss_audio_plan_chunks(): pure per-chunk valid-frame bookkeeping
  (3x stride-2 conv over 400-frame chunks); the single source of
  valid counts shared by both encoder entrypoints, so metadata can
  never drift from the chunk loop.
- moss_audio_compute_mel_meta(): reports the observed PRE-PAD mel
  length alongside the same padded tensor as compute_mel(); the
  pre-pad value is never inferred from padded zeros or a floor.
- moss_audio_run_encoder_meta(): executes and trims using exactly
  T_mel_actual (validated 1..T_mel, fail-closed otherwise), returns
  only real-content 1280-D encoder/tap frames, and fills caller-
  allocated per-chunk valid counts with out_total_valid == out_T_enc
  == sum(valid_counts). Byte-identical to run_encoder() when no pad.
- Load-time fail-closed check: llm.hidden_size must equal the
  adapter down_proj output-row shape; adapter out dim reported from
  the weight (ne[1]), not a hardcoded 2560.
- Header docs: fixed stale 2560-only comment (4096 for MOSS-Music),
  ownership, synchronous copies, single-inflight/non-reentrancy,
  cached-encoder-graph invalidation.
- Tests: hermetic CPU test (sum(valid)==total, sub-30s pad
  exclusion) plus a live differential test that skips without
  CRISPASR_MODEL_MOSS_AUDIO.

Validation: full Release build green; hermetic test 208 assertions
pass; clang-format-18 clean; trailmark entrypoints 17->20 (+3) with
run_encoder complexity 38->4 (logic moved to shared impl).
B1 from adversarial review of 872ce72: moss_audio_run_encoder_impl frees
tap buffers on its graph-alloc/compute/missing-tensor failure paths but
left the caller-facing ds_results slots pointing at freed memory; both
run_encoder wrappers then unconditionally published those slots into
*ds_tap_0/1/2 even when returning NULL, handing callers dangling non-NULL
pointers on failure.

- Wrappers now write the tap out-pointers only on success (r != nullptr),
  restoring the pre-refactor contract: on failure *ds_tap_x are not
  modified, so they can never dangle.
- Impl failure paths also null their ds_results slots alongside the frees
  as defense-in-depth.
- Header docs state the failure contract for both entrypoints.
- Hermetic regression test pins the wrapper invariant at the observable
  boundary (any NULL-returning call leaves caller tap pointers untouched);
  deep alloc/compute failures cannot be forced without a loaded model.
  Verified red against the pre-fix source, green post-fix.

Validation: Release build green; hermetic test 220 assertions / 4 cases
pass; trailmark structural diff shows only the two wrapper guards
(complexity +1 each) and impl line spans, no call-graph or ABI changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants