Repository navigation
feat(birdbench): add Spark SQL dialect and train split - #4898
Conversation
83c1624 to
ada9081
Compare
Loads BIRD dev SQLite DBs into a local Spark warehouse, transpiles each gold query to Spark SQL with sqlglot, and compares result sets against SQLite. First step toward a Spark SQL dialect for birdbench. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
Document the JDK 17, pyspark, sqlglot, and setuptools requirements, plus the PYSPARK_PYTHON fix for driver/worker Python version mismatch. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
…but execute it as sqlite and match its answer against spark sql generated by the LLM when the dialect is spark sql. TODO: - add other dialects like postgresql - possibly, add catalog in table names. Not strictly needed. Signed-off-by: Dipendra Misra <[email protected]>
Signed-off-by: Dipendra Misra <[email protected]>
…trics - execute_sqlite aborts runaway queries with a SQLite progress handler and raises TimeoutError, so a timed-out query frees its worker thread instead of leaving a zombie that makes later queries time out while queued. The connection is now closed explicitly; the outer wait_for is only a backstop. - Report no_sql, gold/pred sql-timeout, gold/pred sql-error, sql-timeout, sql_errors and unclean as per-rollout scores plus counts in the aggregate metrics, and log each SQL failure with running totals. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
prepare() now takes split="dev"|"train" (default dev, output unchanged). The train split builds BIRD's "uberset" -- train.json with each ReViSQL-verified row swapped in by question_id -- and runs it against train_databases, writing data/birdbench_train_<dialect>.jsonl with a null difficulty. - setup_bird_sql: add ensure_bird_train() (train.zip download + nested train_databases.zip extraction), mirroring ensure_bird_sql(). - build_db_values: add corpus_limit_per_column to DbHandle so the BM25 corpus scan can be capped on multi-GB train DBs, replacing the monkeypatch in birdbench_train/prepare_train.py. Dev stays unbounded. - Tests for the uberset merge, train split, corpus cap and error paths. The download/extraction path has not been run against the real train.zip. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
The bird_sql server gets a `split: dev|train` config key; for train it verifies against ensure_bird_train()'s train_databases (the internal `_dev_databases_dir` is renamed `_databases_dir` accordingly). eval.sh gets `--split dev|train`, combinable with `--dialect`: it picks the prepared file (data/birdbench_train_<dialect>.jsonl), dataset name and prompt, sets `prepare_script_args.split` and the server's `split`, and gives train its own Spark warehouse (spark_warehouse_train) since its db_ids differ from dev's. Output dirs get a `_train` suffix. eval.sh is added to version control with this change. config.yaml declares the `split: dev` default; the README gains a "Splits" section. Tests cover the server's split handling and that every split/dialect pair maps to a distinct prepared file. Not run: `eval.sh --split train` against the real train data. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
Folds the standalone birdbench_train collector into birdbench, working for
any `--split` and `--dialect`. `collect` calls a policy endpoint directly
with logprobs (the vllm_model server hardcodes top_logprobs=0) and writes
{id, db_id, context, completions: [{completion, reward,
reference_logprob}]} records, saving every raw API response first.
Rewards follow the bird_sql server's (SQLite, or Spark via
execute_and_compare_spark); a scoring exception counts as reward 0.
Other subcommands: `reprocess` (rebuild grouped output from the saved raw
responses, no API calls), `group` (convert a `gym eval run` rollouts file),
and `select-hard` (rows no rollout solved, matched by id rather than by
prompt text, which was ambiguous for identical prompts).
prepare.py gains databases_dir_for / load_entries / prompt_config_fpath_for
so prepare and collect resolve a split the same way. The README documents
the workflow.
Replaces the untracked benchmarks/birdbench_train/ scripts: the
generate_*/reprocess_* shell wrappers, select_hard_examples.py and the
--via-gym-server launcher are dropped, as is the verified-val set. Open-FD
and RSS diagnostics in reprocess are dropped too (/proc-only; they debugged
a since-fixed GIL issue).
Not run: Spark collection, or anything against the real train data.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Dipendra Misra <[email protected]>
prepare.py gets a CLI (`python -m benchmarks.birdbench.prepare --dialect
{sqlite,spark} --split {dev,train} [--train-dir] [--dscp] [--no-evidence]`)
so both choices are plain flags; covered by two tests.
The README now opens with the three processes (prepare, eval, collect), then
covers installation, dialects and splits, preparing data and the files each
step writes, and only then evaluation and training-data collection. It states
what eval and collect each store (per-rollout rows vs. grouped records) and
is shorter than before.
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Signed-off-by: Dipendra Misra <[email protected]>
- Prompts: prompts/default.yaml -> default_sqlite.yaml and spark.yaml -> default_spark.yaml, so both are default_<dialect>.yaml. - Prepared data: data/birdbench_<dialect>_<split>.jsonl for every dialect and split (dev was birdbench_<dialect>_benchmark.jsonl, train was birdbench_train_<dialect>.jsonl). - eval.sh output: results/<split>_<dialect>/<model>/ (no more dialect/split suffixes on the model dir). - collect output: train_data/<split>_<dialect>/<model>/, and collect and reprocess now default to --split train. prepare and eval still default to dev. README: the model is described as an OpenAI-compatible endpoint you serve (e.g. vLLM); the "Prompts" and "Driving gym directly" sections are removed. Tests and config updated to match. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
The "Collecting training data" section now leads with the `collect` command (repeats, dialect, split, smoke test), its output files and notes. The reprocess, group and select-hard commands move to a separate "Rarely needed" block, each with a one-line comment. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
Server environments are built from pyproject.toml and uv.lock with uv sync, which removes packages installed by hand. Declare pyspark (runs the model's SQL) and sqlglot (checks it is a single SELECT/WITH) and re-lock. Both are imported only when dialect: spark; the dialect also needs a JDK 17 on the machine. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
… answer When the Spark JVM exits, execute_spark swallowed every error and returned None, so each later answer was scored as a wrong answer. A 1534-task run lost ~500 valid rollouts this way: accuracy fell from ~55% to 0 and nothing flagged it. After a failed query, execute_spark now runs a trivial SELECT 1; if that fails too it raises SparkUnavailableError, and verify reports it through the typed, masked verifier-failure path as spark_unavailable. A model's own bad query on a live session still scores as a wrong answer. Also give the Spark routing test a real database file: verify now checks that the database exists (database_missing) before running anything. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
…cense CLAUDE.md requires the source URL, exact commit SHA and license in the header of any adapted code. The n-gram/BM25 value retrieval and the prompt wording come from OmniSQL's train_and_evaluate/process_dataset.py. Pin the links to a66d732010c89fac4353488d1c59e0b06f92b742, where the cited code is still at the cited place, and record the license basis: the repository has no LICENSE file; its maintainers state Apache-2.0 in RUCKBReasoning/OmniSQL issue 25. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
collect.py (SFT rollouts with logprobs) and its tests move to the sdg-pipelines repo as the birdbench-sft-data recipe. Remove it, its README sections and its mentions here. The train split of prepare/eval stays: it is dataset preparation, and the recipe calls into it. Also update the install docs for locked environments: bm25s and nltk are declared in the benchmark's preparation project and pyspark and sqlglot in bird_sql's, so nothing is pip-installed by hand; run prepare directly with uv run --project benchmarks/birdbench. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
ada9081 to
5686b44
Compare
|
/ok to test e3e1c49 |
abelatnvidia
left a comment
There was a problem hiding this comment.
Thanks for the rebase. I ran it locally on main bf31d56: unit tests, plus a stub-model eval.sh over all of dev with the PostgreSQL dialect stacked on top.
1. Fix needed: eval.sh drops prepare_project for any non-default dialect or split. Line 166 replaces the dataset entry, so prepare_project: benchmarks/birdbench from config.yaml is lost. gym eval prepare then runs in Gym's own environment and stops with ModuleNotFoundError. I hit it with --dialect postgres; --dialect spark and --split train go through the same path, and sqlite/dev is fine. Fix: add prepare_project:benchmarks/birdbench, to that override. With it, the full dev run matches the gold check on all 1,534 questions.
2. FYI: the gold-sql-* metrics now always read 0. Main (#5072) masks gold errors and timeouts and leaves those rows out of compute_metrics, so they show up as coverage/masked_rollouts instead (2 in my run). Fine to keep the names; maybe one line in the description.
Optional: pyspark as a plain dependency adds about 340 MB to every bird_sql venv, SQLite-only runs included. A spark extra would avoid that. Your call.
|
Previous comments are addressed, the description is stale: it still advertises benchmarks.birdbench.collect, which isn’t in the current code |
The override replaces the whole datasets entry, so it dropped prepare_project from config.yaml and gym eval prepare ran outside the locked prep project (ModuleNotFoundError for bm25s on --dialect spark and --split train). Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Signed-off-by: Dipendra Misra <[email protected]>
ff7a933
Signed-off-by: Dipendra Misra <[email protected]> # Conflicts: # resources_servers/bird_sql/app.py
|
/ok to test 8a3bd20 |
|
/ok to test a38bfab |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42957708149 |
What and why
Adds a
--dialect sparkoption and atrainsplit to the BIRD benchmark, with no new packages.sqlite/devstays the default and is unchanged.train.json, with rows that ReViSQL re-verified replaced by the verified version.birdbench_<dialect>_<split>.jsonl, one row per task and never repeated.eval.sh: takes--dialectand--split.Issue
No issue; this extends an existing benchmark.
Validation
bird_sqlserver tests: 83 passed.benchmarks/birdbenchtests: 76 passed.VERIFIER_ERROR(spark_unavailable), not scored as a wrong answer.Rollout evidence
Code tested on local machine that can evaluate bird spark train and dev code.
Compatibility
bird_sqlenvironment gainspyspark>=3.5,<4andsqlglot(locked). The Spark dialect also needs a JDK 17 on the machine.gold-sql-*metrics now always read 0. Look atcoverage/masked_rolloutsinstead.