Repository navigation
[Doc] Raise the bar for agent-written tests #62601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c5c9eca
fada500
05636b5
2997617
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,31 @@ | ||||||||||||||||||
| # tests | ||||||||||||||||||
|
|
||||||||||||||||||
| - **User-visible fixes need a real-path test.** Use the cheapest level that | ||||||||||||||||||
| reproduces the problem, but a fix to user-visible behavior needs at least one | ||||||||||||||||||
| regression test through `LLM` (`vllm_runner`) or the OpenAI server | ||||||||||||||||||
| (`RemoteOpenAIServer`), not only a unit test on hand-built inputs. Mock only | ||||||||||||||||||
| external dependencies; a test that only asserts `assert_called*` or "no | ||||||||||||||||||
| exception" guards nothing. | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have mixed opinion on this. Something like: vllm/tests/quantization/test_online.py Lines 1002 to 1008 in a6c898e
vllm/tests/quantization/test_online.py Line 1804 in a6c898e
& generally (not on @pytest.fixture
def single_rank_parallel_state(monkeypatch: pytest.MonkeyPatch):
"""Single rank parallel groups without initializing a process group.
This is faster than the `dist_init` fixture.
"""
for name in ("_WORLD", "_TP", "_ETP", "_DCP", "_PP", "_DP", "_EP", "_PCP"):
monkeypatch.setattr(
f"vllm.distributed.parallel_state.{name}", _SingleRankGroup()
)
monkeypatch.setattr(
"vllm.model_executor.parameter.get_tensor_model_parallel_rank", lambda: 0
)
monkeypatch.setattr(
"vllm.model_executor.parameter.get_tensor_model_parallel_world_size", lambda: 1
)that is faster than Instead of However, there are tests that need real weight loading and not only |
||||||||||||||||||
| - **Show the failure before the fix.** When the bug is reproducible, run the new | ||||||||||||||||||
| test on the base commit (rebuild if the fix touches `csrc/`) and confirm it | ||||||||||||||||||
| fails for the reported reason, then passes with the fix. Paste both commands | ||||||||||||||||||
| and the relevant output in the PR; "fails before" without output is not | ||||||||||||||||||
| evidence. | ||||||||||||||||||
| - **Never buy a green CI.** Do not add `@pytest.mark.flaky(reruns=...)`, retry | ||||||||||||||||||
| loops, wider tolerances, lowered thresholds, `skip`, or deletions to make a | ||||||||||||||||||
| test pass. Find out whether the failure is caused by your change or also | ||||||||||||||||||
| happens on main (`.buildkite/scripts/rerun-test.sh`, | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. xfail as well |
||||||||||||||||||
| `docs/contributing/ci/failures.md`). Mark a known bug with `xfail` linking the | ||||||||||||||||||
| issue, not `skip`. | ||||||||||||||||||
| - **Deterministic by construction.** Use greedy or seeded sampling. vLLM is not | ||||||||||||||||||
| batch invariant by default: batch size, chunked prefill, prefix caching, | ||||||||||||||||||
| backend, and TP size can flip greedy tokens, so compare against a reference | ||||||||||||||||||
| with tolerances (`check_logprobs_close`, `check_embeddings_close`) or require | ||||||||||||||||||
| `VLLM_BATCH_INVARIANT=1` for exact equality. Never synchronize with a fixed | ||||||||||||||||||
| `sleep`; poll an explicit condition with a timeout, and force race orderings | ||||||||||||||||||
| with events. | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also personally prompt not to arbitrarily increase atol/rtol to make tests pass, when they are expected to have strict equality or small atol/rtol. (https://github.com/vllm-project/vllm/pull/59766)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||||||
| - **Make sure CI runs it.** A test no step in `.buildkite/test_areas/*.yaml` | ||||||||||||||||||
| selects never runs, which looks like passing. Check that the step's | ||||||||||||||||||
| `commands` and pytest markers (`core_model`, `slow_test`, `distributed`) | ||||||||||||||||||
| select the test and its `source_file_dependencies` cover the changed files; | ||||||||||||||||||
| update the step if not. | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be general rules to follow and preferences, but not strict enforcements. Otherwise, agents will get stuck trying to fulfill requirements. I'm thinking concretely of:
MagicMockmight be needed in special cases.