Skip to content

Make field-voiced work against the actual model - #64

Merged
ninjudd merged 2 commits into
mainfrom
voice/first-real-run
Aug 8, 2026
Merged

ninjudd merged 2 commits into
mainfrom
voice/first-real-run

Conversation

@ninjudd

@ninjudd ninjudd commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Make field-voiced work against the actual model

Five merged pull requests built this worker and every one of them said, accurately, that nothing had loaded Chatterbox yet. Generating creek's line is the first time anything did, and it found three things — two of them mine.

chatterbox-tts needs pkg_resources and nothing in the graph asks for it. Chatterbox watermarks every generation through perth, whose perth_net/__init__.py imports pkg_resources; Python 3.12 no longer ships it and uv does not install it unasked. perth catches that ImportError and sets PerthImplicitWatermarker = None, so the failure surfaced one layer up as 'NoneType' object is not callable from Chatterbox's constructor, naming neither perth nor setuptools. Declared as setuptools>=70,<81 — the upper bound is not decoration, since setuptools removed pkg_resources itself and 83.0.0 satisfies a bare >=70 while leaving perth exactly as broken.

The #60 leak fix never worked. Restoring the builtin voice before each unreferenced variant went through copy.deepcopy(model.conds), and torch refuses: "Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol." Some of those tensors come out of a forward pass. The fix was right about the leak and inoperative against the model, and it was verified by reading chatterbox/tts.py rather than by running it — which is precisely the distinction that review round could not make, because loading the model was the one thing the harness existed to avoid. clone_conds rebuilds the dataclass field by field with each tensor detached, which is the same shape Chatterbox's own save/load round-trip uses.

A model-side failure left no trace. The lifecycle turned every exception into a one-line protocol error and logged nothing, so the first of these presented as a single sentence with no stack anywhere, and diagnosing it meant rebuilding the whole model load by hand outside the daemon. The wire still carries one line; the daemon's log now also carries the traceback that explains it.

The regression test for that last one gets its own interpreter rather than the shared harness's. The existing one prefers python/voiced/.venv when it exists, which after a real field setup voiced contains Chatterbox — so a test wanting the backend to fail on import would instead load a 2 GB model, and would do so only on machines where setup had been run. Stating the precondition beats inheriting it; that is the same ambient-state trap the environment gate hit twice in #61 and #62.


Note

Medium Risk
Changes voice worker runtime dependencies, conditional cloning on every default-voice variant, and error logging; no auth surface, but incorrect cond cloning could still affect voice provenance.

Overview
Fixes field-voiced so the first real Chatterbox load works: setuptools>=70,<81 is declared so perth can import pkg_resources (otherwise 'NoneType' object is not callable with no useful name on the wire).

Replaces copy.deepcopy(model.conds) with clone_conds, which rebuilds conditionals field-by-field with detached tensor clones—the prior #60 leak fix failed on real tensors from the forward pass.

The shared worker daemon now logs full tracebacks to stderr (the voiced log) on request and generation failures while clients still get one-line protocol errors.

Adds a Vitest block that uses a bare Python (no Chatterbox) so a backend import failure is asserted to appear in voiced.log, avoiding the main harness’s venv that would load the model.

Reviewed by Cursor Bugbot for commit b520227. Configure here.

Five merged pull requests built this worker and every one of them said, accurately, that nothing had loaded Chatterbox yet. Generating creek's line is the first time anything did, and it found three things — two of them mine.

`chatterbox-tts` needs `pkg_resources` and nothing in the graph asks for it. Chatterbox watermarks every generation through `perth`, whose `perth_net/__init__.py` imports `pkg_resources`; Python 3.12 no longer ships it and uv does not install it unasked. perth catches that ImportError and sets `PerthImplicitWatermarker = None`, so the failure surfaced one layer up as `'NoneType' object is not callable` from Chatterbox's constructor, naming neither perth nor setuptools. Declared as `setuptools>=70,<81` — the upper bound is not decoration, since setuptools removed `pkg_resources` itself and 83.0.0 satisfies a bare `>=70` while leaving perth exactly as broken.

The #60 leak fix never worked. Restoring the builtin voice before each unreferenced variant went through `copy.deepcopy(model.conds)`, and torch refuses: "Only Tensors created explicitly by the user (graph leaves) support the deepcopy protocol." Some of those tensors come out of a forward pass. The fix was right about the leak and inoperative against the model, and it was verified by reading `chatterbox/tts.py` rather than by running it — which is precisely the distinction that review round could not make, because loading the model was the one thing the harness existed to avoid. `clone_conds` rebuilds the dataclass field by field with each tensor detached, which is the same shape Chatterbox's own `save`/`load` round-trip uses.

A model-side failure left no trace. The lifecycle turned every exception into a one-line protocol error and logged nothing, so the first of these presented as a single sentence with no stack anywhere, and diagnosing it meant rebuilding the whole model load by hand outside the daemon. The wire still carries one line; the daemon's log now also carries the traceback that explains it.

The regression test for that last one gets its own interpreter rather than the shared harness's. The existing one prefers `python/voiced/.venv` when it exists, which after a real `field setup voiced` contains Chatterbox — so a test wanting the backend to fail on import would instead load a 2 GB model, and would do so only on machines where setup had been run. Stating the precondition beats inheriting it; that is the same ambient-state trap the environment gate hit twice in #61 and #62.
@ninjudd

ninjudd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Starting review of b520227.

@ninjudd ninjudd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed b520227. One finding, P3 and documentation-only — the fix itself is correct and I verified it against the real Conditionals.

What I checked, since most of this PR is a claim about a model nothing had loaded. clone_conds reconstructs correctly: T3Cond.__dict__ keys are exactly its five dataclass fields, so type(t3)(**vars(t3)) round-trips, and Conditionals is a @dataclass whose (t3, gen) order matches the positional call — the same shape Conditionals.load uses at tts.py:103, as the docstring says. Loading the cached conds.pt and cloning it gives equal values with no shared storage in either t3 or gen, and replaying the mutation generate performs at tts.py:225-227 on the clone leaves the builtin's emotion_adv untouched, so the #60 leak is genuinely closed this time. _detached also handles gen.prompt_feat_len, which is None rather than a tensor.

The logging change works and the new test earns its keep. _log_exception is called before _send, so the client cannot observe the error before the traceback has been flushed — the test's read-after-reject is race-free rather than lucky. Generation failures cannot double-log, since _run_generation runs on its own thread and _dispatch has already returned. pnpm typecheck passes, pyright src is clean in both python/worker and python/voiced, and the file runs 8/8 locally with the new block executing rather than skipping.

The setuptools pin is corroborated from an unexpected direction: importing perth prints its own deprecation notice ending "Refrain from using this package or pin to Setuptools<81", so <81 is the bound upstream itself names.

The clone is right and the reason given for it was not. `clone_conds` is only ever handed conditionals loaded from `conds.pt`, which arrive as graph leaves — no forward pass is involved, so "some of these tensors come out of a forward pass" pointed at a mechanism that is not there.

What actually happens: `gen.embedding` is stored with `requires_grad=True`, and `from_local` finishes with `.to(device)`. A device copy of a `requires_grad` tensor carries a `grad_fn` and is no longer a leaf, which is what deepcopy refuses. Verified against the cached `conds.pt`: as loaded and after `.to('cpu')` every tensor is a leaf and deepcopy succeeds; after `.to('mps')` `gen.embedding` is not, and it raises.

That makes the failure device-dependent, and the old wording hid it. `device_preference()` defaults to `"mps"`, so the default path is the broken one — but `.to('cpu')` is a no-op, so the original code passes on CPU and on any runner without MPS. Someone reverting to deepcopy and checking with `FIELD_VOICE_DEVICE=cpu` would watch it pass and conclude the clone was unnecessary. No test can catch that on the runners we have, which is precisely why the comment has to point at the device.
ninjudd added a commit that referenced this pull request Aug 8, 2026
Stacked on #64.

creek's take reads its line at one fixed pace and there was no way to change it: the voice job was text, seed, variants and `voice_ref`, so the only lever was the words. Chatterbox has six sampling parameters; two are exposed here and four are not, because a field added to the recipe is a permanent part of the committed format.

Measured before naming anything, same seed and text as the committed take. Lowering `cfg_weight` from 0.5 to 0.3 changed the delivery and not the pacing at all — different audio, identical 72 tokens. Only at 0.2 did the model start taking longer to say the same sentence (2.90 s of speech against 2.58 s), and `exaggeration` at 0.3 was stronger still at 3.10 s. The extra length is speech rather than silence: leading and trailing silence stay within 0.12–0.20 s throughout. So pacing moves by up to about a fifth, and `exaggeration` is the better lever, which makes sense — it is a conditioning input the model receives, where `cfg_weight` only reweights sampling.

`cfg_weight` is called `conviction` here. The name is the whole of the classifier-free guidance step: each token, the model predicts once knowing the text and voice and once deliberately ignorant of them, and the weight says how far past the informed prediction to push — `logits = cond + w * (cond - uncond)`. Higher commits harder to the on-text reading and hurries; lower lingers. `speed` would promise what the measurement shows it does not deliver, and `looseness` would invert the scale so a value copied from Chatterbox's docs meant its opposite. The direction is kept identical to Chatterbox's, and `adapter.py` does the translation, which is what a quarantined boundary module is for.

Absent means the model's default rather than a default we chose: neither field is written unless it was asked for, and the adapter passes only what it was given. Recording 0.5 explicitly would look identical today and silently pin it if Chatterbox ever moved. The bounds are narrower than the model's and enforced three times — CLI parser, worker job spec, schema — because widening a range later leaves every committed recipe valid and narrowing one does not.

One thing worth recording that fell out of the measurement: the default run reproduced the committed take byte for byte, matching the sha256 the recipe already pins. §1.1 commits outputs because inference does not reproduce across GPU and framework versions, and that stands — but within one fixed environment the seed does exactly what the recipe implies.
@ninjudd

ninjudd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Starting review of acd80e9.

@ninjudd

ninjudd commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed acd80e9 — no findings. The docstring finding from b520227 is addressed, and I checked the fix rather than assuming it.

It is genuinely comment-only. Parsing adapter.py at both SHAs and comparing the ASTs with docstrings stripped gives an exact match, so nothing executable moved and the clean pyright src from b520227 carries over unchanged.

Every claim in the new paragraph holds against the installed 0.1.7. Conditionals.to is self.gen[k] = v.to(device=device) at tts.py:87-88, from_local ends with Conditionals.load(builtin_voice, …).to(device) at tts.py:163, and device_preference() returns "mps" absent an override — so the chain from stored requires_grad=True through a device copy to a non-leaf is stated correctly, and the table matches what I measured against the cached conds.pt line for line.

One imprecision, not worth changing on its own: "a regression test would pass on the runners we have" is right in conclusion and slightly off in mechanism. Such a test could not run at all in CI rather than passing there — pnpm test reaches this code on a bare interpreter with no torch, which the module docstring already says at lines 9-11, and ci.yml installs only the dev group precisely to keep torch out. Either way nothing on a runner would fail, which is the point the paragraph is making.

Reviewing the finding a second time, the wording you landed on is stronger than what I asked for: telling the next reader to leave the cause pointing at the device, and naming FIELD_VOICE_DEVICE=cpu as the trap, guards the revert I was worried about better than a corrected mechanism alone would have.

I have not resolved the thread — that stays yours.

@ninjudd
ninjudd merged commit 18c4279 into main Aug 8, 2026
3 checks passed
ninjudd added a commit that referenced this pull request Aug 8, 2026
Stacked on #64.

creek's take reads its line at one fixed pace and there was no way to change it: the voice job was text, seed, variants and `voice_ref`, so the only lever was the words. Chatterbox has six sampling parameters; two are exposed here and four are not, because a field added to the recipe is a permanent part of the committed format.

Measured before naming anything, same seed and text as the committed take. Lowering `cfg_weight` from 0.5 to 0.3 changed the delivery and not the pacing at all — different audio, identical 72 tokens. Only at 0.2 did the model start taking longer to say the same sentence (2.90 s of speech against 2.58 s), and `exaggeration` at 0.3 was stronger still at 3.10 s. The extra length is speech rather than silence: leading and trailing silence stay within 0.12–0.20 s throughout. So pacing moves by up to about a fifth, and `exaggeration` is the better lever, which makes sense — it is a conditioning input the model receives, where `cfg_weight` only reweights sampling.

`cfg_weight` is called `conviction` here. The name is the whole of the classifier-free guidance step: each token, the model predicts once knowing the text and voice and once deliberately ignorant of them, and the weight says how far past the informed prediction to push — `logits = cond + w * (cond - uncond)`. Higher commits harder to the on-text reading and hurries; lower lingers. `speed` would promise what the measurement shows it does not deliver, and `looseness` would invert the scale so a value copied from Chatterbox's docs meant its opposite. The direction is kept identical to Chatterbox's, and `adapter.py` does the translation, which is what a quarantined boundary module is for.

Absent means the model's default rather than a default we chose: neither field is written unless it was asked for, and the adapter passes only what it was given. Recording 0.5 explicitly would look identical today and silently pin it if Chatterbox ever moved. The bounds are narrower than the model's and enforced three times — CLI parser, worker job spec, schema — because widening a range later leaves every committed recipe valid and narrowing one does not.

One thing worth recording that fell out of the measurement: the default run reproduced the committed take byte for byte, matching the sha256 the recipe already pins. §1.1 commits outputs because inference does not reproduce across GPU and framework versions, and that stands — but within one fixed environment the seed does exactly what the recipe implies.
ninjudd added a commit that referenced this pull request Aug 8, 2026
Give a voice recipe two knobs for how the line is delivered

Stacked on #64.

creek's take reads its line at one fixed pace and there was no way to
change it: the voice job was text, seed, variants and `voice_ref`, so
the only lever was the words. Chatterbox has six sampling parameters;
two are exposed here and four are not, because a field added to the
recipe is a permanent part of the committed format.

Measured before naming anything, same seed and text as the committed
take. Lowering `cfg_weight` from 0.5 to 0.3 changed the delivery and not
the pacing at all — different audio, identical 72 tokens. Only at 0.2
did the model start taking longer to say the same sentence (2.90 s of
speech against 2.58 s), and `exaggeration` at 0.3 was stronger still at
3.10 s. The extra length is speech rather than silence: leading and
trailing silence stay within 0.12–0.20 s throughout. So pacing moves by
up to about a fifth, and `exaggeration` is the better lever, which makes
sense — it is a conditioning input the model receives, where
`cfg_weight` only reweights sampling.

`cfg_weight` is called `conviction` here. The name is the whole of the
classifier-free guidance step: each token, the model predicts once
knowing the text and voice and once deliberately ignorant of them, and
the weight says how far past the informed prediction to push — `logits =
cond + w * (cond - uncond)`. Higher commits harder to the on-text
reading and hurries; lower lingers. `speed` would promise what the
measurement shows it does not deliver, and `looseness` would invert the
scale so a value copied from Chatterbox's docs meant its opposite. The
direction is kept identical to Chatterbox's, and `adapter.py` does the
translation, which is what a quarantined boundary module is for.

Absent means the model's default rather than a default we chose: neither
field is written unless it was asked for, and the adapter passes only
what it was given. Recording 0.5 explicitly would look identical today
and silently pin it if Chatterbox ever moved. The bounds are narrower
than the model's and enforced three times — CLI parser, worker job spec,
schema — because widening a range later leaves every committed recipe
valid and narrowing one does not.

One thing worth recording that fell out of the measurement: the default
run reproduced the committed take byte for byte, matching the sha256 the
recipe already pins. §1.1 commits outputs because inference does not
reproduce across GPU and framework versions, and that stands — but
within one fixed environment the seed does exactly what the recipe
implies.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes the permanent generative recipe format and the voice
generation path, but validation is layered and absent knobs preserve
backward compatibility for existing recipes.
> 
> **Overview**
> Voice generation can now tune **how a line is delivered**, not just
the text and reference. **`field generate`** accepts
**`--exaggeration`** (0.25–2) and **`--conviction`** (0.1–1); both are
**voice-only** and rejected on music prompts like **`--voice-ref`**.
> 
> **`conviction`** is the recipe and wire name for Chatterbox’s
**`cfg_weight`**; **`adapter.py`** maps it at the model boundary so
committed YAML and the protocol stay musician-facing. Unset knobs are
**omitted** from the job, recipe, and **`model.generate`** call so
defaults are not silently pinned if the library changes.
> 
> Bounds are enforced in the CLI parsers, worker **`optional_number`**,
and **`generativeSoundSchema`** (narrower than the model’s range). Tests
cover end-to-end stub wiring, schema kind-split, and live daemon
rejection of out-of-range values.
> 
> **`docs/projects/all/voice-generation.md`** §8 records the measurement
rationale and naming decision.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
f92ee53. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
ninjudd added a commit that referenced this pull request Aug 10, 2026
nested-tracks is Active — chunk 4 is revived by #123 and the soak
holds either way; Shipped was the one indefensible value. The three
stale prose lines are updated to what actually happened (voice
generation through #64/#65 and the #113 fold, effects through #14/#15
with the §6 executor move, musical time through #24), so the keyword
and the prose agree on day one. The README claims adoption, not
sharing, while agent-config#15 is still open.
@ninjudd
ninjudd deleted the voice/first-real-run branch September 28, 2026 04:11
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.

1 participant