Skip to content

feat(beaver): add the BEAVER text-to-SQL benchmark, scored with BEAVER's official execution accuracy - #6708

Open
abelatnvidia wants to merge 37 commits into
NVIDIA-NeMo:mainfrom
abelatnvidia:abel/beaver
Open

abelatnvidia wants to merge 37 commits into
NVIDIA-NeMo:mainfrom
abelatnvidia:abel/beaver

Conversation

@abelatnvidia

@abelatnvidia abelatnvidia commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Review resources_servers/beaver_sql/ex_acc.py (how a query runs and how two results compare), verify() in app.py, setup_beaver_mysql.py (download, load, read-only user, startup check) and benchmarks/beaver/prompts/schema_only.yaml. Skip the tests, benchmarks/beaver/gold_check.py and official_check.py. The layout follows birdbench and bird_sql. Push history is in the comments.

Adds BEAVER (paper), an enterprise text-to-SQL benchmark on real, anonymized data warehouses, as benchmarks/beaver with a new resources server, resources_servers/beaver_sql. The model gets the question, its domain knowledge and the database's CREATE TABLE statements, and answers with one MySQL query. The verifier runs it on MySQL and scores it with BEAVER's own execution-accuracy rule, checked against BEAVER's official evaluator on the same predictions.

  • Scoring (ex_acc.py), as BEAVER's eval/utils/ex_acc.py: each query gets its own connection and 10 seconds. A failed or timed-out query, or a missing ```sql block, is an empty result. Two results match when both are empty, or when their rows, built into a pandas DataFrame, converted with astype(str) and stripped, are equal sets. The DataFrame step and pandas 2 are kept on purpose: both change the text, and so verdicts.
  • Two headline numbers, as BEAVER reports: accuracy over every task, and over tasks whose gold returns rows (stricter, since any empty answer matches an empty gold).
  • MySQL 8.0 with --lower-case-table-names=1. BEAVER's dumps come from a case-insensitive server; on Linux's default, 950 of neutron's 1,017 gold queries fail. The loader and startup check refuse a case-sensitive server.
  • Setup and safety: questions and dumps from Hugging Face (MIT, gated), pinned by revision and SHA-256; nothing committed. Startup reads every table as the verifier and refuses a verifier user with anything beyond SELECT on the BEAVER tables, or any grant authority, so a setup gap fails there instead of scoring every query empty.
  • Failures: a lost connection, a refused login or a gold query that errors masks the row as verifier_error; any other error is the model's. Timed-out queries are killed; a trailing statement still running, and a result over 1,000,000 rows, are stopped.
  • Where this departs from the official evaluator, on purpose: a gold query that errors, or a lost connection, masks the row instead of scoring it; a result over 1,000,000 rows or about 1 GiB never matches, not even an empty gold (no gold result has over 622,224 rows, but officially, comparing sets, an answer of many repeats of a gold's rows could match if read within 10 s; this departure existed at 5,000,000 rows before); statements after the first are stopped once seen; the verifier's user can only read (officially it's the .env user, root in BEAVER's example).
  • Known limit: all verifier connections share one MySQL user, so an answer can KILL QUERY another rollout's query (the server README's "Known limits").
  • Driver: PyMySQL (MIT). The official evaluator uses mysql-connector-python (GPL-2.0 with the Universal FOSS Exception), which this server doesn't depend on; parity below.
  • Task: 300 dw questions by default, drawn with BEAVER's own sampler; stable task_ids; the prompt is auto-ontology-eval's schema-only prompt. Evidence (BEAVER's domain knowledge) is on by default; include_evidence=false gives the leaderboard's hint-free Setting 0. It runs on single_agent_turn_legacy, not the legacy_agent relay.

Checks

Check Result
Official evaluator vs the verifier (PyMySQL), every gold query as its own prediction (6,925) same verdict on 6,923; the other 2 are golds that returned a different result on a second run (different ones each run; before the switch, 3)
Official evaluator vs the verifier, 1,200 saved model answers (three 400-task runs) same verdict on all 1,200
The same 1,200 answers replayed through gym eval run, before and after the switch same reward on every task (13, 3 and 12 passes)
Gold check, all of dw, dw_real, neutron (with the official driver, before the switch) no gold errors; 6 time out at 8 queries at a time, none one at a time; none in the default sample
Prompt parity with auto-ontology-eval 400/400 byte-identical
beaver_sql tests (fake driver, as in CI) 171 passed, 17 skipped
With a live MySQL 8.0.46 and the official ex_acc.py 188 passed, every live and official-file case included: load, startup check, read-only user and grants, timeouts, a trailing statement stopped, and the comparison cases against the official file
A 10^8-row cross join, live stops at the 1,000,000-row limit in 2.1 s; no query left on the server and no thread left running
gym env validate, gym eval plan, task-data schema and import checks, uv lock --check, pre-commit passed

Live runs

Paired per task with saved auto-ontology-eval runs of the same two public NVIDIA models, same 400 prompts: 3 vs 3 passes (large model) and 12 vs 13 (small model). Neither difference is significant: McNemar p = 0.63 for the large model on its 398 non-empty-gold tasks (1 vs 3), and p = 1.0 for the small model on all 400.

Open questions (each with a default)

  1. Case-insensitive server required (default: yes). It's how BEAVER's data was built, and without it most neutron gold queries fail.
  2. No closed ```sql block means an empty prediction (default: as the official evaluator's missing prediction). bird_sql instead scores a missing block 0.

Credits

BEAVER: Chen et al. (data MIT). The schema-only setup, its prompt and the BEAVER seeding are adapted from the Auto Ontology team's auto-ontology-eval at commit e727e4d6e1e198355099de4803590bb3681793a4 (Apache 2.0): ontology_sql_eval/gym/tasks.py for the prompt, ontology_sql_eval/gym/ddl.py for the schema, and scripts/seed/seed_beaverbench.py for the questions and the loader.

abelatnvidia and others added 11 commits November 24, 2026 06:19
…ex_acc

Runs the gold and model queries on BEAVER's MySQL databases and scores
them as BEAVER's official evaluator does: 10 seconds per query, a
failed, timed-out or missing query is an empty result, and two results
match when both are empty or their rows, built into a pandas DataFrame
and converted to stripped text, are equal sets. pandas is pinned below 3,
as the official evaluator runs it. A grader that cannot reach the data is
masked as a verifier error; startup checks every configured database is
loaded from the pinned dump and visible to the read-only user.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…-check

benchmarks/beaver prepares BEAVER questions from Hugging Face at a pinned
revision (default: 300 dw questions, sampling seed 77, as BEAVER's own
download script) with auto-ontology-eval's schema-only prompt: the
question, its domain knowledge as evidence, and the database's CREATE
TABLE statements. gold_check.py runs every gold query the way the grader
does; official_check.py scores the same predictions with BEAVER's
official ex_acc.py (downloaded at a pinned commit, never committed) and
with the grader, and counts disagreements.

beaver_sql now refuses a MySQL server with case-sensitive table names:
the dumps come from macOS, and with Linux's default 950 of neutron's
1,017 gold queries fail. Only a failed connection or a lost one masks a
row; an error inside the query, access denied included, is the query's.
The grader's account is created for host %, not a literal %%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…iming and the driver

A timed-out query keeps its slot while KILL QUERY is repeated, for up to
10 seconds; then the slot is released and the thread abandoned, so a
query MySQL can't interrupt no longer holds a slot forever. The READMEs
give the measurement contract, the MySQL setup, the gold check, which
gold queries sit near the 10-second limit, and how the driver treats a
string with several statements.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…s out

KILL QUERY stops the server, not the client reading rows the server has
already sent, so a query with a very large result kept its slot past the
limit and its rows filled memory. Rows are now read 10,000 at a time and
reading stops as soon as the query is out of time; the verdict, a
timeout, is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…es, cancelled and oversized queries

- The grader runs no session settings, so the model's SQL sees the
  server's own values, as under the official evaluator.
- A result over 5,000,000 rows or 1 GiB isn't compared (the largest gold
  has 622,224 rows): it scores as the query's failure. The comparison runs
  off the event loop.
- A request cancelled while its query runs stops the query before giving
  up its slot; each KILL QUERY connection is bounded to 2 seconds.
- The server running out of memory, threads, disk or temporary space, or
  the grader running out of memory, masks the row instead of scoring it.
  So does a gold query that errors: every gold runs on a correctly set-up
  server, so that means the setup is wrong. A gold timeout stays scored.
- Fields the verifier computes are ignored in an incoming request, so a
  saved row can be graded again.
- Startup reads every table as the grader and refuses a grader that can
  do more than read the BEAVER databases (another privilege, a role, or
  SELECT on other databases). The loader no longer resets an existing
  user's password, refuses a grader DSN that is the loader's own user,
  takes a lock so one loader runs at a time, and only creates a database
  it doesn't own, so one created meanwhile by someone else isn't
  dropped.
- SQL extraction bounds each ```sql block before looking for a letter,
  so a block without one can't swallow the next.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…read-only checks

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ements; recover loads

From an independent review:
- A query is timed on its own thread, which wakes the event loop when it
  ends, so a busy loop or a queued thread pool can no longer turn a fast
  query (or a gold query) into a timeout. Stopping queries uses the
  runner's own threads.
- A string with several statements still returns the first result, but
  when the driver reports more results pending the grader kills that
  connection, so the rest don't run on unwatched.
- An oversized result is non-empty and matches nothing, as it would
  officially, instead of an empty result that matches an empty gold.
- Server resource errors (sort memory, temporary table space, ...) on the
  model's query score as its error again: a runaway query causes them. A
  gold query that errors is still masked.
- The loader marks a database as loading before touching it, so an
  interrupted or short load is loaded again on the next start, and the
  startup check compares against the pinned table count. Startup also
  refuses a grader with an active or mandatory role.
- KILL failures are logged and counted. Category names use underscores
  in metric keys. The README lists where scoring departs from the
  official evaluator, and the known limits.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
An answer that opens the fence twice (```sql then ```sql then the query)
lost its SQL: the second opening was taken as the first block's closing
fence and skipped. Such a fence now stays an opening fence, so the SQL
after the last ```sql is used, as BEAVER's own extraction does. On 800
saved answers, extraction now agrees with BEAVER's few-shot rule on every
answer with a closed ```sql block.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…t until its connection closes

Passwords:
- mysql_password and mysql_admin_password (SecretStr) carry the passwords, set from
  BEAVER_MYSQL_PASSWORD and BEAVER_MYSQL_ADMIN_PASSWORD by the shipped config. They are
  credential-named, so Gym redacts them in what a run saves.
- A DSN that holds a password is refused at startup, without echoing it, so a run's
  identity file never records one. The READMEs and gold_check/official_check take the
  password from the environment too.
- Test: a run manifest written from the shipped config (password from the environment
  and literal) leaves the password in no file.

Runner (Codex re-review):
- The outcome is decided when the query ends; the slot is released only after its
  connection is closed (and trailing statements killed).
- A cancellation while a query is being stopped, on the cancel path or after a
  timeout, waits for the stop before the slot is released.
- A query that ends after the limit is a timeout whatever it returned, so a late gold
  error scores as an empty gold result instead of masking the row. A query that never
  connected still masks it.

Loader (Codex re-review):
- A new database is recorded as loading only after its CREATE succeeds, so a CREATE
  that fails on someone else's database leaves no record a later start would drop.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…malformed DSNs without quoting them

Runner (Codex re-review 3):
- The slot's wait for a query's thread to finish is bounded on the event loop
  (stop_grace_s), on a signal the thread sends once its connection is closed. A stop
  that stalls (a KILL that can't connect) or can't start no longer holds the slot.
- Stopping is fire-and-forget on the runner's own threads.

DSNs (Codex re-review 3):
- The password check runs on the raw string before urlparse, and no parsing error is
  passed on: urlparse's own errors can quote the user info.
- A DSN with a query or fragment (`?password=...`) is refused.
- Refusals raise MySqlDsnError, not ValueError, so pydantic doesn't wrap them at
  startup in an error that prints the config holding the DSN.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…ng it; correct stale docs

From an independent review of the changes since the first one:
- A result stopped at the size limit (or the time limit) left its rows unread, and
  close() then read every one of them (the C driver frees the result that way) while
  the query ran on: the connection, its thread and the server query leaked. The
  connection is now killed before it is closed whenever rows are left unread. Live on
  a 10^8-row cross join: 3.6 s, nothing left running. Fake-driver test for both limits.
- _stop keeps sending KILL QUERY while a given-up query's thread is cleaning up.
- An abandoned thread is logged on every path, not only after a timeout.
- The gold-sql-error metric could never count (a gold error masks its row before it is
  recorded): removed. The module docstring and the gold_status comment said a failed gold
  is scored; it masks the row.
- README: server resource errors (1021, 1030, 1037, 1038, 1041, 1114, 1135) are scored
  as the query's error, not masked; an oversized result never matches, not even an empty
  gold result.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Nov 24, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added risk:high Autobot PR risk: high feature New capabilities, enhancements, or enablement work area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers benchmark-onboarding Self-contained benchmark onboarding needs-review PR is ready for code review and waiting on a reviewer labels Nov 24, 2026
@athitten

Copy link
Copy Markdown
Contributor

/ok to test b0ba016

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 24, 2026 19:29
@athitten

Copy link
Copy Markdown
Contributor

@abelatnvidia please take a look at the secrets detector failure and fix

…e secrets detector

The secrets detector flags the pinned commit SHAs, the neutron dump's SHA-256 and the placeholder passwords in the
DSN tests. None is a secret. Mark each flagged line with `# pragma: allowlist secret`, as main does. The neutron
entry is wrapped one argument per line, the way ruff-format lays it out with the comment, so the pragma stays on the
hash's line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@yaoyu-33
yaoyu-33 requested a review from Glorf November 24, 2026 20:10

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP WITH CARE

I found four RISKs and two NOTEs. The required Unit tests / Test check is red because this PR omits the task-data schema and imports an exported class through its implementation module. Those failures need correction before merge.

I reviewed all 26 changed files with separate execution/scoring, MySQL setup and benchmark/data reviews. The PR supplies concrete reward-profiling and live-rollout results; I did not independently reproduce those external runs.

Validation

  • CI on b0ba016c71723ac72afd3cbb77d801f3c08efd4e: Unit tests / Server suite, lint and component-lock checks succeeded. Unit tests / Test failed; combined core coverage was skipped, not passed.
  • I reproduced the three failing tests locally: TestSchemaPresence::test_every_resources_server_ships_a_schema, TestRepoDataMatchesSchemas::test_all_committed_rows_validate, and test_code_outside_the_library_imports_exported_names_from_the_public_api. All three failed on head and passed on the admitted base using the same environment.
  • The memory-queue probe retained 40 completed gold frames with query concurrency set to one. The loader probe confirmed that a missing database is not recreated when its metadata hash is current.
  • Focused probes passed for prompt preparation, evidence/no-evidence output separation, fixture rewards, stale-grading removal, outage masking, cancellation cleanup, dump checksum recovery and credential redaction. Lock metadata parsed and resolved consistently.
  • These commands ran in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:91666f99091979a03d78b76558851f5bf1bbf43a, the base's successful CI image, because head had no container-build check. An outside-tree virtual environment supplied the PR's MySQL Connector 26.10.0 and pandas 2.3.3. Probes and logs are under /workspace/review-probes/.
  • secrets-detector / secrets-detector also failed. Its log identifies pinned revision/hash literals as high-entropy strings; that is not evidence of leaked credentials.

I did not run live MySQL, gated dataset downloads, model calls or the external official evaluator. Their behavior remains covered by the author's reported evidence, not my probes. I made no repository or provider changes.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

return value.get_secret_value() if value is not None else None


class BeaverSqlVerifyRequest(BaseVerifyRequest):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: Add the resources server's task-data schema. beaver_sql has no task_data.py, so the shared loader returns no schema and collation cannot validate this server's task fields. Both core schema checks fail for this omission on head; I reproduced them locally, while both pass on base. This also lets malformed prepared fields reach the verifier before they are rejected.

Could you add a dependency-light TaskData declaration matching this request model, including the prompt/provenance fields emitted by prepare.py, and enforce agreement between schema and runtime types, requiredness and unknown-field policy? Preserve the flat row shape and extra="allow" behavior; do not introduce a competing contract.

Acceptance: the existing TestSchemaPresence::test_every_resources_server_ships_a_schema and TestRepoDataMatchesSchemas::test_all_committed_rows_validate pass; generated evidence/no-evidence rows validate; malformed required fields fail during collation; and a schema/runtime mismatch fails a drift test. Importing the schema must not require MySQL or pandas.

Comment thread resources_servers/beaver_sql/app.py Outdated
# fails here means the data or server isn't what was checked. (Officially it would be an empty result,
# which an empty or failed answer matches.) A gold query that times out is still scored as empty.
raise MySqlUnavailableError(f"gold query failed: {gold.error}")
pred = missing_prediction() if extracted_sql is None else await self._runner.run(body.db_id, extracted_sql)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: Bound complete verifications, not only individual queries. The runner releases its query permit after returning the gold frame. With concurrent requests, predictions queue behind other requests' gold queries while every completed gold frame stays resident. Comparisons retain both frames outside that permit too, so result memory grows with submitted requests rather than max_concurrency.

I ran PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/workspace/review/source /workspace/review-probes/venv/bin/python /workspace/review-probes/execution-scoring-1/memory_queue_probe.py. It drives the real verifier and runner with a fake connector and reported max_concurrency=1, live_gold_results_peak=40, first_prediction_index=40. All 40 requests graded, but large results can exhaust grader memory despite the configured limit.

Could you hold a separate verification-level semaphore across gold execution, prediction and comparison? Keep the existing query permit and connection-cleanup behavior; acquiring that same permit recursively would deadlock. Add a concurrent tracked-frame regression proving retained result pairs stay bounded, cancellation releases the verification permit after cleanup, and BEAVER's timeout/comparison semantics remain unchanged.


@pytest.mark.parametrize("source", ["environment", "literal"])
def test_no_file_a_run_writes_holds_a_password(self, tmp_path: Path, monkeypatch, source: str) -> None:
from nemo_gym.rollouts.rollout_recovery import RunManifest, config_identity_path_for

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: Import RunManifest through the public package to restore the required core check. This import causes test_code_outside_the_library_imports_exported_names_from_the_public_api to fail in core shard 2, which feeds the required Unit tests / Test aggregate. I reproduced the failure on head and a pass on base, so this is not merely a convention concern.

Could you import RunManifest from nemo_gym.rollouts and leave config_identity_path_for on its current path unless it is also exported? Preserve the credential-redaction test's behavior. Acceptance: the public-API test passes and both environment/literal password cases still verify that saved files contain no credential.

raise RuntimeError(
f"MySQL already has databases {foreign} that this loader didn't create; drop them or use another server"
)
stale = [db_id for db_id in db_ids if recorded.get(db_id) != _dump(db_id).sha256]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISK: Reload an owned database when the schema is missing. The reload decision only checks the recorded hash. If dw is dropped or restored separately while _beaver_meta.loaded keeps its current record, ensure_beaver_mysql() returns without recreating it, even with admin credentials. Startup then fails because the grader sees zero tables.

The unchanged public setup/check functions, driven by the stateful fake-server probe mysql-setup-1/loader_probe.py, produced missing_db_setup_returned_success True dw_exists False, followed by dw: the grader's user sees 0 of 97 tables.

Could you include db_id not in existing in the stale condition and use the existing recorded-ownership reload path? Acceptance: current metadata plus an absent schema reloads the pinned dump and passes startup. Preserve rejection of foreign databases and the existing CREATE-race protection.

modality: text
licensing: MIT
authors:
- abelatnvidia

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, suggestion: Complete the new manifest's selection metadata. The manifest leaves maintainers, capabilities, domains, primary_metric and requirements unset. The review rubric requires these authored fields for new manifests. Here they matter because BEAVER exposes two different headline accuracies and requires MySQL plus gated inputs.

Could you supply the maintainer login, applicable taxonomy values, the exact default-run headline metric key, and GPU/network requirements? Use supported unknown values where genuinely unknown. Acceptance: the manifest loads, taxonomy values validate, and primary_metric names a metric emitted by the default one-repeat run. This is metadata completeness, not a demonstrated scoring failure.

[BEAVER](https://beaverbench.github.io/) ([paper](https://arxiv.org/abs/2409.02038)) is an enterprise text-to-SQL
benchmark: questions over real, anonymized data warehouses with hundreds of tables, gold queries in MySQL. This
benchmark asks for one MySQL query per question from the schema alone and scores it with BEAVER's official execution
accuracy, through the [`beaver_sql`](../../resources_servers/beaver_sql/README.md) resources server.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, suggestion: Expose the setup and measurement contract in the user docs. The new benchmark's instructions live only in repository READMEs; this PR adds no BEAVER entry under fern/versions/latest/pages/. The rubric requires user documentation for a notable benchmark, and users need to discover the case-insensitive MySQL requirement, gated-data setup and distinction between all-task and nonempty-gold accuracy before running it.

Could you add a short navigable Fern entry with the minimal prepare/run example and those limits, linking to the detailed server README rather than duplicating it? Acceptance: the documentation entry resolves, its links work, and its example uses the shipped configuration without putting passwords in a DSN.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 25, 2026
@ffrujeri

ffrujeri commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Hi. Please point your agent to these instructions. Move this benchmark off the legacy_agent relay. We do not accept new legacy_agent configs, for security reasons.

Background: https://gitlab-master.nvidia.com/yuya/how-to-run/-/blob/main/runbooks/gym-resources-server-env-server-migration.md

In this PR:

  1. In benchmarks/beaver/config.yaml and resources_servers/beaver_sql/configs/beaver_sql.yaml, replace the legacy_agent environment server with single_agent_turn_legacy. Point it at beaver_sql_resources_server and the matching agent.
  2. Use https://github.com/NVIDIA-NeMo/Gym/blob/main/benchmarks/gpqa/config.yaml and https://github.com/NVIDIA-NeMo/Gym/blob/main/resources_servers/mcqa/configs/mcqa.yaml as examples.
  3. Do not add session hooks. Do not change app.py or the scoring.
  4. Run gym env validate on the config.
  5. Run a small real-model smoke test on the shipped config.yaml: gym env start, then gym eval run --limit 5. Add the result to the PR description.

abelatnvidia and others added 2 commits November 25, 2026 16:03
…gacy_agent relay

Gym no longer accepts new legacy_agent configs. beaver_sql is a stateless verifier (no seed_session
override, no tools, metric hooks already on the resources server), so the move is the config switch
only, as in benchmarks/gpqa/config.yaml and resources_servers/mcqa/configs/mcqa.yaml: both
beaver_sql_environment_server and the benchmark's beaver_environment_server now use
single_agent_turn_legacy, pointed at beaver_sql_resources_server and the matching agent. No tool
transports, since the server serves no tools. app.py and the scoring are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…t a missing eval.sh

config.yaml said to "use eval.sh, which does both", but the benchmark has no eval.sh. The comment now points at
the README's "Preparing data and evaluating" example, which sets both overrides.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@ffrujeri

Copy link
Copy Markdown
Contributor

/ok to test d63c933

@nemo-pr-automation
nemo-pr-automation Bot requested review from a team November 30, 2026 14:49
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

tests/unit_tests/benchmarks/test_beaver_prepare.py imported
benchmarks/beaver/prepare.py, which imports setup_beaver_mysql. The core
coverage gate counts every repository file the core suite imports, and
setup_beaver_mysql's MySQL paths are exercised only by beaver_sql's own
tests, so core coverage fell to 94.99% against the 95.00% gate. The same
tests now run with beaver_sql's tests as tests/test_prepare.py.

Outside tests/, Gym's public-API check applies: the moved file imports
TaskDataValidator and load_task_data_schema from nemo_gym.data, and finds
the server directory from its own path, as test_task_data.py does,
instead of importing find_server_dir from nemo_gym.data.task_data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-maintainers Waiting on maintainers to respond label Nov 30, 2026
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Pushed 1b85ff3f90, which fixes the one CI failure, the core coverage gate (94.99% against 95.00%). The core test tests/unit_tests/benchmarks/test_beaver_prepare.py imported benchmarks/beaver/prepare.py, which imports setup_beaver_mysql.py. That module's MySQL code is exercised only by beaver_sql's own tests, so the core gate counted it as missed. The same six tests now live at resources_servers/beaver_sql/tests/test_prepare.py and run with the server's suite. They import TaskDataValidator and load_task_data_schema from nemo_gym.data, as the public-API check requires outside tests/.

@abelatnvidia
abelatnvidia requested a review from Glorf November 30, 2026 20:27
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

@ffrujeri thanks for running CI. Could you run /ok to test 1b85ff3f90d536d439b6a0277dbb7d0e6283bbf2?

@github-actions github-actions Bot removed the sla:author-overdue Author response is over the one-business-day SLA label Nov 30, 2026
@ffrujeri

Copy link
Copy Markdown
Contributor

/ok to test 1b85ff3

@ffrujeri ffrujeri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fixes. The four points of the change request are fixed at 1b85ff3f: the verifier's MySQL user gets SELECT on _beaver_meta.loaded only, grant authority is refused with a regression case, each row keeps its source id and gets a stable, unique task_id, and the lock passes uv lock --check, also after a merge with current main. The single_agent_turn_legacy move and the bot's six findings are fixed too. @Glorf, could you re-review, or dismiss the change request if you agree? The threads can then be resolved.

Two small notes are inline. Not blocking: new annotations use Optional, Dict and List; ruff check --select UP006,UP035,UP045 --fix resources_servers/beaver_sql benchmarks/beaver fixes most of them. Open question 1, the MySQL driver license, needs a maintainer answer, which will come separately.

Comment thread resources_servers/beaver_sql/app.py Outdated
records ``gold_result`` (``empty_gold`` or ``nonempty_gold``), and the metrics report accuracy over all tasks and over
``nonempty_gold`` tasks: an empty gold result is matched by any query that returns nothing, so BEAVER publishes both.

When the grader can't reach the data (no MySQL, wrong password, a database not loaded), or a gold query errors within

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text uses two names for one thing: "the grader" here, and BeaverSqlVerifier and verifier_error in the code. Could the comments, docstrings, READMEs and the Fern page say "verifier" (for example "the verifier's MySQL user"), and could grader_privilege_problems become verifier_privilege_problems?

Comment thread benchmarks/beaver/prepare.py Outdated
leaderboard (Setting 0) gives no hints: prepare with ``include_evidence=False`` for numbers comparable with it.

Prompt construction and evidence adapted from auto-ontology-eval (https://github.com/NVIDIA/auto-ontology-eval,
``ontology_sql_eval/gym/tasks.py``, ``ddl.py`` and ``scripts/seed/seed_beaverbench.py`` at e727e4d6e, Apache-2.0).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this header give the full commit, e727e4d6e1e198355099de4803590bb3681793a4, and could the PR description name the same commit and source files? The same short SHA is in setup_beaver_mysql.py and prompts/schema_only.yaml.

abelatnvidia and others added 3 commits December 1, 2026 14:09
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
…modern annotations

Review points from ffrujeri on NVIDIA-NeMo#6708:

- The text called beaver_sql's verifier "the grader" while the code says
  BeaverSqlVerifier and verifier_error. Comments, docstrings, error messages,
  both READMEs and the Fern page now say "verifier", and
  grader_privilege_problems is verifier_privilege_problems (four test names
  follow). The one remaining "grader" in official_check.py is another
  grader's verdict (auto-ontology-eval's), not this verifier.
- benchmarks/beaver/prepare.py, prompts/schema_only.yaml and
  setup_beaver_mysql.py now give auto-ontology-eval's full commit,
  e727e4d6e1e198355099de4803590bb3681793a4, and prepare.py names each source
  file by its full path.
- New annotations use built-in generics and X | None
  (ruff --select UP006,UP035,UP045 --fix, then F401 for the emptied typing
  imports).

No behavior change apart from the wording of the verifier's startup errors.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
"verifier" is two characters longer than "grader". Rewraps the comments,
docstrings and README lines that the rename took past 119 characters, and
splits one error string literal (same text). Two of the lines in
setup_beaver_mysql.py were already over the limit; both are now under. The previous commit also changed the --help text
of gold_check.py and official_check.py from "grader" to "verifier".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Thanks. All three are done in two commits on top of a merge with current main (no rebase):

  • "verifier" throughout. Comments, docstrings, error messages, --help text, both READMEs, the Fern page and this description now say "verifier". grader_privilege_problems is verifier_privilege_problems. The one "grader" left, in official_check.py, is auto-ontology-eval's.
  • Full commit. prepare.py, setup_beaver_mysql.py and prompts/schema_only.yaml give e727e4d6e1e198355099de4803590bb3681793a4. The description's credit line names it with the three source files.
  • Annotations. Built-in generics and X | None, from your ruff command plus F401 for the emptied typing imports.

beaver_sql tests: 170 passed, 17 skipped (the live-MySQL ones). The rendered prompt is unchanged.

@ffrujeri could you /ok to test 42213825f9591bf24d4d239ad91a525ffc725b5d? @Glorf, this is the head to re-review.

@anwithk

anwithk commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

On the MySQL driver: I'd switch to PyMySQL (MIT). mysql-connector-python is GPL-2.0, not LGPL like psycopg, so the bird_sql precedent doesn't really apply. Keeping it would need OSRB sign-off, which takes about two weeks. official_check.py and the 1,200-answer replays already measure parity. If they still match after the swap, switch. If not, keep mysql-connector-python and file with OSRB now so the wait doesn't hold up the merge.

@ffrujeri

ffrujeri commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/review 4221382

@svcnvidia-nemo-ci

This comment has been minimized.

@nemo-pr-automation
nemo-pr-automation Bot requested a review from a team December 1, 2026 19:49

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP

The six prior findings are resolved. I found no new high- or critical-impact defect introduced since b0ba016c71723ac72afd3cbb77d801f3c08efd4e, as required by this follow-up’s above-moderate filter. This is a scoped follow-up, not a full RESET review.

Prior findings

  • Task-data schema: the dependency-light schema matches the verifier’s field types, requiredness and extra-field policy. Prepared rows validate, malformed fields fail collation in error mode, and mutation probes confirm that the drift checks detect mismatches.
  • Verification memory bound: the semaphore now covers gold execution, prediction and comparison. With concurrency one and 40 requests, the differential probe reduced peak retained gold frames from 40 on the previous revision to one on this head. Repeated cancellation kept the permit until query cleanup or comparison completion.
  • Public import: RunManifest now comes from nemo_gym.rollouts. Credential-redaction probes still passed for environment-provided and literal passwords.
  • Missing owned database: setup now recreates an absent schema despite current metadata. A simulated competing CREATE preserved the foreign database without dropping it.
  • Manifest metadata and user docs: the selection fields are populated, the primary metric is emitted by the default run, and the linked Fern page documents setup and both headline accuracies.

I accounted for all 31 changed files through separate verification/concurrency, MySQL setup and benchmark/data/config reviews. I compared the supplied previous revision directly and separated unrelated upstream restructuring from the BEAVER changes.

Validation

  • CI on 42213825f9591bf24d4d239ad91a525ffc725b5d: Unit tests / Test and Unit tests / Server suite succeeded, including all four core shards, eight server shards and combined core coverage. Both component-lock checks and the Fern docs check succeeded.
  • The BEAVER server’s CI log shows 170 passed and 17 skipped. The skips cover 16 official-evaluator comparisons and one live-MySQL test. Unit tests / Changed server tests was skipped; the full server suite did execute BEAVER.
  • Targeted local probes passed for memory bounds, cancellation cleanup, seven previous-versus-current scoring cases, database recovery and ownership races, grant migration, schema validation and drift, preparation and stable task IDs. Eight fake-service episodes through both shipped configurations preserved rewards, masking, cookies and task fields. My separate adapter-to-verifier probe returned rewards [1, 0, 0] and the expected 33.33% aggregate.
  • Probes ran in 766267172432.dkr.ecr.us-east-1.amazonaws.com/gym:91666f99091979a03d78b76558851f5bf1bbf43a, a successful default-branch CI image because this head’s container build was skipped. An outside-tree virtual environment supplied MySQL Connector 26.10.0 and pandas 2.3.3. Scripts and outputs are under /workspace/review-probes/; existing CI suites were not rerun locally.

I did not independently run live MySQL, gated datasets, model calls or the external official evaluator. The PR’s reported profiling and live-rollout results remain author-supplied evidence. The local probes used fake external boundaries, not substitutes for those live checks.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Dec 1, 2026
@yaoyu-33 yaoyu-33 added the Nemotron Work related to NVIDIA Nemotron label Dec 1, 2026
mysql-connector-python is GPL-2.0 with the Universal FOSS Exception, so keeping
it would need OSRB review (anwithk on NVIDIA-NeMo#6708). PyMySQL is MIT. The official
evaluator keeps mysql-connector-python; benchmarks/beaver/official_check.py,
which runs it, is run with `uv run --with mysql-connector-python`, and the
server no longer depends on it.

The verifier keeps the official driver's behavior that matters for scoring:
- Multi-statement strings are allowed (CLIENT.MULTI_STATEMENTS) and only the
  first result counts. Without it PyMySQL refuses such a string (1064) where
  the official driver returns the first statement's result; 2 of 1,600 saved
  model answers depend on it. A statement still running after the first
  result is stopped by killing the connection, as before.
- Rows are read unbuffered (SSCursor), in chunks, so a timed-out or oversized
  result stops being read and memory stays bounded. "More results pending"
  comes from PyMySQL's result (has_next), the connection id from thread_id(),
  error numbers from the exception's first argument.
- PyMySQL reads rows at about half the official driver's rate, so a result
  near the old 5,000,000-row limit ran out of the 10 s first and scored as an
  empty result instead of oversized. The limit is now 1,000,000 rows (1.6
  times the largest gold result, 622,224 rows), reached in a few seconds.
  Officially an over-limit answer whose rows repeat a gold's could match (the
  comparison is over sets); the README lists this departure, which existed at
  5,000,000 rows before.
- After the connection is killed and closed, PyMySQL's leftover unbuffered
  result and cursor are marked done, so garbage collection doesn't log a
  traceback for every multi-statement or oversized answer.

The tests' fake driver follows PyMySQL's API and error classes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abel Brown <[email protected]>
@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Push history, moved out of the description to keep it short.

Since 42213825f9591bf24d4d239ad91a525ffc725b5d (this push, one commit)

  • The verifier runs queries with PyMySQL (MIT) instead of mysql-connector-python (GPL-2.0 with the Universal FOSS Exception), as @anwithk asked. Multi-statement strings are allowed, as the official driver allows them; rows are read unbuffered, as before.
  • The size limit is 1,000,000 rows (was 5,000,000), since PyMySQL reads at about half the official driver's rate.
  • After a connection is killed, PyMySQL's leftover result and cursor no longer log a traceback when garbage-collected.
  • official_check.py runs the official file, which imports mysql-connector-python: run it with uv run --with mysql-connector-python.
  • The description is shorter. The earlier version, with the full gold-check, official-check and auto-ontology-eval comparison tables, is in this PR's description edit history.

1b85ff3f90d536d439b6a0277dbb7d0e6283bbf2 to 42213825f9591bf24d4d239ad91a525ffc725b5d

  • A merge of main; "verifier" instead of "grader" throughout; the full auto-ontology-eval commit in the code headers; built-in generics and X | None in annotations (ffrujeri's review).

@abelatnvidia

Copy link
Copy Markdown
Contributor Author

@anwithk thanks, switched to PyMySQL (MIT). The official evaluator keeps mysql-connector-python (GPL-2.0 with the Universal FOSS Exception); the server doesn't depend on it, and official_check.py, which runs the official file, is run with uv run --with mysql-connector-python.

Parity, on your test:

  • official_check.py on the 1,200 saved answers (three 400-task runs): the same verdict on all 1,200.
  • The same 1,200 answers replayed through gym eval run: identical to before the switch on every task (13, 3 and 12 passes).
  • Every gold query as its own prediction (6,925): the same verdict on 6,923. The other 2 (dw_3246, dw_4521) are golds the server answered differently on a second run; before the switch there were 3 such, with different ids.
  • The server's tests with a live MySQL and the official file: 188 passed.

Two verifier changes came with the switch:

  1. Multi-statement strings are enabled (CLIENT.MULTI_STATEMENTS). Without it, PyMySQL refuses a string with several statements, where the official driver runs it and returns the first result. 2 of the 1,200 answers depend on it (2 more fail either way). As before, only the first result counts; the server runs the later statements as soon as that result is sent, and one still running is stopped by killing the connection. An answer still can't write: the verifier's user holds only SELECT, and startup refuses anything more. On 13 probes (SELECT 1; SELECT 2, SET @x = 3; SELECT @x, a trailing DO SLEEP(30), ...) the official evaluator and the verifier return the same result.
  2. The size limit is 1,000,000 rows (was 5,000,000). No gold result has more than 622,224 rows. One departure grows with it: officially the comparison is over sets of rows, so an answer of more than 1,000,000 rows that repeat a gold's rows could match if the official driver reads it within 10 s; here it's oversized and doesn't match. That departure existed at 5,000,000 rows before; none of the 1,200 answers hits it. I tried counting only distinct rows instead, but a huge repeat-heavy answer then ran on to the 10 s, scored as empty (matching an empty gold) and made a large gold beside it time out, so a plain row limit is the safer trade.

The limit came down because PyMySQL reads rows at about half the official driver's rate (about 350,000 against 735,000 a second for one wide result, measured here). At 5,000,000 rows, a huge answer could run out of the 10 s first and score as a timeout, an empty result, instead of as oversized. One of the 1,200 did (its gold isn't empty, so the verdict didn't change); now it's oversized again.

The slower reads also mean a query near the 10 s limit is a little more likely to time out here than under the official driver; the server README's concurrency note covers the few golds that slow.

@abelatnvidia

Copy link
Copy Markdown
Contributor Author

Switched the verifier to PyMySQL, as @anwithk ruled; parity and the two verifier changes that came with it are in the comment above, and the push history in the one before it.

@Glorf this is the head to re-review. @ffrujeri could you /ok to test ac38750bfd2b56d725a926ca63eda8c6d98688fb?

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers benchmark-onboarding Self-contained benchmark onboarding feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer Nemotron Work related to NVIDIA Nemotron risk:high Autobot PR risk: high sla:review-overdue Review response is over the one-business-day SLA waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants