{"record":{"id":"0957b61dc57b0767","repo":"tensorflow/models","slug":"the-bottleneck-size-intra-bottleneck-size-is-not","errorCode":null,"errorMessage":"The bottleneck size {intra_bottleneck_size} is not a multiple of the number of attention heads {num_attention_heads}.","messagePattern":"The bottleneck size (.+?) is not a multiple of the number of attention heads (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/nlp/modeling/layers/mobile_bert_layers.py","lineNumber":239,"sourceCode":"    Raises:\n      ValueError: A Tensor shape or parameter is invalid.\n    \"\"\"\n    super().__init__(**kwargs)\n    self.hidden_size = hidden_size\n    self.num_attention_heads = num_attention_heads\n    self.intermediate_size = intermediate_size\n    self.intermediate_act_fn = intermediate_act_fn\n    self.hidden_dropout_prob = hidden_dropout_prob\n    self.attention_probs_dropout_prob = attention_probs_dropout_prob\n    self.intra_bottleneck_size = intra_bottleneck_size\n    self.use_bottleneck_attention = use_bottleneck_attention\n    self.key_query_shared_bottleneck = key_query_shared_bottleneck\n    self.num_feedforward_networks = num_feedforward_networks\n    self.normalization_type = normalization_type\n    self.initializer = tf_keras.initializers.get(initializer)\n\n    if intra_bottleneck_size % num_attention_heads != 0:\n      raise ValueError(\n          (f'The bottleneck size {intra_bottleneck_size} is not a multiple '\n           f'of the number of attention heads {num_attention_heads}.'))\n    attention_head_size = int(intra_bottleneck_size / num_attention_heads)\n\n    self.block_layers = {}\n    # add input bottleneck\n    dense_layer_2d = tf_keras.layers.EinsumDense(\n        'abc,cd->abd',\n        output_shape=[None, self.intra_bottleneck_size],\n        bias_axes='d',\n        kernel_initializer=tf_utils.clone_initializer(self.initializer),\n        name='bottleneck_input/dense')\n    layer_norm = _get_norm_layer(self.normalization_type,\n                                 name='bottleneck_input/norm')\n    self.block_layers['bottleneck_input'] = [dense_layer_2d,\n                                             layer_norm]\n\n    if self.key_query_shared_bottleneck:","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/nlp/modeling/layers/mobile_bert_layers.py#L221-L257","documentation":"Error \"The bottleneck size {intra_bottleneck_size} is not a multiple of the number of attention heads {num_attention_heads}.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/nlp/modeling/layers/mobile_bert_layers.py:239 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}