Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/fast/rollout/session/test_request_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ def resolve_request_args(self, request_args, *, turn_args):

@pytest.mark.parametrize("evaluation", [False, True])
def test_session_sampling_defaults_fill_only_omitted_fields(evaluation):
# Training defaults stay unbounded; see SAMPLING in tests/fast/router/test_session_evaluation.py.
defaults = {"temperature": 0.6, "top_p": 0.9 if evaluation else 1.0, "top_k": 20 if evaluation else -1}
temperature = 0.1 if evaluation else 0.6
client_args = {"temperature": temperature, "top_p": None, "top_k": -1}
original = deepcopy(client_args)
Expand All @@ -258,11 +260,11 @@ def test_session_sampling_defaults_fill_only_omitted_fields(evaluation):
config=make_session_server_config(),
turn_args=None,
evaluation=evaluation,
sampling_defaults={"temperature": 0.6, "top_p": 0.9, "top_k": 20},
sampling_defaults=defaults,
)
assert {key: prepared.body[key] for key in ("temperature", "top_p", "top_k")} == {
"temperature": temperature,
"top_p": 0.9,
"top_p": defaults["top_p"],
"top_k": -1,
}
assert client_args == original
Expand Down
20 changes: 12 additions & 8 deletions tests/fast/router/test_session_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,22 @@ async def test_concurrent_train_and_eval_do_not_share_policy(env):
assert sorted(request["return_indexer_topk"] for request in env.backend.requests) == [False, True]


SAMPLING = {"temperature": 0.6, "top_p": 0.9, "top_k": 20}
# Training sessions stay unbounded: sampling-support replay rejects bounded training sampling
# (top_p < 1 or top_k > 0) on a run that does not capture rollout sampling support.
SAMPLING = {"temperature": 0.6, "top_p": 1.0, "top_k": -1}
EVAL_SAMPLING = {"temperature": 0.6, "top_p": 0.9, "top_k": 20}


@pytest.mark.parametrize("evaluation", [False, True])
async def test_creation_sampling_defaults_fill_only_omitted_fields(env, evaluation):
sid = await _create(env, json.dumps({**SAMPLING, "evaluation": evaluation}).encode())
defaults = EVAL_SAMPLING if evaluation else SAMPLING
sid = await _create(env, json.dumps({**defaults, "evaluation": evaluation}).encode())
await _chat(env, sid, [USER])
temperature = 0.1 if evaluation else SAMPLING["temperature"]
temperature = 0.1 if evaluation else defaults["temperature"]
await _chat(env, sid, [USER, ASSISTANT, TOOL], temperature=temperature, top_p=None, top_k=-1)
omitted, explicit = env.backend.requests[-2:]
assert {key: omitted[key] for key in SAMPLING} == SAMPLING
assert {key: explicit[key] for key in SAMPLING} == {**SAMPLING, "temperature": temperature, "top_k": -1}
assert {key: omitted[key] for key in defaults} == defaults
assert {key: explicit[key] for key in defaults} == {**defaults, "temperature": temperature, "top_k": -1}


@pytest.mark.parametrize("saved,requested", [(0.6, 0.1), (0.6, 0.0), (0.0, 0.6)])
Expand All @@ -212,9 +216,9 @@ async def test_training_temperature_mismatch_is_rejected_before_forwarding(env,
f"temperature={requested!r} does not match the training session temperature={saved!r}"
)
assert len(env.backend.requests) == request_count
await _chat(env, sid, messages, temperature=saved, top_p=0.5, top_k=-1)
await _chat(env, sid, messages, temperature=saved, top_p=1.0, top_k=-1)
wire = env.backend.requests[-1]
assert (wire["temperature"], wire["top_p"], wire["top_k"]) == (saved, 0.5, -1)
assert (wire["temperature"], wire["top_p"], wire["top_k"]) == (saved, 1.0, -1)


async def test_training_null_temperature_uses_registered_value(env):
Expand All @@ -240,7 +244,7 @@ async def test_an_integer_temperature_is_accepted_as_a_float_default(env):

async def test_an_integral_float_top_k_is_stored_as_an_int(env):
"""An eval dataset YAML can spell top_k as 40.0; the engine must still receive an integer."""
sid = await _create(env, b'{"top_k": 40.0}')
sid = await _create(env, b'{"evaluation": true, "top_k": 40.0}')
await _chat(env, sid, [USER])
top_k = env.backend.requests[-1]["top_k"]
assert top_k == 40 and isinstance(top_k, int)
Expand Down
Loading