jax-ml/jax · error · ValueError

dtype argument to `weibull_min` must be a float dtype, got {

Error message

dtype argument to `weibull_min` must be a float dtype, got {dtype}

What it means

jax.random.weibull_min requires its dtype argument to be a floating-point dtype. After canonicalization (default float), dtypes.issubdtype(dtype, np.floating) is checked; integer, bool, or complex dtypes fail with this ValueError.

Source

Thrown at jax/_src/random/core.py:2975

  on the domain :math:`0 < x < \infty`, where :math:`c > 0` is the concentration
  parameter, and :math:`\sigma > 0` is the scale parameter.

  Args:
    key: a PRNG key.
    scale: The scale parameter of the distribution.
    concentration: The concentration parameter of the distribution.
    shape: The shape added to the parameters loc and scale broadcastable shape.
    dtype: The type used for samples.

  Returns:
    A jnp.array of samples.

  """
  key, _ = _check_prng_key("weibull_min", key)
  dtype = dtypes.check_and_canonicalize_user_dtype(
      float if dtype is None else dtype)
  if not dtypes.issubdtype(dtype, np.floating):
    raise ValueError(f"dtype argument to `weibull_min` must be a float "
                     f"dtype, got {dtype}")
  shape = core.canonicalize_shape(shape)
  return _weibull_min(key, scale, concentration, shape, dtype)


@jit(static_argnums=(3, 4))
def _weibull_min(key, scale, concentration, shape, dtype) -> Array:
  random_uniform = uniform(
      key=key, shape=shape, minval=0, maxval=1, dtype=dtype)

  # Inverse weibull CDF.
  return jnp.power(-jnp.log1p(-random_uniform), 1.0/concentration) * scale


def orthogonal(
  key: ArrayLike,
  n: int,
  shape: Shape = (),

View on GitHub (pinned to 1e1c6a8fc0)

Solutions

  1. Use a float dtype (np.float32/np.float64/jnp.bfloat16) or omit dtype
  2. Validate forwarded dtypes in wrappers: assert np.issubdtype(dtype, np.floating)

Example fix

// before
x = jax.random.weibull_min(key, 1.0, 2.0, (n,), dtype=jnp.int32)
// after
x = jax.random.weibull_min(key, 1.0, 2.0, (n,), dtype=jnp.float32)
Defensive patterns

Strategy: validation

Validate before calling

import numpy as np
assert dtype is None or np.issubdtype(np.dtype(dtype).type, np.floating), 'weibull_min needs float dtype'

Type guard

def is_float_dtype(d) -> bool:
    import numpy as np
    return d is None or d is float or np.issubdtype(np.dtype(d).type, np.floating)

Prevention

When it happens

Trigger: Calling jax.random.weibull_min(key, scale, concentration, shape, dtype) where dtype is np.int32, np.bool_, or np.complex64.

Common situations: Reusing an int dtype from a discrete sampler, or building a generic wrapper that forwards a user-supplied dtype without validating it against the sampler's requirements.

Related errors


AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27). Data as JSON: /api/errors/95607e251614d2f5. Report an issue: GitHub.