official-stockfish/fishtest

SPSA parameters validation during run submission

Opened this issue · 1 comments

May 15 19:03:33 tests.stockfishchess.org pserve[801]:   File "/home/fishtest/fishtest/server/fishtest/views.py", line 1526, in tests_view
May 15 19:03:33 tests.stockfishchess.org pserve[801]:     r_iter = p["a"] / (A + iter_local) ** alpha / c_iter**2
May 15 19:03:33 tests.stockfishchess.org pserve[801]:              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
May 15 19:03:33 tests.stockfishchess.org pserve[801]: ZeroDivisionError: float division by zero

The SPSA was submitted with c=0

params = value["params"]
value = [summary]
for p in params:
c_iter = p["c"] / (iter_local**gamma)
r_iter = p["a"] / (A + iter_local) ** alpha / c_iter**2
value.append(
[
p["name"],
"{:.2f}".format(p["theta"]),
int(p["start"]),
int(p["min"]),
int(p["max"]),
"{:.3f}".format(c_iter),
"{:.3f}".format(p["c_end"]),
"{:.2e}".format(r_iter),
"{:.2e}".format(p["r_end"]),
]
)

With a validation of the SPSA parameters in the "Create New Test" page we can avoid this issue:

<div class="mb-2">
<label for="spsa_raw_params" class="form-label">SPSA parameters</label>
<textarea
name="spsa_raw_params"
id="spsa_raw_params"
class="form-control"
placeholder="Paste values printed at the startup of the code here"
>${args.get('spsa', {'raw_params': ''})['raw_params']}</textarea>
</div>

function spsaEvents() {
if (document.getElementById('autoselect')["checked"]) {
/* save old stuff */
saved_A = document.getElementById("spsa_A").value;
saved_alpha = document.getElementById("spsa_alpha").value;
saved_gamma = document.getElementById("spsa_gamma").value;
saved_games = document.getElementById("num-games").value;
saved_params = document.getElementById("spsa_raw_params").value;
const ret = spsaWork();
if (!ret) {
document.getElementById('autoselect').checked = false;
}
} else {
document.getElementById("spsa_A").value = saved_A;
document.getElementById("spsa_alpha").value = saved_alpha;
document.getElementById("spsa_gamma").value = saved_gamma;
document.getElementById("num-games").value = saved_games;
document.getElementById("spsa_raw_params").value = saved_params;
}
}

As an additional check I will also enforce c<>0 in the schema. I.e. c in ]0,[. But it will need an upgrade of vtjson since vtsjon does not know about open intervals yet (of course it can be hacked with the current functionality but that would be less elegant).