{"record":{"id":"0b8a8e7e56d67bdc","repo":"xai-org/x-algorithm","slug":"unknown-named-dimension-named-dim-for-namespace","errorCode":null,"errorMessage":"Unknown named dimension: {named_dim} for namespace: {namespace}","messagePattern":"Unknown named dimension: (.+?) for namespace: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/models/sharding_context.py","lineNumber":132,"sourceCode":"            ]\n        flattened_physical_axes, _ = jax.tree.flatten(physical_axes)\n        return axis_group_size(flattened_physical_axes, self.mesh)\n\n\nPerNamespaceShardingConfig = dict[str, ShardingSpec]\nShardingConfig = dict[str, PerNamespaceShardingConfig]\n\n\ndef make_sharding_context_from_config(\n    name: str, mesh: Mesh, config: ShardingConfig\n) -> ShardingContext:\n    ctx = ShardingContext(name, mesh)\n\n    def _sharding_rule(\n        named_dim: str, config: PerNamespaceShardingConfig = None, namespace: str = None\n    ) -> ShardingSpec:\n        if named_dim not in config:\n            raise ValueError(f\"Unknown named dimension: {named_dim} for namespace: {namespace}\")\n        return config[named_dim]\n\n    for namespace, c in config.items():\n        ctx.register_sharding_rule(namespace)(\n            partial(_sharding_rule, config=c, namespace=namespace)\n        )\n    return ctx\n\n\ndefault_sharding_config = {\n    \"default\": {\n        \"batch\": (\"expert\", \"replica\", \"data\"),\n        \"batch_attn\": (\"expert\", \"replica\", \"data\"),\n        \"dense_activation_model\": \"model\",\n        \"dense_activation_seq\": \"seq\",\n        \"embed\": None,\n        \"head\": (\"seq\", \"model\"),\n        \"hidden\": None,","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/models/sharding_context.py#L114-L150","documentation":"When building a ShardingSpec, _sharding_rule looks up the requested named dimension inside the per-namespace config dict. If the dimension name (e.g. 'in_dim') is absent from that namespace's config, it raises this ValueError naming both the dimension and the namespace.","triggerScenarios":"A layer asks for a named dim like 'out_dim' under namespace 'attention' but the sharding config for 'attention' only defines 'in_dim'; renaming a dimension in model code without updating the sharding config.","commonSituations":"Model refactors that rename tensor dimensions; configs written for a different model variant missing entries for some namespaces; typos in dimension names.","solutions":["Add the missing named dimension with its PartitionSpec to the namespace's config in the sharding config","Verify spelling/casing of the dimension against what the model code requests","If the dim should not be sharded, add an explicit entry mapping it to replicated (None)"],"exampleFix":"# before\nsharding:\n  attention:\n    in_dim: [\"data\"]\n# after\nsharding:\n  attention:\n    in_dim: [\"data\"]\n    out_dim: [\"model\"]","handlingStrategy":"validation","validationCode":"for ns, dims in cfg['sharding'].items():\n    assert required_dims[ns] <= set(dims), f'{ns} missing {required_dims[ns] - set(dims)}'","typeGuard":null,"tryCatchPattern":"try:\n    spec = rule(named_dim, config, namespace)\nexcept ValueError as e:\n    if 'Unknown named dimension' in str(e):\n        return None  # replicate\n    raise","preventionTips":["Keep dimension-name lists per layer next to the layer code","Fail fast in config validation listing required dims per namespace"],"tags":["sharding","config","jax","missing-key"],"backgroundTag":"missing-config-key","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}