{"record":{"id":"bb9b9791c468f77e","repo":"jax-ml/jax","slug":"must-provide-valid-mode-for-gumbel-got-s","errorCode":null,"errorMessage":"Must provide valid mode for gumbel got: %s","messagePattern":"Must provide valid mode for gumbel got: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/random/core.py","lineNumber":2277,"sourceCode":"      according to the given sharding specification. Primarily used in explicit\n      sharding mode.\n      See the `explicit sharding tutorial <https://docs.jax.dev/en/latest/parallel.html>`_\n      for more details.\n\n  Returns:\n    A random array with the specified shape and dtype.\n  \"\"\"\n  key, _ = _check_prng_key(\"gumbel\", key)\n  dtype = dtypes.check_and_canonicalize_user_dtype(\n      float if dtype is None else dtype)\n  if not dtypes.issubdtype(dtype, np.floating):\n    raise ValueError(f\"dtype argument to `gumbel` must be a float \"\n                     f\"dtype, got {dtype}\")\n  shape = core.canonicalize_shape(shape)\n  if mode is None:\n    mode = \"high\" if config.use_high_dynamic_range_gumbel.value else \"low\"\n  if mode not in (\"highest\", \"high\", \"low\"):\n    raise ValueError(\"Must provide valid mode for gumbel got: %s\" % mode)\n  out_sharding = canonicalize_sharding_for_samplers(out_sharding, \"gumbel\", shape)\n  return maybe_auto_axes(_gumbel, out_sharding, shape=shape, dtype=dtype,\n                         mode=mode)(key)\n\ndef _safe_int_to_float(bits, dtype):\n  \"\"\"Converts bits: u32[2,...] into f32[...] in the range (0,1).\"\"\"\n  if bits.dtype != np.uint32 or dtype != np.float32:\n    raise RuntimeError(\"_safe_int_to_float only works for u32 -> f32\")\n  finfo = dtypes.finfo(dtype)\n  hiclz, loclz = lax.clz(bits)\n  hi, lo = bits\n\n  mantissa = lax.bitwise_or(\n      lax.shift_left(hi, hiclz),\n      jnp.where(\n          hiclz == 32,\n          lax.shift_left(lo, loclz),\n          lax.shift_right_logical(lo, finfo.bits - hiclz)))","sourceCodeStart":2259,"sourceCodeEnd":2295,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/random/core.py#L2259-L2295","documentation":"jax.random.gumbel's mode argument controls the dynamic range of the sampler and must be one of 'highest', 'high', or 'low'. When mode=None it defaults to 'high' or 'low' based on the jax_use_high_dynamic_range_gumbel config, but any explicitly supplied value outside the allowed trio raises ValueError.","triggerScenarios":"jax.random.gumbel(key, shape, mode='max'), mode='HIGH' (case mismatch), or passing a non-string; only when mode is explicitly given (None is replaced by the config default).","commonSituations":"Newer mode argument unfamiliar to users porting old code; typos; passing the mode through from a config that never validated it.","solutions":["Use 'high', 'low', or 'highest' exactly (lowercase).","Omit mode to get the configuration-driven default ('high' if use_high_dynamic_range_gumbel is enabled, else 'low').","Validate mode against ('highest','high','low') in config-loading code."],"exampleFix":"// before\ng = jax.random.gumbel(key, (8,), mode='max')\n\n// after\ng = jax.random.gumbel(key, (8,), mode='high')","handlingStrategy":"validation","validationCode":"if mode is not None:\n    assert mode in ('highest', 'high', 'low'), f'invalid gumbel mode: {mode}'","typeGuard":"def is_valid_gumbel_mode(mode) -> bool:\n    return mode is None or mode in ('highest', 'high', 'low')","tryCatchPattern":null,"preventionTips":["Omit mode to use the config default.","Remember valid values are lowercase: highest/high/low."],"tags":["jax","random","gumbel","mode","input-validation"],"backgroundTag":"invalid-enum-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}