{"record":{"id":"8dcfb54dfa1d02ee","repo":"jax-ml/jax","slug":"factor-factor-in-kind-is-not-used-in-the-rule","errorCode":null,"errorMessage":"Factor {factor} in {kind} is not used in the rule","messagePattern":"Factor (.+?) in (.+?) is not used in the rule","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"jax/_src/custom_partitioning_sharding_rule.py","lineNumber":170,"sourceCode":"        raise ValueError(\n          f\"Factor {factor} is only used in compound factors; must specify\"\n          \" its size\")\n      if factor in factor_sizes and inferable:\n        raise ValueError(\n          f\"Factor {factor} represents a whole dimension; do not specify its\"\n          \" size\")\n\n    special_factors = set()\n    def check_special_factors(kind, factors):\n      if not isinstance(factors, tuple):\n        raise ValueError(f\"{kind} must be a tuple of factors\")\n\n      if len(factors) != len(set(factors)):\n        raise ValueError(f\"{kind} contains duplicated factors\")\n\n      for factor in factors:\n        if factor not in factors_inferrable:\n          raise ValueError(\n            f\"Factor {factor} in {kind} is not used in the rule\")\n        if factor in special_factors:\n          raise ValueError(f\"Factor {factor} can only be in one of the \"\n              f\"reduction, need replication, or permutation factor sets.\")\n        special_factors.add(factor)\n\n    check_special_factors(\"reduction_factors\", reduction_factors)\n    check_special_factors(\"need_replication_factors\", need_replication_factors)\n    check_special_factors(\"permutation_factors\", permutation_factors)\n\n    self.operand_mappings = operand_mappings\n    self.result_mappings = result_mappings\n    self.factor_sizes = factor_sizes\n    self.reduction_factors = reduction_factors\n    self.need_replication_factors = need_replication_factors\n    self.permutation_factors = permutation_factors\n\n","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/custom_partitioning_sharding_rule.py#L152-L188","documentation":"Every factor listed in reduction_factors / need_replication_factors / permutation_factors must actually appear in the rule string. This check fires when a special factor is nowhere in operands or results.","triggerScenarios":"rule='(i,j)->(i,j)' with permutation_factors=('m',) — 'm' never occurs in the rule.","commonSituations":"Renaming rule factors without updating the special-factor tuples; typos in factor names.","solutions":["Remove the factor from the special-factor tuple or fix its name to match the rule","Cross-check each special factor against tokens in the rule string"],"exampleFix":"# before\nrule='(i,j)->(i,j)', permutation_factors=('m',)\n# after\nrule='(i,j,m)->(i,j)', permutation_factors=('m',)","handlingStrategy":"validation","validationCode":"import re\nused = set(re.findall(r'[A-Za-z_][A-Za-z0-9_]*', rule))\nassert set(reduction_factors) <= used and set(need_replication_factors) <= used and set(permutation_factors) <= used","typeGuard":"def special_factors_in_rule(rule: str, *sets) -> bool:\n    used = set(re.findall(r'[A-Za-z_][A-Za-z0-9_]*', rule))\n    return all(set(s) <= used for s in sets)","tryCatchPattern":null,"preventionTips":["Single source of truth: define factor names once and compose both rule and special sets from it"],"tags":["jax","sharding","unknown-factor","validation"],"backgroundTag":"unknown-name-in-config","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}