{"record":{"id":"4a635c4465e4bc95","repo":"jax-ml/jax","slug":"unknown-keyword-arguments-sharding-rule-dict","errorCode":null,"errorMessage":"Unknown keyword arguments: {sharding_rule_dict}","messagePattern":"Unknown keyword arguments: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning.py","lineNumber":497,"sourceCode":"                    propagate_user_sharding=None, decode_shardings=True,\n                    sharding_rule=None, *, reduction_factors=(),\n                    need_replication_factors=(), permutation_factors=(),\n                    **factor_sizes):\n    self.partition = partition\n    self.propagate_user_sharding = propagate_user_sharding\n    self.infer_sharding_from_operands = infer_sharding_from_operands\n    self.decode_shardings = decode_shardings\n    if (sharding_rule is None or isinstance(sharding_rule, Callable) or\n        isinstance(sharding_rule, SdyShardingRule)):\n      sharding_rule_dict = factor_sizes\n      if len(reduction_factors) > 0:\n        sharding_rule_dict[\"reduction_factors\"] = reduction_factors\n      if len(need_replication_factors) > 0:\n        sharding_rule_dict[\"need_replication_factors\"] = need_replication_factors\n      if len(permutation_factors) > 0:\n        sharding_rule_dict[\"permutation_factors\"] = permutation_factors\n      if sharding_rule_dict:\n        raise ValueError(f\"Unknown keyword arguments: {sharding_rule_dict}\")\n      self.sharding_rule = sharding_rule\n    else:\n      self.sharding_rule = str_to_sdy_sharding_rule(\n          sharding_rule,\n          reduction_factors=reduction_factors,\n          need_replication_factors=need_replication_factors,\n          permutation_factors=permutation_factors,\n          **factor_sizes)\n    return partition\n\n  def __call__(self, *args, **kwargs):\n    args = _resolve_kwargs(self.fun, args, kwargs)\n    debug = api_util.debug_info(\"custom_partitioning\", self.fun,\n                                args, {},\n                                static_argnums=self.static_argnums)\n    if self.static_argnums:\n      static_argnums = set(self.static_argnums)\n      dyn_argnums = [i for i in range(len(args)) if i not in static_argnums]","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning.py#L479-L515","documentation":"In custom_partitioning's def_partition, when constructing an SdyShardingRule from user-supplied pieces, any leftover unsupported keyword entries in sharding_rule_dict raise ValueError. This happens when a rule definition contains options the installed SDY path does not accept.","triggerScenarios":"Building a sharding rule via def_partition with kwargs such as reduction_factors, need_replication_factors, or permutation_factors that end up unconsumed (e.g. combined with an explicit SdyShardingRule where they are not applicable).","commonSituations":"Mixing GSPMD-style factor arguments with the new sharding_rule API; version skew between JAX and the Shardy compiler.","solutions":["Remove reduction_factors / need_replication_factors / permutation_factors and express them in the sharding_rule itself","Pass those arguments only via str_to_sdy_sharding_rule when using a string rule, not alongside a prebuilt SdyShardingRule","Upgrade JAX so the rule options you need are supported"],"exampleFix":"# before\nrule = def_partition(infer_sharding_from_operands=..., reduction_factors=[...])\n\n# after\nrule = def_partition(sharding_rule='i j, j k -> i k')  # factors encoded in the rule string","handlingStrategy":"validation","validationCode":"allowed = {'reduction_factors','need_replication_factors','permutation_factors'}\n# only pass these when using a rule string, never with a prebuilt SdyShardingRule","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Encode factors in the sharding_rule string rather than extra kwargs","Pin JAX version to one matching your Shardy usage"],"tags":["jax","custom-partitioning","shardy","sharding-rule"],"backgroundTag":"invalid-sharding-rule-config","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}