Skip to content

yue2: export the semantic token stream as a result artifact - #635

Merged
0xShug0 merged 1 commit into
0xShug0:mainfrom
engival:yue2-semantic-export
Sep 21, 2026
Merged

0xShug0 merged 1 commit into
0xShug0:mainfrom
engival:yue2-semantic-export

Conversation

@engival

@engival engival commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #561, for the second half of the AR stream. export_semantic=true attaches a semantic artifact next to score. It is the semantic stage output as a flat JSON array of codec indices: one integer per frame (25 frames/s), each in [0, 32768], with no stop token. With --out-dir the CLI writes semantic.json. The server returns it in artifacts like any other. It is off by default, so a request that doesn't set the option is unchanged.

Why: it's the first step toward saving a take and continuing from it later. A follow-up PR adds a semantic_prefix request option.

Scope: model-local (src/models/yue2/, include/engine/models/yue2/), plus the spec entry, the docs and one path-test case. No framework, file-sink, server or WebUI changes.

  • The MIME type is application/vnd.yue2.semantic+json. It is not application/json, so the file sink writes the payload raw and doesn't hex-wrap it.
  • format is yue2-semantic-codec, so the WebUI's ABC detection (/abc|score/i) doesn't pick it up.

Validation (Vulkan, Intel Arc Pro B70; cot=full, semantic_max_tokens=640, 8 steps, seed 1234):

  • Audio is byte-identical to dev at 542bb4e, with the option off and with it on (same sha256 for all three WAVs).
  • Option off: no semantic artifact. Option on: semantic.json with 640 integers, all in range. frames = 640, matching the audio length (640 × 1920 − 64 samples, the VAE's existing tail crop). truncated reports true when the stage stops on semantic_max_tokens.
  • The new path case yue2_semantic_export (audio + artifact) passes.
  • audiocpp_cli and audiocpp_server both build. There are no warnings from YuE2 files.

Open question: would you prefer a different payload format? I picked a readable JSON array because it round-trips through the CLI, server and WebUI with no changes to any of them. It will also be accepted as-is by the follow-up input option. The reference pipeline's semantic.npy could be accepted as an additional input format later if you want it.

I could follow-up with a new PR to add an npy parser.

export_semantic=true attaches the semantic stage output as a `semantic` artifact next to `score`: a flat JSON array of codec indices, one per frame. The CLI writes semantic.json with --out-dir; the server returns it with the other artifacts. Default off; model-local; a request's audio is unchanged either way.
@0xShug0

0xShug0 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

@mirek190 Turns out you were right 😄 Semantic token import/export does have a real use case.

@mirek190

mirek190 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

@mirek190 Turns out you were right 😄 Semantic token import/export does have a real use case.

😄 yay PR 596

@0xShug0
0xShug0 merged commit f0e3a90 into 0xShug0:main Sep 21, 2026
6 checks passed
@0xShug0

0xShug0 commented Sep 21, 2026

Copy link
Copy Markdown
Owner

@engival Merged! Thanks!

@0xShug0

0xShug0 commented Sep 22, 2026

Copy link
Copy Markdown
Owner

@engival BTW let's just use json. No need to support npy.

@engival

engival commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

@engival BTW let's just use json. No need to support npy.

Yeah, I didn't include npy in any of the code. There's a trivial 1 liner in the md file showing how to convert between it in python, which enables compatibility with the reference implementation.

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.

3 participants