Skip to content

feat: --serve answers vocabulary replays from one warm process - #380

Merged
znat merged 2 commits into
feat/syrinx-disfluencyfrom
feat/vocab-serve
Nov 2, 2026
Merged

znat merged 2 commits into
feat/syrinx-disfluencyfrom
feat/vocab-serve

Conversation

@znat

@znat znat commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

ParrotFlow --serve keeps one process alive with its models loaded. It reads one JSON request per line on stdin (dictate, picked, correction, learn, reset) and answers one JSON line on stdout. Each request runs the same function as its separate flag, writes to the config dir included. Vocabulary replays used to launch the binary once per dictation and once per answer. One pass over the 165 bench decisions, both flags and both floors, now takes 2 minutes instead of 29, with every decision and every output identical. No setting changes and no existing command changes. Start with ServeCommand.swift and the extraction in PipelineCommand.swift.

The protocol: five commands, places come back as the stage's own log lines
{"id": 1, "cmd": "dictate", "fixture": "/abs/fixture.yaml", "text": "<heard>", "warm": true}
{"id": 2, "cmd": "picked", "word": "<w>", "term": "<t>", "in": "<sentence>"}
{"id": 3, "cmd": "correction", "wrote": "<w>", "put": "<p>", "in": "<sentence>"}
{"id": 4, "cmd": "learn", "heard": "<h>", "corrected": "<c>", "kind": "person", "in": "<sentence>"}
{"id": 5, "cmd": "reset"}

Each answer has id (echoed), cmd, code (the separate flag's exit code), said (the lines it prints) and log (the lines this request wrote to the log, without the timestamp). dictate adds out and vars, the values --vars prints. A bad line answers {"id", "error"} and the loop goes on. End of input exits 0.

  • dictate runs PipelineCommand.dictate: the fixture is decoded again on every call, then the --quiet path, which is the one the app uses.
  • picked, correction and learn call SoundGroupCommand.picked, SoundGroupCommand.correction and LearnCommand.run. Those three now take a say parameter that defaults to print, so the CLI output is unchanged.
  • Places and their decisions are not modelled a second time. A Log sink returns what the vocabulary stage wrote, and a harness parses those lines as it parsed the log file.
  • reset writes terms: {} to both files. It refuses without PARROTFLOW_CONFIG_DIR, so it never empties the vocabulary someone dictates with.
  • The protocol channel is a private dup of stdout. fd 1 then points at stderr, so a stray print cannot corrupt an answer.
  • One process serves one config dir, so one setting of clause_decider.
Equivalence: per launch against warm, every decision and output identical

The three replay harnesses were ported to a backend switch: one launch per call, or one --serve process per run directory. They are local, in the scratchpad and training/, and not in this PR.

Set Flag Floor Items Differ
Live trial on 0.60 41 0
Live trial off 0.60 41 0
Scripted on 0.60 44 0
Scripted off 0.60 44 0
165 bench, chrono on 0.60 165 0
165 bench, chrono on 0.85 165 0
165 bench, chrono off 0.60 165 0
165 bench, chrono off 0.85 165 0

Compared per item: output text, places with decisions and terms, simulated answers and what they printed, the vocabulary log lines (timings masked), and the final vocabulary.yaml and vocabulary-uses.yaml. The serve runs also match the #379 per-launch runs on disk, decision for decision.

One difference showed up first and was not this mode. espeak-ng exits 1 when HOME is 158 bytes or longer (157 works, measured on real directories), and the sound pass then loses its first ear. The two arms' run directories differed in length, so one arm had a 159-byte HOME. With short run directories, both arms are identical. The harnesses now assert a short HOME.

Speed: 11 to 17 times faster per pass

Wall time per pass, model load included (one --serve process per run).

Set Flag Floor Per launch Warm
Live trial, 41 on 0.60 108 s 8.7 s
Live trial, 41 off 0.60 155 s 11.7 s
Scripted, 44 on 0.60 128 s 11.1 s
Scripted, 44 off 0.60 176 s 14.7 s
165 bench on 0.60 384 s 28.5 s
165 bench on 0.85 373 s 26.4 s
165 bench off 0.60 529 s 36.6 s
165 bench off 0.85 475 s 28.5 s
First use: the 165 bench over 20 random orders, both flags, in 43 minutes

The same seeds as the Python replay (orders from default_rng(12345), fixes from seed k+1). Mean over the 20 orders, chrono in brackets. 84 runs, 2,590 s of wall time in all; per launch this would take about 5 hours.

Flag Floor rw ww rl wl of
on 0.60 43.35 (47) 8.0 (8) 82.95 (81) 7.9 (6) 22.8 (23)
off 0.60 43.05 (46) 7.15 (6) 78.8 (79) 9.7 (7) 26.3 (27)
on 0.85 38.4 (41) 4.25 (4) 90.55 (91) 21.3 (18) 10.5 (11)
off 0.85 38.55 (42) 4.8 (4) 89.85 (91) 22.0 (18) 9.8 (10)
How it was checked
  • scripts/check-serve.sh (new, in make test and CI): 32/32. One server driven request by request through fifos. Each said equals what the separate flag prints, and vocabulary.yaml and vocabulary-uses.yaml match the separate commands byte for byte. No model needed.
  • Existing commands unchanged: --pipeline ... --vars --warm on 32 sentences per flag (sound fixtures at 0.85 and 0.60, rule fixture), plus 8 --learn/--correction/--picked calls per flag. Base 1ede563 against this branch: byte-identical stdout and files.
  • scripts/check-pipeline.sh 134/134, check-sound-group.sh 93/93, check-learn.sh 45/45, check-clause-places.sh 9/9, all under a scratch config and home.
  • CodeRabbit local review: 2 findings. Fixed: reset without a scratch config dir. Declined: "install PyYAML for check-serve"; the workflow already installs it in the same job, and check-join.sh relies on it too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2

znat and others added 2 commits October 29, 2026 13:54
Replays launched the binary once per dictation and once per answer, and
each launch reloaded the models. --serve reads one JSON request per line
(dictate, picked, correction, learn, reset) and runs the same functions
the separate flags run. Places come back as the stage's own log lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
Signed-off-by: Nathan Zylbersztejn <[email protected]>
reset empties vocabulary.yaml and vocabulary-uses.yaml. Run against the
default config, it would erase the vocabulary someone dictates with.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01WfxPEjc1EEGqG2rHoJcLJ2
Signed-off-by: Nathan Zylbersztejn <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 29, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 36740571-eb8c-4a9b-8696-bd968ad9e00d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@znat

znat commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Base automatically changed from feat/vocab-syrinx-slots to feat/syrinx-disfluency November 2, 2026 07:57
@znat

znat commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit review (local CLI 0.8.0). The GitHub app is rate limited on this repository, so this review ran with coderabbit review --agent --base-commit 1ede5634 (the diff against #379). 0 findings.

@znat
znat merged commit 595573b into feat/syrinx-disfluency Nov 2, 2026
10 checks passed
@znat
znat deleted the feat/vocab-serve branch November 2, 2026 08:00
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