{
  "scope": "Four hand-set token embeddings; sinusoidal absolute positions; one hand-parameterized causal MHA layer; LayerNorm/residual arithmetic. No training, corpus, KV cache, GPU, latency, or quality benchmark.",
  "environment": {
    "python": "3.10.12",
    "torch": "2.3.1+cu118",
    "device": "cpu",
    "dtype": "float64",
    "torch_threads": 1,
    "batch_first": true,
    "mha_dropout": 0.0,
    "mha_eval": true,
    "mha_bool_attn_mask_true_means": "blocked",
    "need_weights": true,
    "average_attn_weights": false
  },
  "dimensions": {
    "batch": 1,
    "sequence_length": 4,
    "d_model": 4,
    "num_heads": 2,
    "head_dim": 2,
    "embeddings": [
      1,
      4,
      4
    ],
    "position_encoding": [
      4,
      4
    ],
    "positioned_embeddings": [
      1,
      4,
      4
    ],
    "causal_mask": [
      4,
      4
    ],
    "full_output": [
      1,
      4,
      4
    ],
    "per_head_weights": [
      1,
      2,
      4,
      4
    ],
    "postnorm": [
      1,
      4,
      4
    ],
    "prenorm": [
      1,
      4,
      4
    ]
  },
  "position_encoding": {
    "absolute_position_ids": [
      0,
      1,
      2,
      3
    ],
    "formula": "PE[pos,2i]=sin(pos/10000^(2i/d_model)); PE[pos,2i+1]=cos(pos/10000^(2i/d_model))",
    "embedding_scale": "sqrt(d_model)",
    "pe_rows": [
      [
        0.0,
        1.0,
        0.0,
        1.0
      ],
      [
        0.8414709848,
        0.5403023059,
        0.0099998333,
        0.9999500004
      ],
      [
        0.9092974268,
        -0.4161468365,
        0.0199986667,
        0.9998000067
      ],
      [
        0.1411200081,
        -0.9899924966,
        0.0299955002,
        0.9995500337
      ]
    ],
    "positioned_input_first_token": [
      0.4,
      0.8,
      0.6,
      1.8
    ],
    "offset_check_positions": [
      2,
      3
    ],
    "offset_pe_max_diff_vs_full_sequence_rows_2_3": 0.0,
    "incorrect_reset_to_positions_0_1_max_diff": 1.5302948024685852
  },
  "causal_mask": {
    "true_means": "block this query-key pair for torch.nn.MultiheadAttention 2.3",
    "matrix": [
      [
        false,
        true,
        true,
        true
      ],
      [
        false,
        false,
        true,
        true
      ],
      [
        false,
        false,
        false,
        true
      ],
      [
        false,
        false,
        false,
        false
      ]
    ],
    "diagonal_is_visible": true,
    "full_sequence_output": [
      [
        0.335,
        0.3,
        0.824,
        -0.072
      ],
      [
        0.3864675178,
        0.0709886656,
        0.6591179741,
        0.1377794748
      ],
      [
        0.5078298162,
        -0.0085061378,
        0.4146681244,
        0.1774231196
      ],
      [
        0.3942013879,
        0.1882527702,
        0.4487686007,
        -0.0348606446
      ]
    ],
    "per_head_attention_weights": [
      [
        [
          1.0,
          0.0,
          0.0,
          0.0
        ],
        [
          0.500194179,
          0.499805821,
          0.0,
          0.0
        ],
        [
          0.3857284667,
          0.3199199864,
          0.2943515469,
          0.0
        ],
        [
          0.1941734141,
          0.15272561,
          0.4121225338,
          0.2409784421
        ]
      ],
      [
        [
          1.0,
          0.0,
          0.0,
          0.0
        ],
        [
          0.5557242177,
          0.4442757823,
          0.0,
          0.0
        ],
        [
          0.2415567838,
          0.3848376998,
          0.3736055164,
          0.0
        ],
        [
          0.2426149218,
          0.2903960791,
          0.3155457094,
          0.1514432897
        ]
      ]
    ],
    "per_query_key_weight_sums": [
      [
        1.0,
        1.0,
        1.0,
        1.0
      ],
      [
        1.0,
        1.0,
        1.0,
        1.0
      ]
    ],
    "max_weight_on_blocked_future_positions": 0.0,
    "full_masked_pass_vs_independent_prefix_recomputation_max_diff": 1.1102230246251565e-16,
    "earlier_output_change_after_perturbing_future_token_max_diff": 0.0,
    "prefix_recomputation_note": "Each prefix is rerun from scratch at its original position IDs; this is not cached decoding or a speed comparison."
  },
  "residual_and_layernorm": {
    "post_norm_formula": "LayerNorm(x + Sublayer(x))",
    "pre_norm_formula": "x + Sublayer(LayerNorm(x))",
    "chosen_demo_path": "post_norm",
    "residual_sum": [
      [
        0.735,
        1.1,
        1.424,
        1.728
      ],
      [
        0.6279385026,
        1.6112909715,
        0.8691178074,
        0.7377294752
      ],
      [
        2.217127243,
        -0.0246529744,
        -0.5653332089,
        1.3772231263
      ],
      [
        0.335321396,
        -1.6017397264,
        0.8787641009,
        1.5646893891
      ]
    ],
    "epsilon": 1e-05,
    "normalized_axis": -1,
    "variance_convention": "biased variance (unbiased=False) across the final d_model feature axis for each token",
    "gamma": [
      1.1,
      0.9,
      1.2,
      0.8
    ],
    "beta": [
      0.1,
      -0.2,
      0.05,
      0.3
    ],
    "postnorm_output": [
      [
        -1.422973348,
        -0.5573241639,
        0.6254522026,
        1.3416036577
      ],
      [
        -0.8536996821,
        1.3199223851,
        -0.2381892431,
        -0.1653161892
      ],
      [
        1.5605999776,
        -0.8323461193,
        -1.3807739785,
        0.7536802292
      ],
      [
        0.1383387142,
        -1.6483677688,
        0.6453441038,
        1.1626592463
      ]
    ],
    "postnorm_feature_means_after_affine": [
      -0.0033104129,
      0.0156793177,
      0.0252900273,
      0.0744935739
    ],
    "postnorm_feature_variances_after_affine_biased": [
      1.1316275924,
      0.638519611,
      1.4000711695,
      1.1205755665
    ],
    "manual_layernorm_max_diff": 2.220446049250313e-16,
    "pre_vs_post_norm_max_diff_same_demo_parameters": 1.6793967211269867
  },
  "checks": "PASS: explicit positions retain absolute offsets; MHA future-mask weights are zero; full causal sequence rows match same-token prefix recomputation; changing a future token leaves earlier outputs unchanged; post-norm LayerNorm matches manual final-feature-axis biased-variance computation; pre-norm and post-norm outputs differ."
}
