Customise a model from the portal: a file, a model, a button

A page for anyone in a project, built for the one who knows least: an
Excel, CSV or JSONL file of questions and answers, previewed; a model; a
name; who may use it; and a button. The weights to train on are found
from where the model's came (a GGUF repository's base model), the card's
memory from their size, the node as the one with the most free. When it
is done the adapter is published by itself (a llama.cpp model's replicas
replaced to load it) and is a model of its own in the chat and the API.

The project's by default; its members share it wider (confirmed, and
never wider than the knowledge bases its pairs came from) or delete it.
One trains at a time per project. ctl train start needs only --model and
--data now, and --publish publishes when done.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-11-19 11:31:12 +01:00
1 parent fcda4d3f85
commit a53b2f4be9
33 files changed
+2199 -134

No files matched your search

+35 -1
View File
@@ -35,11 +35,26 @@ type Service struct {
agents Agents
log *slog.Logger
// pick chooses the node for a job that names none, among those not
// busy; "" is none can take it now. Nil leaves such jobs queued.
pick func(needMiB int, busy map[string]bool) string
// done is told of a job that finished, after what it made is kept.
done func(j store.TrainJob)
mu sync.Mutex
// pieces are artifacts arriving, by job and kind.
pieces map[[2]string][]byte
}
// SetPicker has jobs that name no node sent where pick says.
func (s *Service) SetPicker(pick func(needMiB int, busy map[string]bool) string) { s.pick = pick }
// SetOnDone has done told of each job that finishes.
func (s *Service) SetOnDone(done func(j store.TrainJob)) { s.done = done }
// Waiting is what a job that names no node says while no node can take it.
const Waiting = "waiting for a card with enough memory free"
// New is a service.
func New(s Store, a Agents, log *slog.Logger) *Service {
if log == nil {
@@ -81,13 +96,27 @@ func (s *Service) Dispatch(ctx context.Context) {
busy[j.Node] = true
}
for _, q := range queued {
if busy[q.Node] || !s.agents.Connected(q.Node) {
node := q.Node
if node == "" {
if s.pick != nil {
node = s.pick(q.GPUMemoryMiB, busy)
}
if node == "" {
if q.Message != Waiting {
q.Message = Waiting
_ = s.store.UpdateTrainJob(ctx, q)
}
continue
}
}
if busy[node] || !s.agents.Connected(node) {
continue
}
j, err := s.store.TrainJob(ctx, q.ID)
if err != nil {
continue
}
j.Node = node
err = s.agents.Send(j.Node, &llmgwv1.ControlMessage{Msg: &llmgwv1.ControlMessage_TrainStart{TrainStart: &llmgwv1.TrainStart{
JobId: j.ID, BaseRepo: j.BaseRepo, BaseRevision: j.BaseRevision, Data: j.Data, Params: j.Params,
GpuMemoryMib: int32(j.GPUMemoryMiB), Gguf: j.GGUF}}}) //nolint:gosec // MiB
@@ -135,6 +164,11 @@ func (s *Service) OnTrainStatus(node string, st *llmgwv1.TrainStatus) {
}
if err := s.store.UpdateTrainJob(ctx, j); err != nil {
s.log.Warn("could not record a training job's progress", "job", j.ID, "err", err)
return
}
// What it made came before it said it was done, on the same stream.
if j.State == store.TrainDone && s.done != nil {
go s.done(j)
}
}