AsianPlayer/TriDrive / code /models /kpf_inject.py
AsianPlayer's picture
download
raw
1.36 kB
"""cwm3/models/kpf_inject.py — LANE F1 distillation injector (R2 WP4 batch 2; pre-registration docs/decisions.md 2026-09-17T19:33:12Z).
KpfInject: the DETACHED keypoint-forecaster channel (models/kp_forecaster.kpf_channel: 6 future-state probabilities, 3 trajectory-mode probabilities, valid bit;
never mean coordinates) -> LN(10) -> Linear(10 -> 64) -> GELU -> ZERO-initialised Linear(64 -> d_u) added as a residual on the driver state h_u of CWM3Joint.
Created LAST in the joint model so every existing parameter keeps its paired seed init; at init the residual is exactly 0 -> the joint forward is bitwise the
FINAL / ECAN model's (tests/test_kp_forecaster.py::test_inject_identity_at_init). Rows without a forecaster output carry an all-zero channel (valid bit 0).
"""
from __future__ import annotations
import torch
import torch.nn as nn
class KpfInject(nn.Module):
def __init__(self, d_in=10, d_out=128, hidden=64):
super().__init__()
self.ln = nn.LayerNorm(d_in)
self.fc1 = nn.Linear(d_in, hidden)
self.fc2 = nn.Linear(hidden, d_out)
nn.init.zeros_(self.fc2.weight)
nn.init.zeros_(self.fc2.bias)
def forward(self, kpf): # kpf [B,d_in] (f16 / f32) -> residual [B,d_out]
return self.fc2(torch.nn.functional.gelu(self.fc1(self.ln(kpf.float()))))

Xet Storage Details

Size:
1.36 kB
·
Xet hash:
38b42e4a7cd4806761586517c0f6e91c523a68280168daf875d905f9c6c275ae

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.