xai-org/x-algorithm · error · ValueError
feature_prep_enabled (candidate project-then-sum) and enable
Error message
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).
What it means
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).
Source
Thrown at phoenix/xrex/models/recsys_two_tower_model.py:253
@configclass
class RecsysCandidateModelConfig(Config):
hash_table: HashTable
enable_linear_proj: bool = False
emb_table_width: int = 128
scale_config: ScaleConfig = ScaleConfig()
max_posts: int = 10_240_000
num_candidate_heads: int = 1
def make(
self,
sharding_context: ShardingContext,
*,
use_post_embedding: bool = True,
use_post_sid: bool = False,
use_project_then_sum: bool = False,
):
if use_project_then_sum and self.enable_linear_proj:
raise ValueError(
"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)."
)
return RecsysCandidateTower(
self,
sharding_context,
use_post_embedding=use_post_embedding,
use_post_sid=use_post_sid,
use_project_then_sum=use_project_then_sum,
)
def make_post_embeddings(self):
all_post_ids = jnp.arange(self.max_posts * 2).reshape(-1, 2).astype(jnp.int32)
all_author_ids = jnp.arange(self.max_posts * 2).reshape(-1, 2).astype(jnp.int32)
all_dataset_types = jnp.full(
(self.max_posts, 1), RetrievalDataset.PAD.value, dtype=jnp.int32View on GitHub (pinned to 24c60942c5)
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.
Example fix
# before config.enable_linear_proj = True tower = Tower.make(..., use_project_then_sum=True) # after config.enable_linear_proj = False tower = Tower.make(..., use_project_then_sum=True)
Defensive patterns
Strategy: validation
Validate before calling
assert not (use_project_then_sum and config.enable_linear_proj), "mutually exclusive combine modes"
Prevention
- Represent combine mode as a single enum field instead of two booleans.
- Validate tower construction args in a shared factory.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- enable_candidate_tower_linear_proj and feature_prep_enabled
- RMSNorm: when weight_decay_mask > 0 the layer is re-paramete
AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28).
Data as JSON: /api/errors/a2d30b865a65ddb3.
Report an issue: GitHub.