diff --git a/aiserver.py b/aiserver.py index 8d9bd27d..c0485cd1 100644 --- a/aiserver.py +++ b/aiserver.py @@ -7478,7 +7478,7 @@ class GenerationInputSchema(SamplerSettingsSchema): frmtadsnsp: Optional[bool] = fields.Boolean(metadata={"description": "Input formatting option. When enabled, adds a leading space to your input if there is no trailing whitespace at the end of the previous action.\n\nIf `disable_input_formatting` is `true`, this defaults to `false` instead of the value in the KoboldAI GUI."}) quiet: Optional[bool] = fields.Boolean(metadata={"description": "When enabled, Generated output will not be displayed in the console."}) sampler_order: Optional[List[int]] = fields.List(fields.Integer(), validate=[validate.Length(min=6), permutation_validator], metadata={"description": "Sampler order to be used. If N is the length of this array, then N must be greater than or equal to 6 and the array must be a permutation of the first N non-negative integers."}) - sampler_seed: Optional[int] = fields.Integer(metadata={"description": "RNG seed to use for sampling. If not specified, the global RNG will be used."}) + sampler_seed: Optional[int] = fields.Integer(validate=validate.Range(min=0, max=2**64 - 1), metadata={"description": "RNG seed to use for sampling. If not specified, the global RNG will be used."}) sampler_full_determinism: Optional[bool] = fields.Boolean(metadata={"description": "If enabled, the generated text will always be the same as long as you use the same RNG seed, input and settings. If disabled, only the *sequence* of generated texts that you get when repeatedly generating text will be the same given the same RNG seed, input and settings."}) class GenerationResultSchema(KoboldSchema): @@ -9881,7 +9881,7 @@ def put_config_soft_prompt(body: SoftPromptSettingSchema): return {} class SamplerSeedSettingSchema(KoboldSchema): - value: int = fields.Integer(required=True) + value: int = fields.Integer(validate=validate.Range(min=0, max=2**64 - 1), required=True) @api_v1.get("/config/sampler_seed") @api_schema_wrap diff --git a/tpu_mtj_backend.py b/tpu_mtj_backend.py index ec2b2f45..2642943b 100644 --- a/tpu_mtj_backend.py +++ b/tpu_mtj_backend.py @@ -55,7 +55,7 @@ from mesh_transformer.util import to_bf16 params: Dict[str, Any] = {} -__seed = random.randrange(sys.maxsize) +__seed = random.randrange(2**64) rng = random.Random(__seed) @@ -69,7 +69,7 @@ def set_rng_seed(seed: int): return seed def randomize_rng_seed(): - return set_rng_seed(random.randrange(sys.maxsize)) + return set_rng_seed(random.randrange(2**64)) def get_rng_state(): return rng