Repository navigation
Description
In verl/utils/reward_score/exec_eval.py (eval_exec_match, line 240), the branch for a gold query that fails to execute reads:
elif g_flag == 'exception':
pred_passes == 3
break== compares and discards the result, where an assignment was meant. pred_passes stays 1, so the function returns 'Match' instead of 'Gold Error'. compute_score in synsql.py then adds the full exec and result reward (+5) instead of giving 0 for both. In the reproduction below, any prediction that executes, such as SELECT 2, is a match when the gold SQL errors. This only happens when the gold query fails on the database, for example because of a bad dataset entry or because the table was dropped (see the separate report about the writable connection).
Reproduction
Needs func_timeout==4.3.5 sqlparse==0.5.3. Run with SRC set to a checkout of the repo.
import importlib.util, os, sys, sqlite3, tempfile, types
src = os.environ.get("SRC") or (sys.argv[1] if len(sys.argv) > 1 else "src")
d = os.path.join(src, "verl/utils/reward_score")
pkg = types.ModuleType("rs"); pkg.__path__ = [d]; sys.modules["rs"] = pkg
spec = importlib.util.spec_from_file_location("rs.exec_eval", os.path.join(d, "exec_eval.py"))
m = importlib.util.module_from_spec(spec); sys.modules["rs.exec_eval"] = m; spec.loader.exec_module(m)
tmp = tempfile.mkdtemp(); db = os.path.join(tmp, "t.sqlite")
c = sqlite3.connect(db); c.execute("create table log(x int)"); c.execute("insert into log values(1)"); c.commit(); c.close()
import io, contextlib
def run(g, p):
with contextlib.redirect_stdout(io.StringIO()):
return m.eval_exec_match(db, p, g, plug_value=False, keep_distinct=False, progress_bar_for_each_datapoint=False)
ok = run("SELECT x FROM log", "SELECT 2")
bad = run("SELECT y FROM log", "SELECT 2")
print("gold valid, wrong pred:", ok)
print("gold fails, wrong pred: observed", bad, "expected Gold Error")
if bad != "Gold Error":
print("REPRODUCED"); sys.exit(1)Expected: Gold Error for the second call.
Actual on main:
gold valid, wrong pred: Mismatch
gold fails, wrong pred: observed Match expected Gold Error
REPRODUCED
(exit code 1.) Through compute_score, a completion with SELECT 2 against a gold query that references a missing column scored 6.43 (status Match) instead of 1 (format reward only); with a valid gold query the same completion is a Mismatch and scores 0. That check was run by a second script, not shown here.
Reproduces on main at ccfb511e81fdb3a8e87bd3da7f3d71882cedd532.
Activity