{"record":{"id":"620d11df0d043e40","repo":"xai-org/x-algorithm","slug":"unknown-scaling-role-role-r","errorCode":null,"errorMessage":"unknown scaling role: {role!r}","messagePattern":"unknown scaling role: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/models/recsys_feature_prep.py","lineNumber":255,"sourceCode":"def _feature_scale_spec(\n    scale_config: ScaleConfig | None,\n    embed_init_scale: float,\n    model_width: int,\n    role: Literal[\"embedding\", \"hidden_proj\", \"input_proj\"],\n    dim: int,\n) -> tuple[float, float]:\n    eis = embed_init_scale\n    D = model_width\n    if role == \"embedding\":\n        lr = scale_config.emb_lr_multiplier(dim) if scale_config is not None else 1.0\n        return eis / math.sqrt(dim), lr\n    if role == \"hidden_proj\":\n        lr = scale_config.hidden_lr_multiplier(dim) if scale_config is not None else 1.0\n        return eis / math.sqrt(dim), lr\n    if role == \"input_proj\":\n        lr = scale_config.emb_lr_multiplier(D) if scale_config is not None else 1.0\n        return eis / math.sqrt(dim * D), lr\n    raise ValueError(f\"unknown scaling role: {role!r}\")\n\n\ndef _get_proj(\n    name: str,\n    in_dim: int,\n    out_dim: int,\n    config: FeaturePrepConfig,\n    *,\n    role: Literal[\"hidden_proj\", \"input_proj\"],\n) -> jax.Array:\n    embed_init = hk.initializers.VarianceScaling(1.0, mode=\"fan_out\")\n    _, lr_multiplier = _feature_scale_spec(\n        config.scale_config, config.embed_init_scale, config.emb_size, role, in_dim\n    )\n    return typing.cast(\n        jax.Array,\n        get_parameter(\n            name,","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/models/recsys_feature_prep.py#L237-L273","documentation":"_feature_scale_spec computes per-role init scales and LR multipliers for exactly two roles: 'hidden_proj' (eis / sqrt(dim)) and 'input_proj' (eis / sqrt(dim * D)). Callers (_get_proj, _get_emb_table, _get_learned_vector, _embed_entity_sid_scaled) pass the role string; anything else is an unknown scaling role and raises ValueError.","triggerScenarios":"Adding a new projection/embedding path that calls _feature_scale_spec with role=\"output_proj\" or similar without extending the function; typos like \"hiddenproj\".","commonSituations":"Extending the recsys feature-prep code with new towers; refactors that rename roles in one place but not the spec table.","solutions":["Use role='hidden_proj' or 'input_proj' as appropriate for your call site.","Fix typos in the role string at the caller.","Extend _feature_scale_spec with the new role and its scale/LR formulas before using it."],"exampleFix":"# before\n_feature_scale_spec(\"hiddenproj\", dim, D, eis, scale_config)\n\n# after\n_feature_scale_spec(\"hidden_proj\", dim, D, eis, scale_config)","handlingStrategy":"validation","validationCode":"assert role in {\"hidden_proj\", \"input_proj\"}, role","typeGuard":"def is_valid_scaling_role(r: str) -> bool:\n    return r in {\"hidden_proj\", \"input_proj\"}","tryCatchPattern":null,"preventionTips":["When extending feature prep, update _feature_scale_spec in the same change as new callers."],"tags":["feature-prep","scaling","role-validation","internal-api"],"backgroundTag":"invalid-argument-value","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}