Skip to content

Commit aa85515

Browse files
Model K: player-visible option text names the standard path (#265)
Player-visible option text for Model K now names the default as the standard path, with no claim of exactness. - The k_approx create note reads "(opt-in faster approximation; the default is the standard path)". - The a1 lines say that legacy-input frames "run the standard input stage". - The front end's K mode line reads ", the standard path" for the default and ", an approximation (opt-in)" for an opt-in mode. test_k_option_text.py checks the wording, and the device and interop tests read the new strings. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
1 parent a819430 commit aa85515

5 files changed

Lines changed: 59 additions & 8 deletions

File tree

‎clean/k/runtime/runtime_k.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,9 @@ bool KRuntime::create(const WgRtConfig& c, Device* dev, AllocFn alloc_fn, bool e
523523
if (approx_a2_ && !compact_head_) return fail("model K: k_approx=a2 needs the compact head (k_head=compact, the default)");
524524
approx_note_ = std::string("model K: close approximation k_approx=") + (approx_a1_ ? "a1" : "") +
525525
(approx_a1_ && approx_a2_ ? "," : "") + (approx_a2_ ? "a2" : "") +
526-
" (opt-in, not bit-exact; the default path is exact)" +
526+
" (opt-in faster approximation; the default is the standard path)" +
527527
(approx_a1_ ? std::string("; a1 applies to the tiled input stage, frames on the legacy input path "
528-
"run the exact input stage")
528+
"run the standard input stage")
529529
: std::string());
530530
}
531531
const std::string krule = option(c, "k_expo_rule");
@@ -1247,7 +1247,7 @@ bool KRuntime::frame(const WgRtFrame& fr, const FrameIo* io) {
12471247
// log, the first time in this context (take_frame_note)
12481248
if (approx_a1_ && !use_tiled && !a1_legacy_noted_) {
12491249
a1_legacy_noted_ = true;
1250-
frame_note_ = "model K: k_approx=a1 applies to the tiled input stage only; this context's frames on the legacy input path (a render size above 0.68 x the output, a jitter outside [-0.5, 0.5], or input_tiled=0) run the exact input stage (this line once per context)";
1250+
frame_note_ = "model K: k_approx=a1 applies to the tiled input stage only; this context's frames on the legacy input path (a render size above 0.68 x the output, a jitter outside [-0.5, 0.5], or input_tiled=0) run the standard input stage (this line once per context)";
12511251
}
12521252
// k_in_exact: the output colour taps by k_out_color (KFrame's exact plan), not by the tiled input kernel
12531253
const bool use_tiled_color = use_tiled && !in_exact_ && !reset && 4LL * Bw_ >= W_ && 4LL * Bh_ >= H_;

‎clean/k/tests/test_k_approx_executor.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
k_approx=a2 output form; the executor runs the direct one) runs
77
test_interop_d3d12.exe's `matrix` case at 1080p (every usual upscaler-mode ratio, HDR and LDR, both declared maximum
88
sizes): with nothing set every context is taken by the D3D12 executor and its frame runs (the executor's warm-up does not
9-
compile the unselected form) and its mode line names the exact path; with k_approx=a2 every context is refused, naming
9+
compile the unselected form) and its mode line names the standard path; with k_approx=a2 every context is refused, naming
1010
the shader. The unchanged build passes with k_approx=a2 (control: the refusal comes from the changed byte) and its mode
1111
line names k_approx=a2 and an approximation.
1212
@@ -84,17 +84,17 @@ def test_selected_form_runs(self):
8484
self.assertTrue(out.rstrip().endswith("PASS"), out)
8585
modes = mode_lines(out)
8686
self.assertEqual(len(modes), 20, modes)
87-
self.assertTrue(all(";k_approx=a2;" in m and "an approximation (not bit-exact)" in m for m in modes), modes)
87+
self.assertTrue(all(";k_approx=a2;" in m and "an approximation (opt-in)" in m for m in modes), modes)
8888

8989
def test_unselected_form_is_not_prepared(self):
90-
"""The changed shader, nothing set: every context runs on the exact path (the warm-up skips the form)."""
90+
"""The changed shader, nothing set: every context runs on the standard path (the warm-up skips the form)."""
9191
rc, out = self.run_case(True, [])
9292
self.assertEqual(rc, 0, out)
9393
self.assertTrue(out.rstrip().endswith("PASS"), out)
9494
self.assertNotIn("integrity mismatch", out)
9595
modes = mode_lines(out)
9696
self.assertEqual(len(modes), 20, modes)
97-
self.assertTrue(all("k_approx" not in m and "the exact path" in m for m in modes), modes)
97+
self.assertTrue(all("k_approx" not in m and "the standard path" in m for m in modes), modes)
9898

9999
def test_a1_legacy_line_once_per_context(self):
100100
"""The a1 contract through the executor: the matrix's DLAA contexts (render size = output: the legacy input path)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: MIT
2+
"""Model K's player-visible option text (host check, no GPU).
3+
4+
The create note of the opt-in k_approx option (clean/k/runtime/runtime_k.cpp, approx_note_), its a1 legacy-input line
5+
and the front end's K mode line (clean/runtime/interop/backend.cpp) reach the player's log. They name the option as a
6+
faster approximation and the default as the standard path (input stage); they make no claim of exactness (the project's
7+
wording rule). The note itself is checked on a device by
8+
clean/k/tests/test_k_runtime_d3d12.py test_k_approx_each_tag.
9+
10+
Run: python -m unittest clean.k.tests.test_k_option_text
11+
"""
12+
import os
13+
import re
14+
import unittest
15+
16+
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
17+
18+
19+
class TestKOptionText(unittest.TestCase):
20+
def test_k_approx_note_wording(self):
21+
with open(os.path.join(ROOT, "clean", "k", "runtime", "runtime_k.cpp"), encoding="utf-8") as f:
22+
src = f.read()
23+
m = re.search(r"approx_note_ = std::string\(\"model K: close approximation k_approx=\"\)(.*?);\n", src, re.S)
24+
self.assertIsNotNone(m, "approx_note_ assignment not found")
25+
stmt = m.group(1)
26+
fixed = stmt.split("(approx_a1_ ? std::string(")[0] # the part every k_approx note carries
27+
self.assertIn('" (opt-in faster approximation; the default is the standard path)"', fixed)
28+
self.assertNotIn("exact", fixed)
29+
self.assertNotIn("default path is exact", src)
30+
a1 = stmt.split("(approx_a1_ ? std::string(")[1] # the a1 part of the note
31+
self.assertIn("run the standard input stage", a1)
32+
self.assertNotIn("exact", a1)
33+
m = re.search(r'frame_note_ = "(model K: k_approx=a1 [^"]*)";', src)
34+
self.assertIsNotNone(m, "the a1 legacy-input line not found")
35+
self.assertIn("run the standard input stage", m.group(1))
36+
self.assertNotIn("exact", m.group(1))
37+
38+
def test_k_mode_line_wording(self):
39+
"""The front end's K mode line (clean/runtime/interop/backend.cpp) names the default as the standard path and an
40+
opt-in mode as an approximation, with no claim of exactness."""
41+
with open(os.path.join(ROOT, "clean", "runtime", "interop", "backend.cpp"), encoding="utf-8") as f:
42+
src = f.read()
43+
m = re.search(r'network model K mode: network=.*?\(exact \? "([^"]*)" : "([^"]*)"\)', src, re.S)
44+
self.assertIsNotNone(m, "the K mode line not found")
45+
self.assertEqual(m.groups(), (", the standard path", ", an approximation (opt-in)"))
46+
47+
48+
if __name__ == "__main__":
49+
unittest.main()

‎clean/k/tests/test_k_runtime_d3d12.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,8 @@ def test_k_approx_each_tag(self):
408408
self.assertEqual(got["k_approx"], tags)
409409
self.assertEqual(len(got["notes"]), 1, got)
410410
self.assertIn("close approximation k_approx=" + tags, got["notes"][0])
411+
self.assertIn("(opt-in faster approximation; the default is the standard path)", got["notes"][0])
412+
self.assertNotIn("default path is exact", got["notes"][0])
411413
self.need_dev_build()
412414
fb = self.leg("k_approx=a1,a2;k_smx_test=mix_fail")
413415
self.assertTrue(fb["ok"], fb)

‎clean/runtime/interop/backend.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ class Context {
803803
say(WG_LOG_INFO, std::string("network model K mode: network=") + (net.empty() ? "fused" : net) + ";k_fast=" +
804804
(fast.empty() ? "0" : fast) + (approx.empty() ? std::string() : ";k_approx=" + approx) +
805805
";handover=" + (staged_out_ ? "staged" : "fence") +
806-
(exact ? ", the exact path" : ", an approximation (not bit-exact)") +
806+
(exact ? ", the standard path" : ", an approximation (opt-in)") +
807807
(k_default_ ? " (the default mode; network=fused8;k_fast=1;handover=staged selects the "
808808
"fastest mode)"
809809
: " (from the options)"));

0 commit comments

Comments
 (0)