pii: a GPU the driver reset under an idle pf-serve is loaded again on the GPU, not left on the CPU
kongbai01203 (plugins#853): after ~12 minutes idle the Vulkan pf-serve
exited 3 (vk::DeviceLostError) and Privacy Filter then said "GPU error,
running on CPU" until the GPU was tried again.
Cause: the driver's, not ours. pf-serve sits blocked on stdin while idle
and the idle unload only takes a free turn, so there is no race of ours
with a GPU call; the driver lost or reset the device under it, and the
next GPU call threw (an uncaught vk::DeviceLostError ends in abort, exit
3 on MinGW). magpie then counted one death on the GPU as a lost GPU.
Now one that dies on the GPU is started again on the GPU: a new
pf-serve gets a new device. Only a second death (or hang) in a row on the
GPU moves it to the CPU, until gpuRetryAfter. Status says gpuReset when
the error is a device lost, and gpuAgain when the GPU is tried again;
Settings > Privacy says "On, on the CPU until 14:38: the graphics driver
reset the GPU (device lost)" (and "until {time}" on a GPU failure), in
en, zh, zh-TW, ja and de.
Not changed: the model's size. Privacy Filter has q8 (1.64GB) and f16
only, no smaller quant; AstrLink Guard (39MB) is the small choice.
Its ~1.8GB private on the CPU goes with pf-v4 (mmap, 691a10446), whose
pin is another session's work; on Vulkan the ~1.9GB is the driver's.
Run (mote, through mote-run):
- gofmt -l, go vet (darwin, linux, windows), go test -count=1
./internal/pii ./internal/gui ./internal/masking: ok
- GUI: privacy-model, i18n-keys, i18n-en-no-cjk, masking-records in
chromium and webkit (privacy-model at 1100 and 640, every language):
219 of 224, then privacy-model 104 of 104 after zh-TW's expected time
was made 下午02:38 (hhmm's zh-TW form). The one other red is i18n-keys
"a plugin's words are its own", red on main and filed (#5332, #5426,
#5482); this change adds no plugin words.
At this head, rebased on 8f6298fb5: gofmt, go vet and go test
./internal/pii ok; privacy-model and i18n-en-no-cjk 108 of 108 in
chromium and webkit.
Rebased after on 37df73b1b (key balances; the one file it shares,
i18n.js, holds other keys there), not run again.
Broken by hand: serve.go put back to HEAD's: TestGPUDeviceLostReloadsOnGPU,
TestGPUDeathMovesToCPU and TestLostGPUTriedAgain red (starts [gpu CPU]).
app.js put back to HEAD's: the new privacy-model test 10 of 10 red
(chromium).
Not tried: a real device lost on a GPU (it can't be forced here); a
crash in pf_free's teardown at idle unload (harmless: end() ignores the
exit status; a fix needs a native change and a new pf tag).
Full suite: not run at push.
Reported-by: kongbai01203
This commit is contained in:
@@ -22014,6 +22014,11 @@ function pmSub(m) {
|
||||
// the Intel build on Apple silicon: Go, translated, several times slower
|
||||
if (m.rosetta) return t("On, slowly under Rosetta: the next update installs magpie for Apple silicon");
|
||||
if (m.gpuError && m.model === "astrlink-guard") return t("On, on the CPU: CoreML failed ({error})", { error: m.gpuError });
|
||||
// Privacy Filter lost the GPU: to its driver resetting it (device
|
||||
// lost), or to a fault; the GPU is tried again at gpuAgain
|
||||
const time = m.gpuAgain ? hhmm(m.gpuAgain) : "";
|
||||
if (m.gpuReset) return time ? t("On, on the CPU until {time}: the graphics driver reset the GPU (device lost)", { time }) : t("On, on the CPU: the graphics driver reset the GPU (device lost)");
|
||||
if (m.gpuError && time) return t("On, on the CPU until {time}: the GPU failed ({error})", { time, error: m.gpuError });
|
||||
return m.gpuError ? t("On, on the CPU: the GPU failed ({error})", { error: m.gpuError }) : t("On, on the CPU");
|
||||
}
|
||||
if (m.on) return t("On: the model starts with the next request");
|
||||
|
||||
@@ -1495,6 +1495,9 @@ const I18N = {
|
||||
"The model didn't answer, so the rules mask requests alone: {error}": "模型没有响应,请求暂时只按规则脱敏:{error}",
|
||||
"On, on the GPU ({device})": "已开启,运行在 GPU({device})",
|
||||
"On, on the CPU: the GPU failed ({error})": "已开启,运行在 CPU:GPU 出错({error})",
|
||||
"On, on the CPU until {time}: the GPU failed ({error})": "已开启,{time} 前运行在 CPU:GPU 出错({error})",
|
||||
"On, on the CPU: the graphics driver reset the GPU (device lost)": "已开启,运行在 CPU:显卡驱动重置了 GPU(设备丢失)",
|
||||
"On, on the CPU until {time}: the graphics driver reset the GPU (device lost)": "已开启,{time} 前运行在 CPU:显卡驱动重置了 GPU(设备丢失)",
|
||||
"On, on the CPU": "已开启,运行在 CPU",
|
||||
"On, slowly under Rosetta: the next update installs magpie for Apple silicon": "已开启,但在 Rosetta 下运行较慢:下次更新会装上 Apple 芯片版 magpie",
|
||||
"On, with CoreML on the Neural Engine": "已开启,通过 CoreML 运行在神经网络引擎",
|
||||
@@ -6231,6 +6234,9 @@ const I18N = {
|
||||
"The model didn't answer, so the rules mask requests alone: {error}": "模型沒有回應,請求暫時只按規則脫敏:{error}",
|
||||
"On, on the GPU ({device})": "已開啟,執行於 GPU({device})",
|
||||
"On, on the CPU: the GPU failed ({error})": "已開啟,執行於 CPU:GPU 出錯({error})",
|
||||
"On, on the CPU until {time}: the GPU failed ({error})": "已開啟,{time} 前執行於 CPU:GPU 出錯({error})",
|
||||
"On, on the CPU: the graphics driver reset the GPU (device lost)": "已開啟,執行於 CPU:顯示卡驅動程式重設了 GPU(裝置遺失)",
|
||||
"On, on the CPU until {time}: the graphics driver reset the GPU (device lost)": "已開啟,{time} 前執行於 CPU:顯示卡驅動程式重設了 GPU(裝置遺失)",
|
||||
"On, on the CPU": "已開啟,執行於 CPU",
|
||||
"On, slowly under Rosetta: the next update installs magpie for Apple silicon": "已開啟,但在 Rosetta 下執行較慢:下次更新會裝上 Apple 晶片版 magpie",
|
||||
"On, with CoreML on the Neural Engine": "已開啟,透過 CoreML 執行於神經網路引擎",
|
||||
@@ -10936,6 +10942,9 @@ const I18N = {
|
||||
"The model didn't answer, so the rules mask requests alone: {error}": "モデルが応答しないため、リクエストはルールだけでマスクしています:{error}",
|
||||
"On, on the GPU ({device})": "オン、GPU で実行中({device})",
|
||||
"On, on the CPU: the GPU failed ({error})": "オン、CPU で実行中:GPU が失敗しました({error})",
|
||||
"On, on the CPU until {time}: the GPU failed ({error})": "オン、{time} まで CPU で実行中:GPU が失敗しました({error})",
|
||||
"On, on the CPU: the graphics driver reset the GPU (device lost)": "オン、CPU で実行中:グラフィックスドライバーが GPU をリセットしました(デバイスロスト)",
|
||||
"On, on the CPU until {time}: the graphics driver reset the GPU (device lost)": "オン、{time} まで CPU で実行中:グラフィックスドライバーが GPU をリセットしました(デバイスロスト)",
|
||||
"On, on the CPU": "オン、CPU で実行中",
|
||||
"On, slowly under Rosetta: the next update installs magpie for Apple silicon": "オン、Rosetta で動作中のため低速です。次のアップデートで Apple シリコン版の magpie が入ります",
|
||||
"On, with CoreML on the Neural Engine": "オン、CoreML により Neural Engine で実行中",
|
||||
@@ -15672,6 +15681,9 @@ const I18N = {
|
||||
"The model didn't answer, so the rules mask requests alone: {error}": "Das Modell antwortet nicht, Anfragen werden nur nach den Regeln maskiert: {error}",
|
||||
"On, on the GPU ({device})": "An, auf der GPU ({device})",
|
||||
"On, on the CPU: the GPU failed ({error})": "An, auf der CPU: die GPU ist ausgefallen ({error})",
|
||||
"On, on the CPU until {time}: the GPU failed ({error})": "An, bis {time} auf der CPU: die GPU ist ausgefallen ({error})",
|
||||
"On, on the CPU: the graphics driver reset the GPU (device lost)": "An, auf der CPU: der Grafiktreiber hat die GPU zurückgesetzt (Gerät verloren)",
|
||||
"On, on the CPU until {time}: the graphics driver reset the GPU (device lost)": "An, bis {time} auf der CPU: der Grafiktreiber hat die GPU zurückgesetzt (Gerät verloren)",
|
||||
"On, on the CPU": "An, auf der CPU",
|
||||
"On, slowly under Rosetta: the next update installs magpie for Apple silicon": "An, unter Rosetta langsam: das nächste Update installiert magpie für Apple Silicon",
|
||||
"On, with CoreML on the Neural Engine": "An, mit CoreML auf der Neural Engine",
|
||||
|
||||
@@ -65,9 +65,9 @@ function serve(lang, masking, model, posts) {
|
||||
};
|
||||
}
|
||||
|
||||
async function open(engine, lang, width, masking, model, posts) {
|
||||
async function open(engine, lang, width, masking, model, posts, context = {}) {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 1400 } })).newPage();
|
||||
const page = await (await browser.newContext({ viewport: { width, height: 1400 }, ...context })).newPage();
|
||||
page.setDefaultTimeout(8000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
const errors = [];
|
||||
@@ -115,6 +115,22 @@ const runs = {
|
||||
rosetta: { device: "CPU", rosetta: true },
|
||||
};
|
||||
|
||||
// Privacy Filter moved to the CPU after its GPU was lost (plugins#853,
|
||||
// kongbai01203: "GPU error, running on CPU" read as a fault of the
|
||||
// model's): a GPU the graphics driver reset says so, and either says until
|
||||
// when, 14:38 UTC here (zh-TW says it 下午02:38)
|
||||
const lostWords = {
|
||||
en: { reset: "On, on the CPU until 02:38 PM: the graphics driver reset the GPU (device lost)", failed: "On, on the CPU until 02:38 PM: the GPU failed (ended)" },
|
||||
zh: { reset: "已开启,14:38 前运行在 CPU:显卡驱动重置了 GPU(设备丢失)", failed: "已开启,14:38 前运行在 CPU:GPU 出错(ended)" },
|
||||
"zh-TW": { reset: "已開啟,下午02:38 前執行於 CPU:顯示卡驅動程式重設了 GPU(裝置遺失)", failed: "已開啟,下午02:38 前執行於 CPU:GPU 出錯(ended)" },
|
||||
ja: { reset: "オン、14:38 まで CPU で実行中:グラフィックスドライバーが GPU をリセットしました(デバイスロスト)", failed: "オン、14:38 まで CPU で実行中:GPU が失敗しました(ended)" },
|
||||
de: { reset: "An, bis 14:38 auf der CPU: der Grafiktreiber hat die GPU zurückgesetzt (Gerät verloren)", failed: "An, bis 14:38 auf der CPU: die GPU ist ausgefallen (ended)" },
|
||||
};
|
||||
const lostRuns = {
|
||||
reset: { gpuError: "pf-serve-vulkan ended (exit status 3): terminate called after throwing an instance of 'vk::DeviceLostError' | what(): vk::Device::waitForFences: ErrorDeviceLost", gpuReset: true },
|
||||
failed: { gpuError: "ended" },
|
||||
};
|
||||
|
||||
// what the row shows: its words and its New mark, whether they rest out of
|
||||
// sight for the hover card (hint) or are cut, that it is inside the list,
|
||||
// and that it is the page's first setting
|
||||
@@ -194,6 +210,24 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
}
|
||||
}
|
||||
|
||||
for (const lang of Object.keys(lostWords)) {
|
||||
for (const width of [1100, 640]) {
|
||||
test(`${engine} ${lang} ${width}px: Privacy Filter on the CPU says how the GPU was lost, and until when`, async () => {
|
||||
for (const [k, run] of Object.entries(lostRuns)) {
|
||||
const model = { supported: true, installed: true, on: true, running: true, device: "cpu", size, gpuAgain: Date.UTC(2026, 10, 8, 14, 38), ...run };
|
||||
const { browser, page, errors } = await open(engine, lang, width, true, model, [], { locale: "en-US", timezoneId: "UTC" });
|
||||
await page.locator("#privacyModelRow .segs").waitFor();
|
||||
const m = await look(page);
|
||||
await browser.close();
|
||||
// an engine's ICU may put a narrow space before PM
|
||||
assert.equal(m.sub.replace(/[\u202f\u00a0]/g, " "), lostWords[lang][k], k);
|
||||
assert(!m.hint && !m.cut && m.inside && !m.wide, `${k} shown in full and inside: ${JSON.stringify(m)}`);
|
||||
assert.deepEqual(errors, []);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
test(`${engine}: a download is cancelled, and a downloaded model deleted after asking`, async (t) => {
|
||||
const posts = [], model = { supported: true, installed: false, size };
|
||||
const { browser, page, errors } = await open(engine, "en", 1100, true, model, posts);
|
||||
|
||||
@@ -49,8 +49,11 @@ const (
|
||||
// gpuhang on the GPU, never answers a request; else ok
|
||||
// gpuhangonce on the GPU, never answers the first request of the
|
||||
// test; else ok
|
||||
// gpudiesonce on the GPU, ends at the first request of the test;
|
||||
// else ok
|
||||
// gpudiestwice on the GPU, ends at the first two requests of the
|
||||
// test; else ok
|
||||
// gpulostidle on the GPU, answers the first request of the test and
|
||||
// ends at the second, its device lost as Vulkan's is
|
||||
// after an idle spell (plugins#853); else ok
|
||||
//
|
||||
// Like pf-serve, it first writes ggml's startup lines to stderr.
|
||||
func fakeServe(mode string) {
|
||||
@@ -120,18 +123,28 @@ func fakeServe(mode string) {
|
||||
texts[i] = string(b)
|
||||
}
|
||||
logf("request %d %q", n, texts)
|
||||
// once: the first request of the test, on the GPU
|
||||
once := false
|
||||
if p := os.Getenv(fakeLog); p != "" && gpu && strings.HasSuffix(mode, "once") {
|
||||
if f, err := os.OpenFile(p+".once", os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644); err == nil {
|
||||
f.Close()
|
||||
once = true
|
||||
// nth: which request of the test this is on the GPU, counted
|
||||
// across the pf-serves the test starts
|
||||
nth := 0
|
||||
if p := os.Getenv(fakeLog); p != "" && gpu {
|
||||
for nth = 1; ; nth++ {
|
||||
f, err := os.OpenFile(fmt.Sprintf("%s.gpu%d", p, nth), os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644)
|
||||
if err == nil {
|
||||
f.Close()
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
once := strings.HasSuffix(mode, "once") && nth == 1
|
||||
switch {
|
||||
case mode == "gpudies" && gpu, mode == "gpudiesonce" && once:
|
||||
case mode == "gpudies" && gpu, mode == "gpudiestwice" && gpu && nth <= 2:
|
||||
fmt.Fprintln(os.Stderr, "ggml_metal: device lost")
|
||||
os.Exit(3)
|
||||
case mode == "gpulostidle" && nth == 2:
|
||||
// as pf-serve-vulkan on Windows (MinGW) ends with it
|
||||
fmt.Fprintln(os.Stderr, "terminate called after throwing an instance of 'vk::DeviceLostError'")
|
||||
fmt.Fprintln(os.Stderr, " what(): vk::Device::waitForFences: ErrorDeviceLost")
|
||||
os.Exit(3)
|
||||
case mode == "hang", mode == "gpuhang" && gpu, mode == "gpuhangonce" && once:
|
||||
time.Sleep(time.Hour)
|
||||
case mode == "asserts":
|
||||
|
||||
+15
-5
@@ -19,11 +19,12 @@
|
||||
//
|
||||
// A process of its own, not linked in: 1.7 GB the gateway would otherwise
|
||||
// hold for good, and a GPU driver's crash that would end the gateway with
|
||||
// it. One that dies is started again; one that dies on the GPU, doesn't
|
||||
// load there in gpuLoadTimeout, or hangs there twice in a row, is started
|
||||
// on the CPU until the GPU is tried again (gpuRetryAfter), with no restart
|
||||
// of magpie. One that keeps failing holds requests back at once, not
|
||||
// after a load each, until it is tried again (retryAfter).
|
||||
// it. One that dies is started again, on the GPU too: a driver that reset
|
||||
// the GPU (device lost) is got past by a load there. One that dies or hangs
|
||||
// on the GPU twice in a row, or doesn't load there in gpuLoadTimeout, is
|
||||
// started on the CPU until the GPU is tried again (gpuRetryAfter), with
|
||||
// no restart of magpie. One that keeps failing holds requests back at
|
||||
// once, not after a load each, until it is tried again (retryAfter).
|
||||
package pii
|
||||
|
||||
import (
|
||||
@@ -155,6 +156,11 @@ type Status struct {
|
||||
GPU bool `json:"gpu,omitempty"`
|
||||
LoadMS int `json:"loadMs,omitempty"`
|
||||
GPUError string `json:"gpuError,omitempty"`
|
||||
// GPUReset says the GPU was lost to its driver resetting it
|
||||
// (Vulkan's device lost), not to a fault of the model's; GPUAgain
|
||||
// is when the GPU is tried again (Unix ms), while that is ahead
|
||||
GPUReset bool `json:"gpuReset,omitempty"`
|
||||
GPUAgain int64 `json:"gpuAgain,omitempty"`
|
||||
// why the last request got no answer
|
||||
Failed string `json:"failed,omitempty"`
|
||||
// pf-serve is loading the model, and how many requests wait for it
|
||||
@@ -179,7 +185,11 @@ func Now() Status {
|
||||
if s.GPUError == "" {
|
||||
s.GPUError = srv.gpuLost
|
||||
}
|
||||
if srv.cpu && time.Now().Before(srv.gpuAgain) {
|
||||
s.GPUAgain = srv.gpuAgain.UnixMilli()
|
||||
}
|
||||
srv.mu.Unlock()
|
||||
s.GPUReset = deviceLost.MatchString(s.GPUError)
|
||||
s.Waiting = int(waiting.Load())
|
||||
return s
|
||||
}
|
||||
|
||||
+23
-14
@@ -378,6 +378,10 @@ var startup = regexp.MustCompile(`^(ggml_metal_(device_init|library_init|init|fr
|
||||
// trouble is a line that says something went wrong, startup's or not.
|
||||
var trouble = regexp.MustCompile(`(?i)error|fail|assert|abort|unable|cannot|can't|could not|out of memory|exception|lost`)
|
||||
|
||||
// deviceLost is a GPU the driver reset under pf-serve, as ggml's Vulkan
|
||||
// says it (vk::DeviceLostError, VK_ERROR_DEVICE_LOST) and Metal's.
|
||||
var deviceLost = regexp.MustCompile(`(?i)DeviceLost|device[ _]lost`)
|
||||
|
||||
// lastSaid is the last n lines of stderr that say more than ggml's
|
||||
// startup, joined.
|
||||
func lastSaid(stderr string, n int) string {
|
||||
@@ -482,11 +486,14 @@ func end(h *helper) {
|
||||
}
|
||||
|
||||
// classify asks pf-serve, started if it isn't, what is in texts. One that
|
||||
// fails is ended and started again; one that died on the GPU is started
|
||||
// on the CPU, until the GPU is tried again. One that magpie ended on the
|
||||
// GPU for taking too long is started again on the GPU: a request too
|
||||
// slow for its time is no lost GPU. Twice in a row there is, and the CPU
|
||||
// is tried for the next. The caller holds turn.
|
||||
// fails is ended and started again. One that failed on the GPU is started
|
||||
// again on the GPU: one that died there is most often a GPU the driver
|
||||
// reset under it (vk::DeviceLostError, kongbai01203's after an idle
|
||||
// spell), which a new pf-serve gets a new device of, and one magpie ended
|
||||
// for taking too long had a request too slow for its time. Twice in a row
|
||||
// the GPU is lost, and the CPU is tried, until the GPU is tried again: at
|
||||
// once for one that died, and from the next request for one that hung,
|
||||
// whose request has waited twice already. The caller holds turn.
|
||||
func classify(texts []string) ([][]redact.Found, error) {
|
||||
out, err := classifyTurn(texts)
|
||||
srv.mu.Lock()
|
||||
@@ -520,7 +527,7 @@ func heldBack() error {
|
||||
|
||||
func classifyTurn(texts []string) ([][]redact.Found, error) {
|
||||
var last error
|
||||
for try := 0; try < 2; try++ {
|
||||
for try := 0; try < 3; try++ {
|
||||
srv.mu.Lock()
|
||||
h, cpu, stop := srv.h, srv.cpu, stopCh()
|
||||
var gone *helper
|
||||
@@ -578,17 +585,19 @@ func classifyTurn(texts []string) ([][]redact.Found, error) {
|
||||
h.kill()
|
||||
return nil, errStopped
|
||||
}
|
||||
if h.hello.GPU {
|
||||
if h.slow.Load() != nil && try == 0 {
|
||||
// ended for taking too long: a slow request, or a
|
||||
// GPU's hang that a new pf-serve gets past, is no lost
|
||||
// GPU, and the try again is on the GPU
|
||||
} else {
|
||||
lostGPULocked(err.Error())
|
||||
}
|
||||
hung := h.slow.Load() != nil
|
||||
if h.hello.GPU && try > 0 {
|
||||
lostGPULocked(err.Error())
|
||||
}
|
||||
// else the try again is on the GPU: a GPU the driver reset
|
||||
// (device lost), a crash, or a hang that a new pf-serve gets
|
||||
// past, is no lost GPU yet
|
||||
srv.mu.Unlock()
|
||||
h.kill()
|
||||
if try == 1 && (!h.hello.GPU || hung) {
|
||||
// a third try only after the GPU died twice, on the CPU
|
||||
break
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("the local masking model failed: %w", last)
|
||||
}
|
||||
|
||||
+49
-16
@@ -84,8 +84,9 @@ func TestWithinCutsSpansAtTheTextsEnds(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// pf-serve that dies on the GPU is started again on the CPU, which the
|
||||
// request then gets its answer from, and stays there; the status says why.
|
||||
// pf-serve that dies on the GPU twice in a row is started on the CPU,
|
||||
// which the request then gets its answer from, and stays there; the
|
||||
// status says why, and when the GPU is tried again.
|
||||
func TestGPUDeathMovesToCPU(t *testing.T) {
|
||||
log, gpu := gpuInstall(t, "gpudies")
|
||||
got, err := Find([]string{"hi Alice"})
|
||||
@@ -95,22 +96,54 @@ func TestGPUDeathMovesToCPU(t *testing.T) {
|
||||
if !reflect.DeepEqual(got, [][]redact.Found{{person(3, 8)}}) {
|
||||
t.Fatalf("Find = %v", got)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, "start pf-serve CPU"}) {
|
||||
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, gpu, "start pf-serve CPU"}) {
|
||||
t.Fatalf("starts = %q", starts)
|
||||
}
|
||||
st := Now()
|
||||
if st.GPU || st.Device != "CPU" || !strings.Contains(st.GPUError, "device lost") {
|
||||
t.Fatalf("Now = %+v, want on the CPU saying the GPU was lost", st)
|
||||
if st.GPU || st.Device != "CPU" || !strings.Contains(st.GPUError, "device lost") || !st.GPUReset {
|
||||
t.Fatalf("Now = %+v, want on the CPU saying the GPU was reset", st)
|
||||
}
|
||||
if again := time.Until(time.UnixMilli(st.GPUAgain)); again < 9*time.Minute || again > 11*time.Minute {
|
||||
t.Fatalf("GPUAgain in %s, want the GPU tried again in 10 minutes", again)
|
||||
}
|
||||
Stop()
|
||||
if _, err := Find([]string{"Alice again"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 3 || starts[2] != "start pf-serve CPU" {
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 4 || starts[3] != "start pf-serve CPU" {
|
||||
t.Fatalf("starts = %q, want the CPU after a stop too", starts)
|
||||
}
|
||||
}
|
||||
|
||||
// A GPU pf-serve that answered, and dies at a later request because the
|
||||
// driver reset the GPU while it sat idle (vk::DeviceLostError, exit 3:
|
||||
// kongbai01203 in plugins#853, ~12 minutes after it loaded), is loaded
|
||||
// again on the GPU, which the request gets its answer from; the model
|
||||
// stays on the GPU, and the status says nothing was lost. Before, it moved
|
||||
// to the CPU for 10 minutes and said "the GPU failed".
|
||||
func TestGPUDeviceLostReloadsOnGPU(t *testing.T) {
|
||||
log, gpu := gpuInstall(t, "gpulostidle")
|
||||
if _, err := Find([]string{"hi Alice"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, err := Find([]string{"Alice after a while"})
|
||||
if err != nil || !reflect.DeepEqual(got, [][]redact.Found{{person(0, 5)}}) {
|
||||
t.Fatalf("Find = %v, %v", got, err)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, gpu}) {
|
||||
t.Fatalf("starts = %q, want the GPU loaded again", starts)
|
||||
}
|
||||
if st := Now(); !st.GPU || st.GPUError != "" || st.GPUReset || st.GPUAgain != 0 {
|
||||
t.Fatalf("Now = %+v, want on the GPU with nothing lost", st)
|
||||
}
|
||||
srv.mu.Lock()
|
||||
cpu, fails := srv.cpu, srv.gpuFails
|
||||
srv.mu.Unlock()
|
||||
if cpu || fails != 0 {
|
||||
t.Fatalf("cpu=%v fails=%d after the GPU was loaded again", cpu, fails)
|
||||
}
|
||||
}
|
||||
|
||||
// The answer of a GPU pf-serve that died is read only after it has
|
||||
// exited and been waited for, and the status still says the GPU was lost,
|
||||
// not "read |0: file already closed" (#3741: cmd.Wait closed the pipe
|
||||
@@ -327,8 +360,8 @@ func TestServeStartsWithoutResidencyHeartbeat(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got := fakeLines(t, log, "residency")
|
||||
if len(got) != 2 {
|
||||
t.Fatalf("residency lines = %q, want a GPU and a CPU start", got)
|
||||
if len(got) != 3 {
|
||||
t.Fatalf("residency lines = %q, want two GPU starts and a CPU one", got)
|
||||
}
|
||||
for _, l := range got {
|
||||
if l != "residency 1" {
|
||||
@@ -474,8 +507,8 @@ func TestServeKeepsMoEChunkUnlessUserSets(t *testing.T) {
|
||||
user string // "" unset
|
||||
want []string
|
||||
}{
|
||||
{"vulkan", true, "", []string{"moechunk pf-serve-vulkan ", "moechunk pf-serve "}},
|
||||
{"vulkan, user's own", true, "3072", []string{"moechunk pf-serve-vulkan 3072", "moechunk pf-serve 3072"}},
|
||||
{"vulkan", true, "", []string{"moechunk pf-serve-vulkan ", "moechunk pf-serve-vulkan ", "moechunk pf-serve "}},
|
||||
{"vulkan, user's own", true, "3072", []string{"moechunk pf-serve-vulkan 3072", "moechunk pf-serve-vulkan 3072", "moechunk pf-serve 3072"}},
|
||||
}
|
||||
if runtime.GOOS == "darwin" {
|
||||
cases = append(cases, struct {
|
||||
@@ -483,7 +516,7 @@ func TestServeKeepsMoEChunkUnlessUserSets(t *testing.T) {
|
||||
vulkan bool
|
||||
user string
|
||||
want []string
|
||||
}{"metal", false, "", []string{"moechunk pf-serve ", "moechunk pf-serve "}})
|
||||
}{"metal", false, "", []string{"moechunk pf-serve ", "moechunk pf-serve ", "moechunk pf-serve "}})
|
||||
}
|
||||
for _, c := range cases {
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
@@ -560,17 +593,17 @@ func TestGPUHungTwiceMovesToCPU(t *testing.T) {
|
||||
// no restart of magpie: the CPU's pf-serve makes way for the GPU's, and a
|
||||
// GPU that answers is the model's again.
|
||||
func TestLostGPUTriedAgain(t *testing.T) {
|
||||
log, gpu := gpuInstall(t, "gpudiesonce")
|
||||
log, gpu := gpuInstall(t, "gpudiestwice")
|
||||
if _, err := Find([]string{"hi Alice"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, "start pf-serve CPU"}) {
|
||||
t.Fatalf("starts = %q, want the GPU, then the CPU", starts)
|
||||
if starts := fakeLines(t, log, "start"); !reflect.DeepEqual(starts, []string{gpu, gpu, "start pf-serve CPU"}) {
|
||||
t.Fatalf("starts = %q, want the GPU twice, then the CPU", starts)
|
||||
}
|
||||
if _, err := Find([]string{"Alice two"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 2 {
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 3 {
|
||||
t.Fatalf("starts = %q, want the CPU kept until the GPU's time", starts)
|
||||
}
|
||||
srv.mu.Lock()
|
||||
@@ -583,7 +616,7 @@ func TestLostGPUTriedAgain(t *testing.T) {
|
||||
if err != nil || !reflect.DeepEqual(got, [][]redact.Found{{person(0, 5)}}) {
|
||||
t.Fatalf("Find = %v, %v", got, err)
|
||||
}
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 3 || starts[2] != gpu {
|
||||
if starts := fakeLines(t, log, "start"); len(starts) != 4 || starts[3] != gpu {
|
||||
t.Fatalf("starts = %q, want the GPU tried again", starts)
|
||||
}
|
||||
if st := Now(); !st.GPU || st.GPUError != "" {
|
||||
|
||||
Reference in New Issue
Block a user