mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5427] [Other] Drafting: a GPU lookup that found no card is made again, so a service started at boot gets DFlash2 #5419
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5419
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5427
Author: @ezoushen
Created: 11/6/2026
Status: 🔄 Open
Base:
main← Head:drafting-boot-lookup📝 Commits (1)
8773d77drafting: a GPU lookup that found no card is made again at the next call, so a service started at boot before the NVIDIA driver answers gets DFlash2 (it kept the MTP, "DFlash2 isn't available on this graphics card"); a card that was found is still looked up once; tests📊 Changes
2 files changed (+41 additions, -14 deletions)
View changed files
📝
strata_control/drafting.py(+17 -14)📝
tests/terminal/test_drafting_hardware.py(+24 -0)📄 Description
Problem and result
strata serveruns as a systemd unit, with"drafting": "dflash2"named in its config. Started at boot, it chose the MTP every time with[strata] Drafting: MTP (DFlash2 isn't available on this graphics card). Asystemctl restartof the same unit later in the same boot chosedrafting: DFlash2 alone, and the engine then ran it:strata serve: DFlash2 drafter on (…q4_0-selq4.pack, graphs captured in 5 ms)./metricsshowed"drafting": "dflash2".Cause, from the code and the logs below:
nvidia-smifor the card. The NVIDIA driver did not answer yet: exit code 9, "couldn't communicate with the NVIDIA driver"./sys/class/drmlisted onlycard0; the NVIDIA card appears ascard1oncenvidia-drminitializes, about half a second later.rocminfoandsycl-lsare not installed on this box.strata_cli/cli.py_serve->_launch_plan->serve/server.pyengine_args->drafting.detect_hardware(). I traced this call stack in the 0.1.57 build. Which function made the call at boot was not logged.detect_backend()returnedNone, anddetect_hardware()kept(None, [])in_HARDWAREfor the life of the process. This is inferred from the code and the change in outcome; the return value was not logged.(None, []):hardware_support(None)givescan_run=False. With DFlash2 named in the config,decide()then picks the MTP withNOT_THIS_CARD.After this change, a lookup that found no card is not kept, and the next call probes again. A card that was found is still looked up once. On the same box with the same unit, the start chooses DFlash2 at boot.
nvidia-smiwrapper (below)Draftingline of the boot)detect_hardware()One of these boots used a version of this patch that differed only in the docstring.
Logs
nvidia-smicalls made by the Strata process at boot. A wrapper script placed first on the unit'sPATHlogged each call with the uptime, the exit code, the arguments and the/sys/class/drmentries, then ran/usr/bin/nvidia-smi. The kernel and service lines come fromjournalctl -o short-monotonic.I trimmed the lines: the pid and ppid, and repeated
drmandoutfields, are removed. The released-0.1.57 block was copied from my terminal output, because the log file was cleared before the next boot.The
--query-gpu=index,compute_capcall at about 16.3-16.5 s is a different query. It does not go throughengine_component._smi_query; in the code it is the BUILD.json architecture check inserve/server.py.Released 0.1.57:
With this change:
Related discussion
none. I searched the open and closed issues and pull requests for DFlash2, MTP and boot or start-up detection.
PARALLEL=8) differs from this one.This is a focused fix, with no default and no feature change.
Approach
Only
drafting.detect_hardware()changes: it keeps its answer only when a backend was found.I did not change the unit's ordering instead (for example
After=nvidia-persistenced.service). Strata's start should not depend on how a user or an app wrote the autostart, and the ordering does not promise that the driver answers.strata servealready callsdetect_hardware()again at the real start, so not keeping the failed answer is enough.Compatibility:
A computer where a card is found: unchanged. One lookup per process, the same result.
A computer where no card is found: each call to
detect_hardware()probes again, inengine_component.detect_backend(). What a probe costs depends on the system (read in the code, not measured):shutil.whichand sysfs reads.nvidia-smi --query-gpu=name,rocminfo(hipInfoon Windows) andsycl-lsprobes are not cached and have an 8 s timeout each. A hung tool can therefore cost its timeout on each call instead of once.I did not measure how often
detect_hardware()is called on such a computer.Validation
Revisions:
mainat9f7d977d2with this patch, for the tests.strata --version: 0.2.11, build 0.1.57) for the hardware runs, withdetect_hardware()in the installedstrata_control/drafting.pyreplaced by the patched function (the same text). The function in 0.1.57 is identical to the one onmainbefore this patch.Passed:
python -m pytest tests/terminal/test_drafting_hardware.py, on macOS 27.0.1 with Python 3.14.8 (pytest 9.2.0, requirements.txt and textual 8.2.8): 30 passed.test_a_lookup_that_found_no_card_is_made_againfails on9f7d977d2without the code change:Tuples differ: (None, []) != ('cuda', ['sm_89']). It passes with the change.if True:in place ofif backend is not None:) makes that test fail again.test_a_card_that_was_found_is_looked_up_oncepasses before and after. It fails when nothing is kept (if False:in place ofif _HARDWARE:):2 != 1calls ofdetect_backend.python -m pytest tests/terminal, on the same macOS environment, run on9f7d977d2and again with the patch.User=a normal user,After=network-online.target,WantedBy=multi-user.target,ExecStart=… strata serve --config <file> --host 0.0.0.0 --port 8080 --parallel 1."drafting": "dflash2".Failed:
none caused by this change. The tests in
tests/terminalthat fail in my environment fail the same way with and without the patch (the list is identical). They come from a sparse checkout withoutdocs/and most ofapps/, and from Python 3.14 on macOS.Not run:
Limits
engine_component._smi_querykeeps a failedcompute_capanswer for 30 s by design (round 0213: a stuck driver should cost its timeout once). The first look, at about 0.4 s, asks forcompute_capwhile the driver does not answer yet. The logs show a failed--query-gpu=compute_capat 4.34 s and no--query-gpu=compute_capcall after it.("cuda", []). This is inferred from the code and that log; the value itself was not logged.detect_hardware()when no backend was found is not enough. I tried that variant on the same box, and a failed--query-gpu=compute_capcall still came at 4.28 s from another caller. By the order inengine_args, that caller isdrafting_card_class()(inferred, not traced). From reading the code,updater.detect_hardware()also asks forcompute_cap.hardware_support("cuda", [])givescan_run=True.sm_120andsm_86, and thesm_121branch indrafting_vram_mib. On this card (sm_89, in neither table) I could not observe a difference.drafting_card_class()also keeps its first answer for the life of the process (_CARD_CLASS).decide()saysklassis not used any more, so I left it as it is.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.