Skip to content

Commit

Permalink
CI: fix flaky tests (#1612)
Browse files Browse the repository at this point in the history
## Describe your changes
Some tests have been flaky recently:
- bert_ptq_cpu: Remove latency goal since the optimized onnx model is
not always faster than the torch model on CI. The latest torch might be
faster than it used to be.
- test_rmsnorm_to_l2norm: Increase the tolerance on all close check. The
tolerance is not met for some random data but the graph is correct.

## Checklist before requesting a review
- [ ] Add unit tests for this change.
- [ ] Make sure all tests can pass.
- [ ] Update documents if necessary.
- [ ] Lint and apply fixes to your code by running `lintrunner -a`
- [ ] Is this a user-facing change? If yes, give a description of this
change to be included in the release notes.
- [ ] Is this PR including examples changes? If yes, please remember to
update [example
documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md)
in a follow-up PR.

## (Optional) Issue link
  • Loading branch information
jambayk authored Feb 13, 2025
1 parent 50f360a commit 4153b37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/test/local/test_bert_ptq_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ def test_bert(sampler, execution_order, system, olive_json):
from olive.workflows import run as olive_run

olive_config = patch_config(olive_json, sampler, execution_order, system)
# remove the latency goal since it is flaky on CI
metrics = olive_config["evaluators"]["common_evaluator"]["metrics"]
del metrics[1]["sub_types"][0]["goal"]

footprint = olive_run(olive_config, tempdir=os.environ.get("OLIVE_TEMPDIR", None))
check_output(footprint)
2 changes: 1 addition & 1 deletion test/unit_test/passes/onnx/test_graph_surgeries.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def test_rmsnorm_to_l2norm(tmp_path, use_rsqrt, use_cast, all_ones):
input_feed = {"x": np.random.randn(1, hidden_size).astype(np.float32)}
input_result = input_session.run(None, input_feed)
output_result = output_session.run(None, input_feed)
np.testing.assert_allclose(input_result[0], output_result[0], rtol=1e-5, atol=1e-5)
np.testing.assert_allclose(input_result[0], output_result[0], rtol=1e-3, atol=1e-3)
# count nodes
dag = OnnxDAG.from_model_path(onnx_model.model_path)
expected_num_nodes = 2 + 2 * int(use_cast)
Expand Down

0 comments on commit 4153b37

Please sign in to comment.