{"record":{"id":"1f5f31f9b103d90c","repo":"xai-org/x-algorithm","slug":"please-override-this-method-for-specific-attention","errorCode":null,"errorMessage":"Please override this method for specific attention impl.","messagePattern":"Please override this method for specific attention impl\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"phoenix/xrex/models/attention.py","lineNumber":76,"sourceCode":"        value: Optional[jax.Array],\n        segment_ids: Optional[jax.Array],\n        segment_ids_k: Optional[jax.Array],\n        temp: Optional[jax.Array],\n        **kwargs,\n    ):\n        return self.call_attn(query, key, value, segment_ids, segment_ids_k, temp, **kwargs)\n\n    def call_attn(\n        self,\n        query: jax.Array,\n        key: Optional[jax.Array],\n        value: Optional[jax.Array],\n        segment_ids: Optional[jax.Array],\n        segment_ids_k: Optional[jax.Array],\n        temp: Optional[jax.Array],\n        **kwargs,\n    ):\n        raise NotImplementedError(\"Please override this method for specific attention impl.\")\n\n\nclass CustomAttention(Attention):\n    def sharded_custom_op_with_extra_args(\n        self, **kwargs\n    ) -> tuple[Callable, dict[str, Callable[[str], NamedShape]]]:\n        raise NotImplementedError\n\n    def call_attn(self, query, key, value, segment_ids, segment_ids_k, temp, **kwargs):\n        assert self.sharding_context is not None\n\n        body_fn, extra_arg_shape_fns = self.sharded_custom_op_with_extra_args(**kwargs)\n        sharding_rule = functools.partial(\n            self.sharding_context.sharding_specs, namespace=self.config.attn_sharding_namespace\n        )\n\n        extra_args = []\n        extra_arg_shapes = []","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/phoenix/xrex/models/attention.py#L58-L94","documentation":"Attention.call_attn is the abstract dispatch method of the Attention base class in xrex.models.attention; the base implementation unconditionally raises NotImplementedError. Every concrete attention subclass (JaxAttention, PallasAttention, CustomAttention, ...) must override call_attn, and __call__ routes into it, so hitting this means a raw or incomplete Attention subclass was instantiated and invoked.","triggerScenarios":"Instantiating Attention (or a subclass that forgot to override call_attn) and calling it via __call__ with query/key/value arrays; registering a custom attention class whose method is named differently (e.g. call_attention) so the base stub runs.","commonSituations":"Adding a new attention kernel and misspelling the override method name; refactoring that renames call_attn in one subclass but not another; passing the base class as attn_class by accident in _get_attn_impl.","solutions":["Override call_attn(self, query, key, value, segment_ids, segment_ids_k, temp, **kwargs) in your subclass.","Check the subclass actually inherits from the intended base and the method signature matches.","Make the base class abstract (abc.abstractmethod) so instantiation fails earlier with a clearer error."],"exampleFix":"# before\nclass MyAttn(Attention):\n    def attention(self, q, k, v, **kw): ...\n\n# after\nclass MyAttn(Attention):\n    def call_attn(self, query, key, value, segment_ids, segment_ids_k, temp, **kwargs): ...","handlingStrategy":"type-guard","validationCode":"from xrex.models.attention import Attention\nassert type(attn).call_attn is not Attention.call_attn, \"call_attn not overridden\"","typeGuard":"def has_call_attn_override(cls) -> bool:\n    return cls.call_attn.__func__ is not Attention.__dict__[\"call_attn\"]","tryCatchPattern":null,"preventionTips":["Decorate Attention with abc.abstractmethod so subclasses fail at instantiation.","Add unit tests that call every registered attention impl once."],"tags":["attention","not-implemented","subclass-contract","jax"],"backgroundTag":"abstract-method-not-overridden","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}