{"record":{"id":"a2d30b865a65ddb3","repo":"xai-org/x-algorithm","slug":"feature-prep-enabled-candidate-project-then-sum","errorCode":null,"errorMessage":"feature_prep_enabled (candidate project-then-sum) and enable_linear_proj are mutually exclusive; enable at most one candidate-tower combine mode (or neither for mean-pool).","messagePattern":"feature_prep_enabled \\(candidate project-then-sum\\) and enable_linear_proj are mutually exclusive; enable at most one candidate-tower combine mode \\(or neither for mean-pool\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/models/recsys_two_tower_model.py","lineNumber":253,"sourceCode":"@configclass\nclass RecsysCandidateModelConfig(Config):\n    hash_table: HashTable\n    enable_linear_proj: bool = False\n    emb_table_width: int = 128\n    scale_config: ScaleConfig = ScaleConfig()\n    max_posts: int = 10_240_000\n    num_candidate_heads: int = 1\n\n    def make(\n        self,\n        sharding_context: ShardingContext,\n        *,\n        use_post_embedding: bool = True,\n        use_post_sid: bool = False,\n        use_project_then_sum: bool = False,\n    ):\n        if use_project_then_sum and self.enable_linear_proj:\n            raise ValueError(\n                \"feature_prep_enabled (candidate project-then-sum) and \"\n                \"enable_linear_proj are mutually exclusive; enable at most one \"\n                \"candidate-tower combine mode (or neither for mean-pool).\"\n            )\n\n        return RecsysCandidateTower(\n            self,\n            sharding_context,\n            use_post_embedding=use_post_embedding,\n            use_post_sid=use_post_sid,\n            use_project_then_sum=use_project_then_sum,\n        )\n\n    def make_post_embeddings(self):\n        all_post_ids = jnp.arange(self.max_posts * 2).reshape(-1, 2).astype(jnp.int32)\n        all_author_ids = jnp.arange(self.max_posts * 2).reshape(-1, 2).astype(jnp.int32)\n        all_dataset_types = jnp.full(\n            (self.max_posts, 1), RetrievalDataset.PAD.value, dtype=jnp.int32","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/models/recsys_two_tower_model.py#L235-L271","documentation":"RecsysCandidateTower.make offers three candidate combine modes: feature_prep project-then-sum (use_project_then_sum=True), a shared linear projection (enable_linear_proj on the parent config), and the default mean-pool. Enabling both projections at once is ambiguous, so make raises ValueError telling you to pick at most one (or neither).","triggerScenarios":"Constructing the two-tower model with feature_prep_enabled=true in config (which sets use_project_then_sum) while enable_linear_proj is also true, or passing use_project_then_sum=True explicitly alongside a config with enable_linear_proj.","commonSituations":"Turning on the newer project-then-sum path while an old config still sets enable_linear_proj; merging config overlays that each enable one mode.","solutions":["Set enable_linear_proj=false when using project-then-sum (feature_prep).","Or keep enable_linear_proj=true and pass use_project_then_sum=False.","Set both off for the default mean-pool combine."],"exampleFix":"# before\nconfig.enable_linear_proj = True\ntower = Tower.make(..., use_project_then_sum=True)\n\n# after\nconfig.enable_linear_proj = False\ntower = Tower.make(..., use_project_then_sum=True)","handlingStrategy":"validation","validationCode":"assert not (use_project_then_sum and config.enable_linear_proj), \"mutually exclusive combine modes\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Represent combine mode as a single enum field instead of two booleans.","Validate tower construction args in a shared factory."],"tags":["two-tower","candidate-tower","mutually-exclusive","config-constraint"],"backgroundTag":"invalid-config-combination","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}