{"record":{"id":"ab214fb8fe3a11cb","repo":"google-research/timesfm","slug":"layer-norm-config-attention-norm-not-supported","errorCode":null,"errorMessage":"Layer norm: {config.attention_norm} not supported.","messagePattern":"Layer norm: (.+?) not supported\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/timesfm/flax/transformer.py","lineNumber":301,"sourceCode":"      deterministic=deterministic,\n      module=self if sow_weights else None,\n    )\n    # back to the original inputs dimensions\n    out = self.out(x)\n    return out, decode_cache\n\n\nclass Transformer(nnx.Module):\n  \"\"\"Classic Transformer used in TimesFM.\"\"\"\n\n  def __init__(self, config: TransformerConfig, *, rngs=nnx.Rngs(42)):\n    self.config = config\n\n    if config.attention_norm == \"rms\":\n      self.pre_attn_ln = RMSNorm(num_features=config.model_dims, rngs=rngs)\n      self.post_attn_ln = RMSNorm(num_features=config.model_dims, rngs=rngs)\n    else:\n      raise ValueError(f\"Layer norm: {config.attention_norm} not supported.\")\n\n    self.attn = MultiHeadAttention(\n      num_heads=config.num_heads,\n      in_features=config.model_dims,\n      use_per_dim_scale=True,\n      use_rotary_position_embeddings=config.use_rotary_position_embeddings,\n      qk_norm=config.qk_norm,\n      rngs=rngs,\n    )\n\n    if config.feedforward_norm == \"rms\":\n      self.pre_ff_ln = RMSNorm(num_features=config.model_dims, rngs=rngs)\n      self.post_ff_ln = RMSNorm(num_features=config.model_dims, rngs=rngs)\n    else:\n      raise ValueError(f\"Layer norm: {config.feedforward_norm} not supported.\")\n    self.ff0 = nnx.Linear(\n      in_features=config.model_dims,\n      out_features=config.hidden_dims,","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/google-research/timesfm/blob/331c6d33cb1ac2611de3056d0ac7164aab6301eb/src/timesfm/flax/transformer.py#L283-L319","documentation":"The transformer block only implements 'rms' (RMSNorm) for attention pre/post layer normalization; any other config.attention_norm value raises this ValueError in __init__. Unlike a flexible enum, there is exactly one accepted value in this code path.","triggerScenarios":"Constructing the transformer with config.attention_norm set to 'layer_norm', 'layernorm', 'ln', 'none', or None instead of 'rms'.","commonSituations":"Porting configs from other transformer stacks that default to LayerNorm, hand-editing configs expecting more norm options, or typos like 'RMS' (case-sensitive comparison).","solutions":["Set config.attention_norm to 'rms' (exact string, lowercase).","If LayerNorm is needed, add an elif branch constructing nnx.LayerNorm in transformer.py.","Confirm the config source doesn't inject a default like 'layer_norm' when the key is absent."],"exampleFix":"// before\nconfig = TransformerConfig(attention_norm=\"layer_norm\")  # ValueError\n// after\nconfig = TransformerConfig(attention_norm=\"rms\")","handlingStrategy":"validation","validationCode":"if config.attention_norm != \"rms\":\n    raise ValueError(f\"attention_norm must be 'rms', got {config.attention_norm!r}\")","typeGuard":"def has_supported_attention_norm(cfg) -> bool:\n    return getattr(cfg, \"attention_norm\", None) == \"rms\"","tryCatchPattern":"try:\n    block = TransformerBlock(config)\nexcept ValueError as e:\n    if \"attention_norm\" in str(e) or \"Layer norm\" in str(e):\n        config.attention_norm = \"rms\"\n        block = TransformerBlock(config)\n    else:\n        raise","preventionTips":["Use Literal[\"rms\"] typing (or an enum) for attention_norm in the config class.","Never copy norm names from other frameworks without mapping them first.","Pin the config default to \"rms\" explicitly."],"tags":["config","validation","layernorm","valueerror"],"backgroundTag":"unsupported-config-value","analyzedSha":"331c6d33cb1ac2611de3056d0ac7164aab6301eb","analyzedAt":"2026-08-29T01:04:23.138Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}