Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/inference/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func (m BackendMode) String() string {
}

type BackendConfiguration struct {
ContextSize int64 `json:"context_size,omitempty"`
RawFlags []string `json:"flags,omitempty"`
ContextSize int64 `json:"context-size,omitempty"`
RuntimeFlags []string `json:"runtime-flags,omitempty"`
Comment on lines +33 to +34
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know if this JSON nomenclature is used anywhere (I couldn't find it), but I've tried to make it consistent before it becomes used anywhere.

}

// Backend is the interface implemented by inference engine backends. Backend
Expand Down
2 changes: 1 addition & 1 deletion pkg/inference/backends/llamacpp/llamacpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (l *llamaCpp) Run(ctx context.Context, socket, model string, mode inference
if config.ContextSize >= 0 {
args = append(args, "--ctx-size", strconv.Itoa(int(config.ContextSize)))
}
args = append(args, config.RawFlags...)
args = append(args, config.RuntimeFlags...)
}

l.log.Infof("llamaCppArgs: %v", args)
Expand Down
7 changes: 4 additions & 3 deletions pkg/inference/scheduling/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ type UnloadResponse struct {

// ConfigureRequest specifies per-model runtime configuration options.
type ConfigureRequest struct {
Model string `json:"model"`
ContextSize int64 `json:"context-size,omitempty"`
RawRuntimeFlags string `json:"raw-runtime-flags,omitempty"`
Model string `json:"model"`
ContextSize int64 `json:"context-size,omitempty"`
RuntimeFlags []string `json:"runtime-flags,omitempty"`
RawRuntimeFlags string `json:"raw-runtime-flags,omitempty"`
}
20 changes: 12 additions & 8 deletions pkg/inference/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,23 +388,27 @@ func (s *Scheduler) Configure(w http.ResponseWriter, r *http.Request) {
}

configureRequest := ConfigureRequest{
Model: "",
ContextSize: -1,
RawRuntimeFlags: "",
ContextSize: -1,
}
if err := json.Unmarshal(body, &configureRequest); err != nil {
http.Error(w, "invalid request", http.StatusBadRequest)
return
}
rawFlags, err := shellwords.Parse(configureRequest.RawRuntimeFlags)
if err != nil {
http.Error(w, "invalid request", http.StatusBadRequest)
return
var runtimeFlags []string
if len(configureRequest.RuntimeFlags) > 0 {
runtimeFlags = configureRequest.RuntimeFlags
} else {
rawFlags, err := shellwords.Parse(configureRequest.RawRuntimeFlags)
if err != nil {
http.Error(w, "invalid request", http.StatusBadRequest)
return
}
runtimeFlags = rawFlags
}

var runnerConfig inference.BackendConfiguration
runnerConfig.ContextSize = configureRequest.ContextSize
runnerConfig.RawFlags = rawFlags
runnerConfig.RuntimeFlags = runtimeFlags

if err := s.loader.setRunnerConfig(r.Context(), backend.Name(), configureRequest.Model, inference.BackendModeCompletion, runnerConfig); err != nil {
s.log.Warnf("Failed to configure %s runner for %s: %s", backend.Name(), configureRequest.Model, err)
Expand Down