Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPSA parameters validation during run submission #2014

Open
ppigazzini opened this issue May 15, 2024 · 1 comment
Open

SPSA parameters validation during run submission #2014

ppigazzini opened this issue May 15, 2024 · 1 comment

Comments

@ppigazzini
Copy link
Collaborator

ppigazzini commented May 15, 2024

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;
}
}

@vdbergh
Copy link
Contributor

vdbergh commented May 15, 2024

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants