Skip to content

Drive multi-task local lm-eval with completions - #98

Merged
haofrank merged 6 commits into
AMD-AGI:mainfrom
amd-nithya:crystal/local-eval-multi-task
Sep 21, 2026
Merged

haofrank merged 6 commits into
AMD-AGI:mainfrom
amd-nithya:crystal/local-eval-multi-task

Conversation

@amd-nithya

@amd-nithya amd-nithya commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • When MAGPIE_EVAL_TASKS is set, Magpie drives lm_eval with --model local-completions against /v1/completions so multiple-choice tasks that need loglikelihood (mmlu, hellaswag) work on the local eval path.
  • Magpie builds the lm-eval argv itself, including --confirm_run_unsafe_code for HumanEval, instead of wrapping InferenceX run_eval with a Bash python3() intercept that server-watch bypasses.
  • Enable HF_ALLOW_CODE_EVAL=1 when code evaluation is required, even if the caller did not set it.
  • Before launch, call InferenceX _install_lm_eval_deps and _patch_lm_eval when they are sourced; otherwise install lm-eval[api] into MAGPIE_EVAL_PYTHON.
  • Pass max_length and a generation budget (max_gen_toks plus --gen_kwargs max_tokens) so local-completions does not keep the 2048/256 defaults.
  • Record completed vs failed eval concurrencies instead of marking every requested conc as completed.
  • Publish results_concN.json per accuracy concurrency so batched concs stay distinguishable.
  • Leave InferenceX run_eval in place when MAGPIE_EVAL_TASKS is unset.
  • Document optional RUN_EVAL: "true" on the SGLang MI355X example YAML.

Test plan

  • PYTHONPATH=. pytest tests/test_eval_concurrency_scripts.py (35 passed)
  • Cover local-completions argv, --confirm_run_unsafe_code, HF_ALLOW_CODE_EVAL=1, dep install, _patch_lm_eval, max_length / max_tokens, and completed vs failed concs
  • pip install 'lm-eval[api]' && PYTHONPATH=. pytest tests/test_eval_lm_eval_runtime.py (starts real python -m lm_eval; skips if lm-eval is not installed)
  • After merge, run a Magpie YAML with RUN_EVAL: "true" and MAGPIE_EVAL_TASKS=gsm8k,mmlu,hellaswag,gpqa_diamond_cot_n_shot,humaneval_instruct and confirm the lm-eval results JSON contains all requested task keys

Crystal already sends comma-separated lm-eval task names, but the local
wrapper kept EVAL_TASKS_DIR as a single YAML and skipped HumanEval's
unsafe-code flag. Map the Magpie env into InferenceX and confirm
code-execution tasks so multi-task accuracy runs actually execute.

@haofrank haofrank left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Forwarding Magpie's task configuration to InferenceX makes sense, but I found three runtime issues below. All 27 existing tests pass; however, the new tests do not actually run lm-eval, so they do not cover these cases.

…ferenceX.

Magpie now invokes local-completions itself when MAGPIE_EVAL_TASKS is set so loglikelihood tasks and HumanEval flags survive server-watch, and HF_ALLOW_CODE_EVAL is set for code eval.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amd-nithya amd-nithya changed the title Honor MAGPIE_EVAL_TASKS on the local eval path Drive multi-task local lm-eval with completions Sep 17, 2026
amd-nithya and others added 2 commits September 17, 2026 13:34
lm-eval writes into a directory, so Magpie copies the newest result to results_concN.json and keeps conc 8 and 64 distinguishable for downstream gates.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover local-completions multiple-choice scoring, --confirm_run_unsafe_code, and HF_ALLOW_CODE_EVAL against a real lm-eval process. Skip when lm-eval is not installed so Magpie unit CI stays lightweight.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amd-nithya

Copy link
Copy Markdown
Collaborator Author

The mocked argv tests still do not start lm-eval. tests/test_eval_lm_eval_runtime.py now does: Magpie's eval shim runs real python -m lm_eval.

  • local-chat-completions raises NotImplementedError on loglikelihood; Magpie local-completions scores a tiny multiple-choice task against a local /v1/completions server
  • an unsafe_code task fails without --confirm_run_unsafe_code and succeeds when Magpie puts that flag on the lm-eval process
  • Magpie sets HF_ALLOW_CODE_EVAL=1; Hugging Face code_eval refuses when that env is unset

Those tests importorskip when lm-eval is not installed so Magpie unit CI stays unchanged. Locally: pip install 'lm-eval[api]' then PYTHONPATH=. pytest tests/test_eval_lm_eval_runtime.py (4 passed).

@haofrank haofrank left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The update addresses the three earlier concerns. I found three remaining issues in the new execution path, noted inline. The 28 script tests passed locally; the runtime test module was skipped because lm-eval was not installed in my environment.

Install and patch eval deps, pass context and generation limits, and record completed vs failed concurrencies so RUN_EVAL works without a wrapper caller.

Co-authored-by: Cursor <cursoragent@cursor.com>
@haofrank
haofrank self-requested a review September 21, 2026 21:10
magpie_run_eval_persisted cds into a temp results dir, so a relative MAGPIE_EVAL_INCLUDE_PATH such as custom-tasks would otherwise stop resolving.

Co-authored-by: Cursor <cursoragent@cursor.com>
@haofrank
haofrank self-requested a review September 21, 2026 22:07

@haofrank haofrank left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, Thanks @amd-nithya !

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants