Issues / #3188

#3188 [Benchmark] BENCH.bat / strata_bench.py crashes with NameError when it starts the server

open · @IVoyt · 4 Kommentare · Auf GitHub

BenchmarksSetup & installNVIDIA / CUDAModels & quantsWindows

Beschreibung

## Area

[Benchmark] (measurements and reports)

## Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

## What happened

`tools/strata_bench.py` crashes with a `NameError` as soon as it has to **start** the server itself — which is the default path and the one `BENCH.bat` uses:

```
PS D:\Strata> .\.venv\Scripts\python.exe tools\strata_bench.py --config D:\Strata\strata-swift-iq3_s.json --out D:\Strata-data\ab\old --runs 3 --long
Traceback (most recent call last):
  File "D:\Strata\tools\strata_bench.py", line 1037, in <module>
    sys.exit(main())
  File "D:\Strata\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
```

The name `port` is never assigned in `main()`; only `a.port` and the local `base` exist. Three lines use the undefined name:

- `tools/strata_bench.py:987` — `print(f"Port {port} is used by something that is not Strata: pass --port N.", ...)`
- `tools/strata_bench.py:990` — `say(f"Starting {cfg_path.name} on port {port} ...")`
- `tools/strata_bench.py:991` — `proc = start_server(cfg_path, port, a.gpu, log_path)`

Line 990 is reached on every run that starts a server, so the tool fails immediately, before the model is loaded and before any measurement.

## Smallest steps or command that reproduce it

```
python tools\strata_bench.py --config <a config with an installed model>
```

(or `BENCH.bat`, which calls the same tool with the same arguments). `--url http://127.0.0.1:<port>` works, because that path never reaches the broken lines.

## Reproduction status

Reproduced locally.

## Strata version

Strata 0.2.0-beta (build 0.1.45.3), git `3fa1b524` (v0.2.0-beta-7), source checkout.

## Graphics card, memory and system

RTX 5090 32 GB - 96 GB RAM - Windows 11 (10.0.26300), i7-12700KF, driver 617.42, CUDA toolkit 13.1 (nvcc 13.1.115), Python 3.13.12.

## Model, size and settings

Swift 1.5 Qwen3.8-Flash-Next IQ3_S, 524288 context, pictures off.

## Expected behavior

The tool starts the server on the config's port (or `--port`), waits for the model, runs the suite and writes the results folder.

## Actual behavior

`NameError: name 'port' is not defined` at `tools/strata_bench.py:990`, immediately.

## Suggested fix

Bind the port once and use it in the three places:

```python
port = a.port or int(cfg.get("port", 8080))
base = server_base(cfg.get("host"), port)
```

and use `port` at lines 987, 990 and 991.

## Additional context

- The same three lines are unchanged since at least v0.1.45, so this is not a regression of the 0.2.0 work; it is a long-standing break of the default benchmark path.
- The tool's own tests never reach it: every `main()` test in `tools/test_strata_bench.py` calls the tool with `--url` (line 216: `argv = ["--url", srv.base, "--out", out_dir, "--runs", "2", "--quiet", *extra]`), so the "start the server" branch is never executed by the suite. A test that starts the server on a free port would have caught this.
- The same branch also writes the engine log excerpt (`engine-log-excerpt.txt`); with `--url` that file is not produced, so the workaround loses the log excerpt as well.
- Unrelated, found while running the suite: `python tools\test_strata_bench.py` fails on a PC whose account name is `user`, because the redaction placeholder is `<user>` and the test asserts the account name is absent from the redacted text (`tools/test_strata_bench.py:186-187`, `len(user) >= 4`). The test needs a name that is not a substring of the placeholder, or the placeholder needs to differ.

Mehr auf der Site

Links zu Install, Modellen, Releases.