mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 23:38:47 +00:00
Monitor (web): the PCIe card shows the slowest card's link from gpu_pcie_bottleneck (#4623 / #5801 rule)
INT's rule (coordinator 11-16): the top-level gpu_pcie_* fields stay card 0's, and gpu_pcie_bottleneck names the card with the slowest link, all its fields from that one card; INT drops the producer part off5c07ddfd(the narrowest link folded into the top-level fields). The web Monitor's PCIe card is the one machine-wide link figure this branch shows, so it now reads pcieLink(hw): with several cards the bottleneck's generation (the one it can reach), width and current generation (for the "idle GenN" note), else the top-level fields (one card, or a server from before the field). No new words. The app's own Monitor reads the top-level link only for a single card, where card 0 is that card: unchanged. Test: serve/test_web_pcie_link.py runs app.js's pcieLink under node (several cards, one card, an older server, an incomplete bottleneck, the card's wiring): 4 of 4 fail on0027d210b, pass; with test_monitor and test_speed_average 21/21.
This commit is contained in:
1 parent
0027d210b8
commit
b2c826738c
2 files changed
+65
-3
No files matched your search
@@ -0,0 +1,52 @@
|
||||
"""The Monitor tab's PCIe card on a machine with several cards (#4623 / #5801 rule, 11-16): the server keeps the top-level gpu_pcie_* fields as
|
||||
card 0's and names the card with the slowest link in gpu_pcie_bottleneck (all its fields from that one card). The card shows that link; one
|
||||
card, or a server from before the field, shows the top-level fields as before. Runs app.js's own pcieLink() under node.
|
||||
|
||||
python -m pytest serve/test_web_pcie_link.py
|
||||
"""
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
WEB = Path(__file__).resolve().parent / "web"
|
||||
NODE = shutil.which("node")
|
||||
|
||||
|
||||
def function_source(text: str, name: str) -> str:
|
||||
start = text.index(f"function {name}(")
|
||||
end = text.index("\n}\n", start) + 3
|
||||
return text[start:end]
|
||||
|
||||
|
||||
@unittest.skipUnless(NODE, "node is needed to run the page's own code")
|
||||
class PcieLinkCard(unittest.TestCase):
|
||||
def link(self, hw):
|
||||
src = function_source((WEB / "app.js").read_text(encoding="utf-8"), "pcieLink")
|
||||
out = subprocess.run([NODE, "-e", f"{src}\nprocess.stdout.write(JSON.stringify(pcieLink({json.dumps(hw)})));"],
|
||||
capture_output=True, text=True, encoding="utf-8", timeout=60, check=True)
|
||||
return json.loads(out.stdout)
|
||||
|
||||
def test_several_cards_show_the_slowest_link_from_one_card(self):
|
||||
hw = {"gpu_pcie_gen": 4, "gpu_pcie_gen_max": 4, "gpu_pcie_width": 16, # card 0's, kept top level
|
||||
"gpu_pcie_bottleneck": {"card": 1, "gen": 1, "gen_max": 3, "width": 8, "width_max": 16}} # card 1, idle at Gen1
|
||||
self.assertEqual(self.link(hw), {"gen": 3, "cur": 1, "width": 8, "card": 1})
|
||||
|
||||
def test_one_card_or_an_older_server_shows_the_top_level_fields(self):
|
||||
self.assertEqual(self.link({"gpu_pcie_gen": 2, "gpu_pcie_gen_max": 4, "gpu_pcie_width": 16}), {"gen": 4, "cur": 2, "width": 16, "card": None})
|
||||
self.assertEqual(self.link({"gpu_pcie_gen": 4, "gpu_pcie_width": 16, "gpu_pcie_bottleneck": None}), {"gen": 4, "cur": 4, "width": 16, "card": None})
|
||||
|
||||
def test_a_bottleneck_without_a_width_or_generation_is_not_used(self):
|
||||
hw = {"gpu_pcie_gen": 4, "gpu_pcie_width": 16, "gpu_pcie_bottleneck": {"card": 1, "gen": None, "gen_max": None, "width": 8}}
|
||||
self.assertEqual(self.link(hw)["width"], 16)
|
||||
|
||||
def test_the_card_uses_pcie_link_for_its_value_and_idle_note(self):
|
||||
js = (WEB / "app.js").read_text(encoding="utf-8")
|
||||
self.assertIn("const link = pcieLink(hw), gen = link.gen;", js)
|
||||
self.assertIn('setMetric("pcie", gen ? `Gen${gen}` : null, link.width ? `x${link.width}` : "",', js)
|
||||
self.assertIn("(link.cur && gen && link.cur < gen ? ` · idle Gen${link.cur}` : \"\")", js)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+13
-3
@@ -413,6 +413,16 @@ function renderTotals(t) {
|
||||
return `Since ${since}: ${fmt(t.requests)} requests · ${fmt(read)} prompt tokens read${pSpeed} (${fmt(t.reused)} reused) · ` +
|
||||
`${fmt(t.output_tokens)} written${oSpeed}`;
|
||||
}
|
||||
/* The machine's PCIe link for the PCIe card: with several cards the one with the slowest link (gpu_pcie_bottleneck, which the server names
|
||||
from ONE card: its generation, width and the generation it can reach), else the top-level fields (one card, or a server from before it).
|
||||
gen is the generation the link can reach (NVML reports a lower one while a card is idle), cur the one it runs at now. */
|
||||
function pcieLink(hw) {
|
||||
const b = hw && hw.gpu_pcie_bottleneck;
|
||||
if (b && (b.gen || b.gen_max) && b.width) return { gen: b.gen_max || b.gen, cur: b.gen || null, width: b.width, card: b.card };
|
||||
if (!hw) return { gen: null, cur: null, width: null, card: null };
|
||||
return { gen: hw.gpu_pcie_gen_max || hw.gpu_pcie_gen || null, cur: hw.gpu_pcie_gen || null, width: hw.gpu_pcie_width || null, card: null };
|
||||
}
|
||||
|
||||
function renderMonitor(live, hw, st, eng, h, last, requests, totals, kept) {
|
||||
// model state
|
||||
// A local turn keeps metrics on "unloaded" for the whole engine start.
|
||||
@@ -493,10 +503,10 @@ function renderMonitor(live, hw, st, eng, h, last, requests, totals, kept) {
|
||||
spark("sp-temp", h.gpu_temp, 90);
|
||||
setMetric("power", hw.gpu_power == null ? null : fmt(hw.gpu_power), "W", hw.gpu_power_limit ? `of ${fmt(hw.gpu_power_limit)} W limit` : "");
|
||||
spark("sp-power", h.gpu_power, hw.gpu_power_limit);
|
||||
const gen = hw.gpu_pcie_gen_max || hw.gpu_pcie_gen;
|
||||
setMetric("pcie", gen ? `Gen${gen}` : null, hw.gpu_pcie_width ? `x${hw.gpu_pcie_width}` : "",
|
||||
const link = pcieLink(hw), gen = link.gen;
|
||||
setMetric("pcie", gen ? `Gen${gen}` : null, link.width ? `x${link.width}` : "",
|
||||
hw.gpu_pcie_rx_mb == null ? "" : `to GPU ${fmt(hw.gpu_pcie_rx_mb, hw.gpu_pcie_rx_mb < 10 ? 1 : 0)} MB/s` +
|
||||
(hw.gpu_pcie_gen && gen && hw.gpu_pcie_gen < gen ? ` · idle Gen${hw.gpu_pcie_gen}` : ""));
|
||||
(link.cur && gen && link.cur < gen ? ` · idle Gen${link.cur}` : ""));
|
||||
spark("sp-pcie", h.gpu_pcie_rx_mb);
|
||||
setMetric("cpu", hw.cpu == null ? null : fmt(hw.cpu), "%", st.threads ? `${st.cores ? `${st.cores} cores · ` : ""}${st.threads} threads` : "");
|
||||
spark("sp-cpu", h.cpu, 100);
|
||||
|
||||
Reference in new issue
Block a user