Add a text generation IPC protocol over HWInference
Categories
(Core :: Machine Learning: On Device, task, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox159 | --- | fixed |
People
(Reporter: gregtatum, Assigned: vpollet)
References
(Blocks 1 open bug)
Details
(Whiteboard: [aiplatform])
Attachments
(1 external file)
In order to check this work in incrementally, we can design the input/output API layer for the process, without actually checking in the llama.cpp dependency and wiring it in. Here the work would be to create an initial API for how we would want to talk to the llama.cpp implementation. It wouldn't need to be 100% correct for the final implementation, but just good enough to be plausible. The benefit is that we can get all of the file structures in place and get the general outline in a good place. That way when we actually put llama.cpp into place here we're less worried about the Gecko-specific structure and can focus on the llama.cpp integration.
What's out of scope here is designing and implementing the JS binding layer that consumes this in any real way via the createEngine and MLEngineParent APIs. This is just about getting the native-code focused IPC layer in place from a structural perspective.
AI Suggestion:
Design and implement the PTextGeneration IPDL protocol. This is the llama.cpp equivalent of PSpeechRecognition — a new protocol that lives under PHWInferenceManager and handles a single text generation session. The key design differences from whisper are that output is a stream of tokens rather than a single result, and the session holds stateful KV cache context that must be managed across calls. The protocol needs messages for: starting a generation with a prompt, streaming tokens back incrementally (e.g. OnToken(nsCString token, bool isFinal)), cancellation, and session teardown. Create dummy implementations end-to-end so the IPC plumbing is reviewable and testable independently of the llama.cpp wiring.
AI Suggestion:
Implement TextGenerationParent in the HWInference process. This actor runs the llama.cpp inference loop on a dedicated background thread (following the SpeechRecognitionParent threading model), holds llama.cpp context state including the KV cache, and pushes token results back over IPC. Unlike whisper, llama.cpp context is long-lived and must be explicitly reset between sessions. Concurrency — what happens when a second generation request arrives while one is in flight — must be defined here, since the current JS Inference implementation fails ungracefully in this case.
Updated•5 months ago
|
| Assignee | ||
Updated•4 months ago
|
| Assignee | ||
Comment 1•3 months ago
|
||
PTextGeneration is a HWInferenceBrowserManager managed protocol to generate text with llama.cpp.
This commit introduces the protocol itself with a stubbed implementation.
Updated•3 months ago
|
| Assignee | ||
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Comment 3•2 months ago
|
||
| bugherder | ||
Updated•1 month ago
|
Description
•