Skip to content

Add unit tests for diffusion model eval branch in eval_cli.py#1524

Closed
Copilot wants to merge 2 commits intoxinhe/3-10from
copilot/sub-pr-1522-again
Closed

Add unit tests for diffusion model eval branch in eval_cli.py#1524
Copilot wants to merge 2 commits intoxinhe/3-10from
copilot/sub-pr-1522-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Description

The diffusion-model eval branch (is_diffusion_modeldiffusion_load_modelevaluate_diffusion_model) in eval_cli.eval() had no test coverage. Adds lightweight unit tests that monkeypatch these functions to verify the branch is taken correctly without requiring diffusers or model downloads.

New test class TestEvalDiffusionModelBranch in test/test_cpu/advanced/test_evaluation_functions.py:

  • test_diffusion_branch_taken — patches is_diffusion_model to return True, asserts diffusion_load_model is called with the model path and evaluate_diffusion_model is called with (args, pipe=pipe)
  • test_non_diffusion_model_skips_branch — patches is_diffusion_model to return False, asserts evaluate_diffusion_model is never invoked
with (
    patch("auto_round.eval.eval_cli.is_diffusion_model", return_value=True),
    patch("auto_round.utils.diffusion_load_model", return_value=(mock_pipe, MagicMock())) as mock_load,
    patch("auto_round.eval.evaluation.evaluate_diffusion_model") as mock_eval,
):
    eval_fn(args)

mock_load.assert_called_once_with(args.model)
mock_eval.assert_called_once_with(args, pipe=mock_pipe)

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Other (please specify): Test coverage

Related Issues

Relates to #1522

Checklist Before Submitting

  • My code has been tested locally.
  • Documentation has been updated as needed.
  • New or updated tests are included where applicable.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: xin3he <83260933+xin3he@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 10, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • huggingface.co
    • Triggering command: /usr/bin/python python -m pytest test/test_cpu/advanced/test_evaluation_functions.py -v --no-header (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on enabling --eval for diffusion model Add unit tests for diffusion model eval branch in eval_cli.py Mar 10, 2026
@xin3he xin3he closed this Mar 10, 2026
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