Skip to content
Open
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
1 change: 1 addition & 0 deletions contracts/api/v2/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -252365,6 +252365,7 @@
"qsv",
"vaapi",
"nvenc",
"videotoolbox",
"none"
],
"type": "string"
Expand Down
18 changes: 9 additions & 9 deletions docs/admin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ configuration, last health result, and last stored hardware inventory. See
`hw_accel_override` and `hw_device_override` override the cluster-wide
`playback.hw_accel` and `playback.hw_device` settings for one node.
`hw_accel_override` takes the same values as the cluster setting — `auto`,
`qsv`, `vaapi`, `nvenc`, `none`. Absent means inherit; there is no separate
"inherit" value to set.
`qsv`, `vaapi`, `nvenc`, `videotoolbox`, `none`. Absent means inherit; there
is no separate "inherit" value to set.

They exist for a heterogeneous deployment: one CPU-only node in a QSV cluster
sets `none` for itself instead of forcing every node onto the lowest common
Expand Down Expand Up @@ -839,11 +839,11 @@ indistinguishable from omission.

`200 OK` with the updated node, `404 Not Found` for an unknown id,
`422 validation_failed` when `hw_accel_override` is not one of `auto`, `qsv`,
`vaapi`, `nvenc`, `none` (matched case-insensitively and stored lowercase, as
`playback.hw_accel` is). The node pools are reloaded afterwards, so remote
dispatch honors a new override immediately; the target node itself picks it up
on its next config reload — see "Acceleration overrides" above for what waits
for a restart.
`vaapi`, `nvenc`, `videotoolbox`, `none` (matched case-insensitively and
stored lowercase, as `playback.hw_accel` is). The node pools are reloaded
afterwards, so remote dispatch honors a new override immediately; the target
node itself picks it up on its next config reload — see "Acceleration
overrides" above for what waits for a restart.

`download_artifact_dir_override` (an absolute path; `null` or empty restores the
inherited directory) and `download_artifact_max_bytes_override` (bytes, `0` for no
Expand Down Expand Up @@ -1000,7 +1000,7 @@ Top-level (and each node's own report):

| Field | Type | Meaning |
|---|---|---|
| `resolved` | string | The backend that would actually be used: `nvenc`, `qsv`, `vaapi`, or `none`. An explicitly configured backend wins even when its probe failed — read `detected_backends` for why. |
| `resolved` | string | The backend that would actually be used: `nvenc`, `qsv`, `vaapi`, `videotoolbox`, or `none`. An explicitly configured backend wins even when its probe failed — read `detected_backends` for why. |
| `render_devices` | string[] | Every accessible `/dev/dri/renderD*` path. |
| `render_device_details` | object[] | One entry per device (see below). |
| `intel_detected` | bool | An Intel GPU is present in the inventory. |
Expand All @@ -1025,7 +1025,7 @@ Top-level (and each node's own report):

| Field | Type | Meaning |
|---|---|---|
| `backend` | string | `nvenc`, `qsv`, or `vaapi`. |
| `backend` | string | `nvenc`, `qsv`, `vaapi`, or `videotoolbox`. |
| `verified` | bool | At least one candidate device passed a real single-frame encode, not just an FFmpeg build-flag listing. |
| `devices` | string[] | Every candidate considered for this backend. |
| `device` | string | The candidate whose probe passed. Empty for NVENC, which addresses its GPU through CUDA rather than a render node. |
Expand Down
2 changes: 1 addition & 1 deletion internal/nodecontrol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ type Registration struct {
Group *string `json:"group,omitempty"`
MaxJobs *int `json:"max_jobs,omitempty"`
SourceAccess *string `json:"source_access,omitempty" enum:"local,core"`
HWAccelOverride *string `json:"hw_accel_override,omitempty" enum:"auto,qsv,vaapi,nvenc,none"`
HWAccelOverride *string `json:"hw_accel_override,omitempty" enum:"auto,qsv,vaapi,nvenc,videotoolbox,none"`
HWDeviceOverride *string `json:"hw_device_override,omitempty"`
DownloadArtifactDirOverride *string `json:"download_artifact_dir_override,omitempty"`
DownloadArtifactMaxBytesOverride *int64 `json:"download_artifact_max_bytes_override,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions internal/nodedeclare/nodedeclare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestFromEnv(t *testing.T) {
})
t.Run("values follow the update body", func(t *testing.T) {
in, err := FromEnv(nodepool.NodeTypeTranscode, env(map[string]string{
"SILO_NODE_MAX_TRANSCODES": "0", "SILO_NODE_HW_ACCEL": "QSV", "SILO_NODE_SOURCE_ACCESS": "core",
"SILO_NODE_MAX_TRANSCODES": "0", "SILO_NODE_HW_ACCEL": "VideoToolbox", "SILO_NODE_SOURCE_ACCESS": "core",
"SILO_NODE_URL": "http://gpu1:8082", "SILO_NODE_DOWNLOAD_ARTIFACT_MAX_BYTES": "0",
// A proxy variable means nothing to a transcode node.
"SILO_NODE_MAX_STREAMS": "5",
Expand All @@ -32,7 +32,7 @@ func TestFromEnv(t *testing.T) {
if got := in.SetFields(); !slices.Equal(got, want) {
t.Fatalf("declared %v, want %v", got, want)
}
if *in.MaxJobs != 0 || *in.HWAccelOverride != "qsv" || *in.DownloadArtifactMaxBytesOverride != 0 {
if *in.MaxJobs != 0 || *in.HWAccelOverride != "videotoolbox" || *in.DownloadArtifactMaxBytesOverride != 0 {
t.Fatalf("max_jobs %d, hw_accel %q, max_bytes %d", *in.MaxJobs, *in.HWAccelOverride, *in.DownloadArtifactMaxBytesOverride)
}
})
Expand Down
4 changes: 2 additions & 2 deletions internal/nodepool/declaration_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestNodeDeclarationsLockFieldsDB(t *testing.T) {
return revision, generation
}

group, jobs, accel := "rack-a", 0, "vaapi"
group, jobs, accel := "rack-a", 0, "videotoolbox"
declared, _, err := store.Declare(ctx, node.ID, UpdateNodeInput{Group: &group, MaxJobs: &jobs, HWAccelOverride: &accel})
if err != nil {
t.Fatal(err)
Expand All @@ -38,7 +38,7 @@ func TestNodeDeclarationsLockFieldsDB(t *testing.T) {
// Restating a declared value, in the spelling a full-form save sends,
// goes through; changing one is refused and changes nothing.
restated, zero := "rack-a", 0
if _, _, err := store.Update(ctx, node.ID, UpdateNodeInput{Group: &restated, MaxJobs: &zero}, accept); err != nil {
if _, _, err := store.Update(ctx, node.ID, UpdateNodeInput{Group: &restated, MaxJobs: &zero, HWAccelOverride: &accel}, accept); err != nil {
t.Fatalf("restating declared values: %v", err)
}
other, name := "rack-b", "renamed"
Expand Down
13 changes: 7 additions & 6 deletions internal/nodepool/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,17 +448,18 @@ func (i UpdateNodeInput) ValidateFor(node *Node) error {
// internal/config/admin_settings.go and the CHECK constraint on
// stream_nodes.hw_accel_override: a per-node override may only name a backend
// the cluster-wide setting could also name.
var hwAccelOverrideValues = []string{hwAccelAuto, hwAccelQSV, hwAccelVAAPI, hwAccelNVENC, hwAccelNone}
var hwAccelOverrideValues = []string{hwAccelAuto, hwAccelQSV, hwAccelVAAPI, hwAccelNVENC, hwAccelVideoToolbox, hwAccelNone}

const (
// hwAccelAuto asks the node to resolve its own backend against live
// hardware at session start; dispatch passes it through untouched for
// exactly that reason.
hwAccelAuto = "auto"
hwAccelQSV = "qsv"
hwAccelVAAPI = "vaapi"
hwAccelNVENC = "nvenc"
hwAccelNone = "none"
hwAccelAuto = "auto"
hwAccelQSV = "qsv"
hwAccelVAAPI = "vaapi"
hwAccelNVENC = "nvenc"
hwAccelVideoToolbox = "videotoolbox"
hwAccelNone = "none"
)

// sameURL is true when an update leaves the row addressing the same worker.
Expand Down
22 changes: 22 additions & 0 deletions migrations/sql/20261121042328_allow_videotoolbox_node_override.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- +goose Up
-- A node can be pinned to VideoToolbox, as the cluster-wide playback.hw_accel
-- already can: hw_accel_override takes the same values as that setting.
ALTER TABLE public.stream_nodes DROP CONSTRAINT stream_nodes_hw_accel_override_check;
ALTER TABLE public.stream_nodes
ADD CONSTRAINT stream_nodes_hw_accel_override_check
CHECK (hw_accel_override IN ('auto', 'qsv', 'vaapi', 'nvenc', 'videotoolbox', 'none'));

-- +goose Down
-- A node pinned to VideoToolbox goes back to inheriting the cluster setting,
-- and a field its environment declared is no longer locked to that value.
-- The table lock the ALTERs need comes first: taken after the UPDATE, it could
-- deadlock with a node's health write waiting on a row the UPDATE changed.
LOCK TABLE public.stream_nodes IN ACCESS EXCLUSIVE MODE;
UPDATE public.stream_nodes
SET hw_accel_override = NULL,
env_managed = array_remove(env_managed, 'hw_accel_override')
WHERE hw_accel_override = 'videotoolbox';
ALTER TABLE public.stream_nodes DROP CONSTRAINT stream_nodes_hw_accel_override_check;
ALTER TABLE public.stream_nodes
ADD CONSTRAINT stream_nodes_hw_accel_override_check
CHECK (hw_accel_override IN ('auto', 'qsv', 'vaapi', 'nvenc', 'none'));
112 changes: 59 additions & 53 deletions web/src/pages/AdminNodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ import {
nodeUsesCUDADevices,
parseHWDeviceOverride,
restoreEnvManagedFields,
nodeUsesVideoToolbox,
} from "./adminNodesPresentation";
import { NodeRoutingSettings } from "@/pages/admin-settings/NodeRoutingSettings";

Expand Down Expand Up @@ -1055,6 +1056,9 @@ function NodeForm({
const { data: serverSettings } = useAdminServerSettings();
const clusterHWAccel = serverSettings?.["playback.hw_accel"];
const usesCUDADevices = nodeUsesCUDADevices(node, hwAccelOverride, clusterHWAccel);
// VideoToolbox takes no device, so its control is hidden. The value stays in
// state and is saved as it was: hiding it clears nothing.
const showDeviceOverride = !nodeUsesVideoToolbox(node, hwAccelOverride, clusterHWAccel);
Comment on lines +1059 to +1061

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

kody code-review Bug medium

Selecting VideoToolbox silently clears an NVENC device override

Saving after switching from NVENC to VideoToolbox silently loses the hidden CUDA device override. Update selectHWAccelOverride to preserve the device when transitioning to or from VideoToolbox.

Prompt for LLM
File web/src/pages/AdminNodes.tsx, lines 1059-1061:

Selecting VideoToolbox silently clears an NVENC device override

Switching a node from NVENC to VideoToolbox clears its existing CUDA device override through `selectHWAccelOverride`, so saving the form silently loses the setting even though the hidden field is supposed to be preserved. Exclude transitions to and from VideoToolbox from device-syntax clearing so that the saved device remains available when switching back.

Talk to Kody by mentioning @kody

Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.

​

​

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.

Leaving this as it is. Moving from NVENC to VideoToolbox changes the device syntax, the same as moving from NVENC to QSV, which already clears the CUDA device. A VideoToolbox node takes no device, so saving null is right for that node. If the CUDA index were kept, it would carry into the next backend picked after VideoToolbox, such as VAAPI, where it means nothing. The comment on showDeviceOverride covers hiding the field without changing the selection, as for a Mac on Auto, and that clears nothing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Agreed. Clearing the CUDA device override when switching from NVENC to VideoToolbox is consistent with the existing behavior for backend changes and avoids carrying an incompatible value into a later selection.

The showDeviceOverride comment describes a separate case: hiding the field without changing the selection preserves its value. I withdraw the suggestion; no change is needed.

// A device override written for one syntax means nothing in the other: a
// render path is not a CUDA identity and neither is settable as the other, so
// moving the selection between them drops the stored value rather than
Expand Down Expand Up @@ -1319,61 +1323,63 @@ function NodeForm({
{lockedNote("hw_accel_override")}
</div>

<div className="space-y-2">
<Label htmlFor={hasDeviceInventory ? undefined : "node-hw-device-override"}>
{t("web.admin.nodes.form.gpuDevices")}
</Label>
{hasDeviceInventory ? (
<NodeDevicePicker
rows={deviceRows}
onToggle={(path) =>
setHwDeviceOverride(toggleHWDevice(hwDeviceOverride, path, devicePaths))
}
onInherit={() => setHwDeviceOverride("")}
disabled={isLocked("hw_device_override")}
/>
) : (
<>
<Input
id="node-hw-device-override"
// Device paths read left to right; the translated placeholder keeps the page's direction.
dir={hwDeviceOverride ? "ltr" : undefined}
value={hwDeviceOverride}
{showDeviceOverride && (
<div className="space-y-2">
<Label htmlFor={hasDeviceInventory ? undefined : "node-hw-device-override"}>
{t("web.admin.nodes.form.gpuDevices")}
</Label>
{hasDeviceInventory ? (
<NodeDevicePicker
rows={deviceRows}
onToggle={(path) =>
setHwDeviceOverride(toggleHWDevice(hwDeviceOverride, path, devicePaths))
}
onInherit={() => setHwDeviceOverride("")}
disabled={isLocked("hw_device_override")}
onChange={(e) => setHwDeviceOverride(e.target.value)}
placeholder={t("web.admin.nodes.form.gpuDevicesPlaceholder")}
/>
{/*
Each branch is a whole sentence rather than a shared tail: an
NVENC node reaches the free-text field *with* a reported
inventory (its render devices are real, they are just not what
NVENC addresses), so "no inventory yet" is only true of the
other branch — and splitting one sentence across the
conditional also lets JSX drop the space before "empty".

Neither branch says what leaving this empty resolves to. Empty
inherits the cluster-wide playback.hw_device verbatim, and this
form does not know that value — naming a default here would be
a guess, and on the NVENC branch a dangerous one, since an
inherited /dev/dri path reaches NVENC as a CUDA identity.
*/}
<p className="text-muted-foreground text-sm">
{usesCUDADevices
? t("web.admin.nodes.form.cudaDeviceHelp", {
index: "0",
uuid: "GPU-a1b2c3d4",
path: "/dev/dri",
mono,
})
: t("web.admin.nodes.form.renderDeviceHelp", {
example: "/dev/dri/renderD128,/dev/dri/renderD129",
mono,
})}
</p>
</>
)}
{lockedNote("hw_device_override")}
</div>
) : (
<>
<Input
id="node-hw-device-override"
// Device paths read left to right; the translated placeholder keeps the page's direction.
dir={hwDeviceOverride ? "ltr" : undefined}
value={hwDeviceOverride}
disabled={isLocked("hw_device_override")}
onChange={(e) => setHwDeviceOverride(e.target.value)}
placeholder={t("web.admin.nodes.form.gpuDevicesPlaceholder")}
/>
{/*
Each branch is a whole sentence rather than a shared tail: an
NVENC node reaches the free-text field *with* a reported
inventory (its render devices are real, they are just not what
NVENC addresses), so "no inventory yet" is only true of the
other branch — and splitting one sentence across the
conditional also lets JSX drop the space before "empty".

Neither branch says what leaving this empty resolves to. Empty
inherits the cluster-wide playback.hw_device verbatim, and this
form does not know that value — naming a default here would be
a guess, and on the NVENC branch a dangerous one, since an
inherited /dev/dri path reaches NVENC as a CUDA identity.
*/}
<p className="text-muted-foreground text-sm">
{usesCUDADevices
? t("web.admin.nodes.form.cudaDeviceHelp", {
index: "0",
uuid: "GPU-a1b2c3d4",
path: "/dev/dri",
mono,
})
: t("web.admin.nodes.form.renderDeviceHelp", {
example: "/dev/dri/renderD128,/dev/dri/renderD129",
mono,
})}
</p>
</>
)}
{lockedNote("hw_device_override")}
</div>
)}
</>
)}

Expand Down
11 changes: 11 additions & 0 deletions web/src/pages/adminNodesPresentation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
nodeHasHWDeviceInventory,
hwDeviceSyntaxChanges,
nodeUsesCUDADevices,
nodeUsesVideoToolbox,
restoreEnvManagedFields,
} from "./adminNodesPresentation";

Expand Down Expand Up @@ -520,6 +521,16 @@ describe("buildNodeHWDeviceRows", () => {
});
});

describe("nodeUsesVideoToolbox", () => {
it("follows a Mac node's own resolution and an explicit pin", () => {
const mac = makeNode({ capabilities: { resolved: "videotoolbox" } });
expect(nodeUsesVideoToolbox(mac, HW_ACCEL_INHERIT, "auto")).toBe(true);
expect(nodeUsesVideoToolbox(mac, "auto", "qsv")).toBe(true);
expect(nodeUsesVideoToolbox(makeNode({}), "videotoolbox")).toBe(true);
expect(nodeUsesVideoToolbox(mac, HW_ACCEL_INHERIT, "qsv")).toBe(false);
});
});

describe("nodeUsesCUDADevices", () => {
it("follows what the node resolves to when the cluster names no backend", () => {
const node = makeNode({ capabilities: { resolved: "nvenc" } });
Expand Down
38 changes: 32 additions & 6 deletions web/src/pages/adminNodesPresentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ export const HW_ACCEL_INHERIT = "inherit";
const QSV_LABEL = "Intel Quick Sync (QSV)";
const VAAPI_LABEL = "VA-API";
const NVENC_LABEL = "NVIDIA NVENC";
const VIDEOTOOLBOX_LABEL = "VideoToolbox";

/**
* The acceleration choices a node may be pinned to, inherit first. The backend
Expand All @@ -689,6 +690,7 @@ export function hwAccelOverrideOptions(): { value: string; label: string }[] {
{ value: "qsv", label: QSV_LABEL },
{ value: "vaapi", label: VAAPI_LABEL },
{ value: "nvenc", label: NVENC_LABEL },
{ value: "videotoolbox", label: VIDEOTOOLBOX_LABEL },
{ value: "none", label: t("web.admin.nodes.hwAccel.software") },
];
}
Expand Down Expand Up @@ -723,20 +725,44 @@ export function nodeUsesCUDADevices(
override: string | null | undefined,
clusterHWAccel?: string | null,
): boolean {
return nodeBackend(node, override, clusterHWAccel) === "nvenc";
}

/**
* The backend this node will run under the editor's selection: an explicit
* backend, the cluster's backend while inheriting one, and otherwise what the
* node resolves to itself (an explicit `auto`, or inheriting an `auto`
* cluster). See nodeUsesCUDADevices for why inheritance follows the cluster.
*/
function nodeBackend(
node: StreamNode | null | undefined,
override: string | null | undefined,
clusterHWAccel?: string | null,
): string {
const selected = override?.trim().toLowerCase() ?? "";
if (selected === "nvenc") {
return true;
}
if (selected !== "" && selected !== HW_ACCEL_INHERIT && selected !== "auto") {
return false;
return selected;
}
if (selected === "" || selected === HW_ACCEL_INHERIT) {
const cluster = clusterHWAccel?.trim().toLowerCase() ?? "";
if (cluster !== "" && cluster !== "auto") {
return cluster === "nvenc";
return cluster;
}
}
return node?.capabilities?.resolved?.trim().toLowerCase() === "nvenc";
return node?.capabilities?.resolved?.trim().toLowerCase() ?? "";
}

/**
* Whether this node will run VideoToolbox, which takes no device: its FFmpeg
* arguments name none, so the device control has nothing to set. A Mac node on
* the cluster default or Auto resolves VideoToolbox itself.
*/
export function nodeUsesVideoToolbox(
node: StreamNode | null | undefined,
override: string | null | undefined,
clusterHWAccel?: string | null,
): boolean {
return nodeBackend(node, override, clusterHWAccel) === "videotoolbox";
}

/**
Expand Down
Loading