{
  "scope": "Hand-set mechanics only, CPU float64, no text corpus/training/benchmark or guaranteed memory quality.",
  "environment": {
    "python": "3.10.12",
    "torch": "2.3.1+cu118",
    "device": "cpu",
    "dtype": "torch.float64"
  },
  "inputs": {
    "x": [
      0.6,
      -0.4
    ],
    "previous_hidden": [
      0.3,
      -0.2
    ],
    "previous_cell_lstm": [
      2.4,
      -1.8
    ],
    "batched_shapes": {
      "x": [
        1,
        2
      ],
      "h": [
        1,
        2
      ],
      "c": [
        1,
        2
      ]
    }
  },
  "lstm": {
    "gate_stack_order": [
      "i",
      "f",
      "g",
      "o"
    ],
    "parameters_column_orientation": {
      "i": {
        "W_i": [
          [
            0.4,
            -0.2
          ],
          [
            0.1,
            0.3
          ]
        ],
        "W_h": [
          [
            0.5,
            0.15
          ],
          [
            -0.25,
            0.4
          ]
        ],
        "b_i": [
          0.05,
          -0.1
        ],
        "b_h": [
          -0.02,
          0.03
        ]
      },
      "f": {
        "W_i": [
          [
            -0.3,
            0.2
          ],
          [
            0.25,
            -0.1
          ]
        ],
        "W_h": [
          [
            0.2,
            -0.35
          ],
          [
            0.15,
            0.3
          ]
        ],
        "b_i": [
          0.2,
          0.1
        ],
        "b_h": [
          0.04,
          -0.06
        ]
      },
      "g": {
        "W_i": [
          [
            0.2,
            0.5
          ],
          [
            -0.4,
            0.3
          ]
        ],
        "W_h": [
          [
            0.3,
            -0.2
          ],
          [
            0.4,
            0.1
          ]
        ],
        "b_i": [
          -0.1,
          0.05
        ],
        "b_h": [
          0.07,
          -0.03
        ]
      },
      "o": {
        "W_i": [
          [
            0.1,
            -0.3
          ],
          [
            0.2,
            0.4
          ]
        ],
        "W_h": [
          [
            -0.2,
            0.25
          ],
          [
            0.3,
            -0.15
          ]
        ],
        "b_i": [
          0.1,
          -0.05
        ],
        "b_h": [
          -0.04,
          0.02
        ]
      }
    },
    "preactivations": {
      "i": [
        0.47,
        -0.28500000000000003
      ],
      "f": [
        0.11000000000000001,
        0.21500000000000002
      ],
      "g": [
        0.01999999999999999,
        -0.24000000000000002
      ],
      "o": [
        0.13000000000000003,
        0.04999999999999996
      ]
    },
    "gate_values": {
      "i": [
        0.6153837563911821,
        0.4292283881055083
      ],
      "f": [
        0.5274723043445937,
        0.5535439031511183
      ],
      "g": [
        0.019997333759930923,
        -0.23549574953849794
      ],
      "o": [
        0.5324543063873187,
        0.5124973964842103
      ]
    },
    "retained_f_times_c": [
      1.2659335304270247,
      -0.9963790256720131
    ],
    "written_i_times_g": [
      0.012306034366994494,
      -0.10108146098010796
    ],
    "manual_c_new": [
      1.2782395647940192,
      -1.0974604866521211
    ],
    "manual_h_new": [
      0.45578896285862075,
      -0.4097852148962811
    ],
    "builtin_c_new": [
      1.2782395647940192,
      -1.0974604866521211
    ],
    "builtin_h_new": [
      0.4557889628586207,
      -0.4097852148962811
    ],
    "max_abs_cell_error": 0.0,
    "max_abs_hidden_error": 5.551115123125783e-17,
    "range_note": "i/f/o in(0,1),g/h in(-1,1); C itself is not bounded to(-1,1)."
  },
  "fixed_gate_direct_cell_path": {
    "scope": "Artificial C_t=f*C_prev with writes zero and fixed gate independent of states. Direct-path derivative only; NOT total full-LSTM gradient or task quality.",
    "series": [
      {
        "fixed_f": 0.9,
        "c_t_from_t0_to_t10": [
          1.0,
          0.9,
          0.81,
          0.7290000000000001,
          0.6561000000000001,
          0.5904900000000002,
          0.5314410000000002,
          0.47829690000000014,
          0.43046721000000016,
          0.38742048900000015,
          0.34867844010000015
        ],
        "direct_path_dc10_dc0": 0.34867844010000015,
        "closed_form_f_power_10": 0.3486784401000001
      },
      {
        "fixed_f": 0.2,
        "c_t_from_t0_to_t10": [
          1.0,
          0.2,
          0.04000000000000001,
          0.008000000000000002,
          0.0016000000000000005,
          0.00032000000000000013,
          6.400000000000002e-05,
          1.2800000000000006e-05,
          2.5600000000000013e-06,
          5.120000000000002e-07,
          1.0240000000000006e-07
        ],
        "direct_path_dc10_dc0": 1.0240000000000006e-07,
        "closed_form_f_power_10": 1.0240000000000006e-07
      }
    ]
  },
  "gru": {
    "gate_stack_order": [
      "r",
      "z",
      "n"
    ],
    "parameters_column_orientation": {
      "r": {
        "W_i": [
          [
            0.4,
            -0.3
          ],
          [
            -0.2,
            0.5
          ]
        ],
        "W_h": [
          [
            0.2,
            0.35
          ],
          [
            -0.4,
            0.1
          ]
        ],
        "b_i": [
          0.1,
          -0.15
        ],
        "b_h": [
          0.05,
          -0.02
        ]
      },
      "z": {
        "W_i": [
          [
            -0.1,
            0.2
          ],
          [
            0.3,
            0.15
          ]
        ],
        "W_h": [
          [
            0.4,
            -0.2
          ],
          [
            0.1,
            0.3
          ]
        ],
        "b_i": [
          -0.05,
          0.08
        ],
        "b_h": [
          0.03,
          -0.04
        ]
      },
      "n": {
        "W_i": [
          [
            0.25,
            -0.4
          ],
          [
            0.3,
            0.2
          ]
        ],
        "W_h": [
          [
            0.6,
            -0.5
          ],
          [
            0.4,
            0.3
          ]
        ],
        "b_i": [
          0.07,
          -0.09
        ],
        "b_h": [
          0.2,
          -0.15
        ]
      }
    },
    "reset_r": [
      0.6224593312018546,
      0.34751053780725555
    ],
    "update_z": [
      0.5,
      0.5324543063873187
    ],
    "input_candidate_affine": [
      0.38000000000000006,
      0.009999999999999981
    ],
    "recurrent_h_projection_without_bias": [
      0.28,
      0.06
    ],
    "reset_before_recurrent_projection": [
      0.14679373339705937,
      0.05384448747578721
    ],
    "d2l_equivalent_single_candidate_bias": [
      0.27,
      -0.24
    ],
    "reset_before_candidate_preactivation": [
      0.7267937333970593,
      -0.0861555125242128
    ],
    "reset_after_candidate_preactivation": [
      0.6787804789768903,
      -0.021275948402653018
    ],
    "reset_before_candidate": [
      0.6210998693740931,
      -0.08594297263760514
    ],
    "reset_after_candidate": [
      0.5907260070215555,
      -0.021272738684476083
    ],
    "reset_before_hidden": [
      0.4605499346870465,
      -0.14667312803044855
    ],
    "manual_pytorch_hidden": [
      0.44536300351077773,
      -0.11643683864073844
    ],
    "builtin_pytorch_hidden": [
      0.44536300351077773,
      -0.11643683864073845
    ],
    "max_abs_builtin_manual_error": 1.3877787807814457e-17,
    "max_abs_variant_hidden_difference": 0.03023628938971011,
    "preactivation_difference_matrix_noncommutation": [
      0.027494879339459932,
      -0.03299385520735188
    ],
    "preactivation_difference_bias_placement": [
      -0.07550813375962909,
      0.09787341932891165
    ],
    "variant_note": "Reset-before uses W_hn(r*h)+b_hn; PyTorch uses r*(W_hn*h+b_hn). Same r/z/weights/input; differences are matrix order AND bias placement, not precision error."
  },
  "fixed_z_interpolation": {
    "scope": "Artificial z substitution with same fixed old hidden/candidate; not a trained gate or probability of remembering.",
    "cases": [
      {
        "artificial_fixed_z": 0.99,
        "mixed_hidden": [
          0.30290726007021557,
          -0.19821272738684478
        ],
        "max_distance_to_old_hidden": 0.002907260070215578,
        "max_distance_to_candidate": 0.28781874695133997
      },
      {
        "artificial_fixed_z": 0.01,
        "mixed_hidden": [
          0.58781874695134,
          -0.02306001129763132
        ],
        "max_distance_to_old_hidden": 0.28781874695133997,
        "max_distance_to_candidate": 0.002907260070215578
      }
    ]
  },
  "checks": "PASS: Python LSTM vs nn.LSTMCell; ranges; isolated fixed-f path autograd; GRU variants differ; Python reset-after vs nn.GRUCell; difference decomposition; z-near1 preserves old hidden."
}
