mstar.utils.generation_kwargs

mstar.utils.generation_kwargs#

The client-facing generation knobs, sampling and output geometry, checked once where every endpoint submits.

One meaning per knob on every model: null is the same as leaving the key out, a value is coerced to the knob’s type only when it denotes exactly that value ("0.7", "5", 5.0 for an integer; never a bool), and a value out of range is a ValueError (a 400) before any worker sees the request. A multi-stage model’s <stage>_<knob> (talker_temperature) follows the rule for <knob>.

Functions

check_seed(seed)

Raise ValueError unless seed is None or an integer that fits in int64.

normalize_generation_kwargs(model_kwargs)

model_kwargs with nulls dropped, length aliases folded into max_output_tokens, and every known knob coerced, then type- and range-checked.

offset_seed(seed, i)

seed + i wrapped to signed int64, as the Rust frontend computes it.

mstar.utils.generation_kwargs.check_seed(seed)[source]#

Raise ValueError unless seed is None or an integer that fits in int64.

int64 is the widest seed a sampler can store or pass to manual_seed, and past it the request cannot even be packed for the conductor.

Return type:

None

mstar.utils.generation_kwargs.normalize_generation_kwargs(model_kwargs)[source]#

model_kwargs with nulls dropped, length aliases folded into max_output_tokens, and every known knob coerced, then type- and range-checked.

Raises ValueError naming the knob and its allowed range.

Parameters:

model_kwargs (dict | None)

Return type:

dict

mstar.utils.generation_kwargs.offset_seed(seed, i)[source]#

seed + i wrapped to signed int64, as the Rust frontend computes it.

Parameters:
Return type:

int