{"record":{"id":"2e7e3e84e787f804","repo":"jax-ml/jax","slug":"unrecognized-mode-config-mode","errorCode":null,"errorMessage":"Unrecognized mode: {config.mode}.","messagePattern":"Unrecognized mode: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/cudnn/scaled_matmul_stablehlo.py","lineNumber":618,"sourceCode":"\n  if config.mode == \"mxfp8\":\n    assert config.global_scale is None\n    assert config.scale_type == dtypes.float8_e8m0fnu\n\n    scales_q = cast_to_e8m0_with_rounding_up(get_scales_per_block(x))\n    scaled_x = x / e8m0_to_dtype(scales_q, x.dtype)\n  elif config.mode == \"nvfp4\":\n    assert config.scale_type == dtypes.float8_e4m3fn\n    assert config.global_scale.dtype == np.float32\n\n    SCALE_MAX = dtypes.finfo(config.scale_type).max.astype(x.dtype)\n\n    x /= config.global_scale\n    scales_q = jnp.clip(get_scales_per_block(x), 0, SCALE_MAX)\n    scales_q = lax.optimization_barrier(scales_q.astype(config.scale_type))\n    scaled_x = x / scales_q.astype(np.float32)\n  else:\n    raise ValueError(f\"Unrecognized mode: {config.mode}.\")\n\n  clipped_x = jnp.clip(scaled_x, -MAX, MAX)\n  x_q = clipped_x.astype(config.data_type)\n\n  x_q = x_q.reshape(x_shape)  # shape = (B, M, K)\n  scales_q = jnp.reshape(scales_q, scales_q.shape[:-1]).view(\n      config.scale_type\n  )\n  return x_q, scales_q\n\ndef scaled_dot_impl(lhs, rhs, dimension_numbers, preferred_element_type,\n                    configs):\n  if preferred_element_type is None:\n    preferred_element_type = dtypes.result_type(\n        lhs, rhs, return_weak_type_flag=False\n    )\n  else:\n    preferred_element_type = dtypes.check_and_canonicalize_user_dtype(","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/cudnn/scaled_matmul_stablehlo.py#L600-L636","documentation":"The quantize helper in the cuDNN scaled matmul path only supports a fixed set of BlockScaleConfig modes (e.g. 'mxfp8', and the nvfp4-style modes). Any other config.mode string falls through to this ValueError.","triggerScenarios":"Constructing BlockScaleConfig with a mode string that is not recognized (typo like 'mxf8', or an experimental/new mode unsupported by the installed jax-cudnn version) and calling scaled_dot / scaled_dot_general which quantizes inputs.","commonSituations":"Upgrading jax but not jax-cudnn (or vice versa) so new modes aren't recognized; hand-rolling configs copied from other repos; typos in mode names.","solutions":["Use a supported mode string exactly as documented (e.g. 'mxfp8', 'nf-hd', 'nvfp4-ish' per your version)","Upgrade jax and jax-cudnn together to the latest compatible pair","If you copied a config from elsewhere, compare against the modes handled in the if/elif chain above the raise"],"exampleFix":"# before\ncfg = BlockScaleConfig(mode='mxf8', ...)\n# after\ncfg = BlockScaleConfig(mode='mxfp8', ...)","handlingStrategy":"type-guard","validationCode":"from jax._src.cudnn.scaled_matmul_stablehlo import BlockScaleConfig  # modes validated at construction in newer versions","typeGuard":"SUPPORTED_MODES = {'mxfp8'}  # extend per your jax-cudnn version\ndef is_supported_mode(mode: str) -> bool:\n    return mode in SUPPORTED_MODES","tryCatchPattern":null,"preventionTips":["Centralize BlockScaleConfig construction in one helper","Upgrade jax and jax-cudnn in lockstep"],"tags":["jax","fp8","quantization","config","cudnn"],"backgroundTag":"invalid-enum-value","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}