[Rust Frontend] Forward per-request watermarking controls (#56338)
Co-authored-by: Codex <noreply@openai.com> Signed-off-by: NickLucche <nicolo.lucchesi@mistral.ai>
This commit is contained in:
@@ -20,6 +20,10 @@ fn default_temperature() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
fn default_watermarking() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn default_max_tokens() -> u32 {
|
||||
16
|
||||
}
|
||||
@@ -68,6 +72,9 @@ pub struct EngineCoreSamplingParams {
|
||||
/// greedy sampling.
|
||||
#[serde(default = "default_temperature")]
|
||||
pub temperature: f32,
|
||||
/// Whether to apply the engine's configured watermark to this request.
|
||||
#[serde(default = "default_watermarking")]
|
||||
pub watermarking: bool,
|
||||
/// Cumulative probability threshold for nucleus sampling.
|
||||
#[serde(default = "default_top_p")]
|
||||
pub top_p: f32,
|
||||
@@ -155,6 +162,7 @@ impl EngineCoreSamplingParams {
|
||||
pub fn for_test() -> Self {
|
||||
Self {
|
||||
temperature: 1.0,
|
||||
watermarking: true,
|
||||
top_p: 1.0,
|
||||
top_k: 0,
|
||||
seed: None,
|
||||
@@ -229,6 +237,7 @@ mod tests {
|
||||
|
||||
// Omitted fields -> Python defaults.
|
||||
assert_eq!(sampling.temperature, 1.0);
|
||||
assert!(sampling.watermarking);
|
||||
assert_eq!(sampling.top_p, 1.0);
|
||||
assert_eq!(sampling.top_k, 0);
|
||||
assert_eq!(sampling.seed, None);
|
||||
|
||||
@@ -151,6 +151,7 @@ fn sample_request_with_id(request_id: &str) -> EngineCoreRequest {
|
||||
prompt_token_ids: Some(vec![11, 22]),
|
||||
sampling_params: Some(EngineCoreSamplingParams {
|
||||
temperature: 0.8,
|
||||
watermarking: false,
|
||||
top_p: 0.9,
|
||||
top_k: 8,
|
||||
max_tokens: 32,
|
||||
@@ -2662,6 +2663,7 @@ fn python_msgpack_fixtures_match_rust_encoding() {
|
||||
sampling,
|
||||
EngineCoreSamplingParams {
|
||||
temperature: 1.0,
|
||||
watermarking: true,
|
||||
top_p: 1.0,
|
||||
top_k: 0,
|
||||
seed: None,
|
||||
|
||||
@@ -34,6 +34,7 @@ class FinishReason(IntEnum):
|
||||
# Mirror of real SamplingParams; omit_defaults makes fixtures match real maps.
|
||||
class EngineCoreSamplingParams(msgspec.Struct, dict=True, omit_defaults=True):
|
||||
temperature: float = 1.0
|
||||
watermarking: bool = True
|
||||
top_p: float = 1.0
|
||||
top_k: int = 0
|
||||
seed: int | None = None
|
||||
@@ -123,6 +124,7 @@ request = EngineCoreRequest(
|
||||
mm_features=None,
|
||||
sampling_params=EngineCoreSamplingParams(
|
||||
temperature=0.8,
|
||||
watermarking=False,
|
||||
top_p=0.9,
|
||||
top_k=8,
|
||||
seed=None,
|
||||
|
||||
Reference in New Issue
Block a user