[PR #3320] [CLOSED] [Benchmark] bind the port so strata_bench.py can start its own server #4566

Closed
opened 2026-11-07 15:37:28 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3320
Author: @victorgabr
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/bench-port-nameerror


📝 Commits (1)

  • 8c1d078 [Benchmark] bind the port so strata_bench.py can start its own server (#3188)

📊 Changes

2 files changed (+23 additions, -1 deletions)

View changed files

📝 tools/strata_bench.py (+2 -1)
📝 tools/test_strata_bench.py (+21 -0)

📄 Description

Closes #3188. Also covers the crash reported in #2864, #2872, #2908 and #3130.

Problem and resulting behavior

tools/strata_bench.py dies with NameError: name 'port' is not defined on every run that has to start the server itself - the default path, and the one BENCH.bat and the setup "Run a quick benchmark now?" prompt use:

File "tools/strata_bench.py", line 990, in main
    say(f"Starting {cfg_path.name} on port {port} (loading takes 1-3 minutes; the PC may be slow meanwhile) ...")
NameError: name 'port' is not defined

After this change the tool starts the server on the config's port (or --port), waits for the model, runs the suite and writes the results folder; the "port is used by something that is not Strata" message also prints the real port instead of crashing.

Why this approach

Commit 69fe4055 (#2330) replaced port = a.port or int(cfg.get("port", 8080)) + base = f"http://127.0.0.1:{port}" with base = server_base(cfg.get("host"), a.port or int(cfg.get("port", 8080))) and left the three remaining uses of port (lines 987, 990, 991) unbound. The fix restores the assignment the line used to carry and uses it in all three places - the same shape suggested in #3188. The --url path is untouched.

The suite never caught it because every main() test passes --url, so the start-server branch is never executed; that gap is called out in #3188. One new test (test_the_start_server_branch_knows_its_port) reaches the branch with a stubbed start_server: it asserts the config's port reaches the starter and the not-ready path returns 1, and that a non-Strata port occupant returns 2 with the port named in the message.

Validation

On upstream/main e88ee39d, Linux, Python 3.14.7, branch exactly as submitted:

Passed

  • python tools/test_strata_bench.py with the fix: Ran 18 tests ... OK (17 existing + the new one).
  • The new test fails without the fix (fix reverted, test kept): FAILED (errors=1), with the real traceback NameError: name 'port' is not defined, line 990, in main.
  • End-to-end with the fix, no CI, on hardware: python tools/strata_bench.py --config strata-iq3_s.json on Linux (TITAN RTX, engine 0.1.45.3) started its own server, ran the suite and wrote a full results folder - the path the change unblocks. Two paired runs this way produced the A/B evidence posted alongside this bug report's thread dates.

Failed

  • none.

Not run

  • Windows path (BENCH.bat) - the changed code is platform-independent Python and reproduces identically on Windows per #3188 and #3130, but I ran it only on Linux.
  • No CUDA/HIP/SYCL builds needed: no compiled file is touched.

Limits

The new test stubs start_server, so it proves the branch binds and passes the port, not that a real engine boots. The port-free check still relies on /health probing (unchanged behavior).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3320 **Author:** [@victorgabr](https://github.com/victorgabr) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/bench-port-nameerror` --- ### 📝 Commits (1) - [`8c1d078`](https://github.com/Niko1221/Strata/commit/8c1d078af25981c300e66e329a3333e8e918811e) [Benchmark] bind the port so strata_bench.py can start its own server (#3188) ### 📊 Changes **2 files changed** (+23 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tools/strata_bench.py` (+2 -1) 📝 `tools/test_strata_bench.py` (+21 -0) </details> ### 📄 Description Closes #3188. Also covers the crash reported in #2864, #2872, #2908 and #3130. ## Problem and resulting behavior `tools/strata_bench.py` dies with `NameError: name 'port' is not defined` on every run that has to **start the server itself** - the default path, and the one `BENCH.bat` and the setup "Run a quick benchmark now?" prompt use: ``` File "tools/strata_bench.py", line 990, in main say(f"Starting {cfg_path.name} on port {port} (loading takes 1-3 minutes; the PC may be slow meanwhile) ...") NameError: name 'port' is not defined ``` After this change the tool starts the server on the config's port (or `--port`), waits for the model, runs the suite and writes the results folder; the "port is used by something that is not Strata" message also prints the real port instead of crashing. ## Why this approach Commit 69fe4055 (#2330) replaced `port = a.port or int(cfg.get("port", 8080))` + `base = f"http://127.0.0.1:{port}"` with `base = server_base(cfg.get("host"), a.port or int(cfg.get("port", 8080)))` and left the three remaining uses of `port` (lines 987, 990, 991) unbound. The fix restores the assignment the line used to carry and uses it in all three places - the same shape suggested in #3188. The `--url` path is untouched. The suite never caught it because every `main()` test passes `--url`, so the start-server branch is never executed; that gap is called out in #3188. One new test (`test_the_start_server_branch_knows_its_port`) reaches the branch with a stubbed `start_server`: it asserts the config's port reaches the starter and the not-ready path returns 1, and that a non-Strata port occupant returns 2 with the port named in the message. ## Validation On `upstream/main` `e88ee39d`, Linux, Python 3.14.7, branch exactly as submitted: **Passed** - `python tools/test_strata_bench.py` with the fix: `Ran 18 tests ... OK` (17 existing + the new one). - The new test fails **without** the fix (fix reverted, test kept): `FAILED (errors=1)`, with the real traceback `NameError: name 'port' is not defined`, `line 990, in main`. - End-to-end with the fix, no CI, on hardware: `python tools/strata_bench.py --config strata-iq3_s.json` on Linux (TITAN RTX, engine 0.1.45.3) started its own server, ran the suite and wrote a full results folder - the path the change unblocks. Two paired runs this way produced the A/B evidence posted alongside this bug report's thread dates. **Failed** - none. **Not run** - Windows path (`BENCH.bat`) - the changed code is platform-independent Python and reproduces identically on Windows per #3188 and #3130, but I ran it only on Linux. - No CUDA/HIP/SYCL builds needed: no compiled file is touched. ## Limits The new test stubs `start_server`, so it proves the branch binds and passes the port, not that a real engine boots. The port-free check still relies on `/health` probing (unchanged behavior). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:28 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4566
No description provided.