CLAUDE: export L2 (Layer2Net step) to TorchScript for native LibTorch
Piece 1 of the native-JNA DNN path (no Python server). Adds export_l2_torchscript.py:
wraps a trained Layer2Net's cell+head into a single-step L2Step module
forward(x,h)->(h_new,det,vel) — exactly infer_server's per-scene recurrence
(h=cell(x,h); det,vel=decode(h)) — so the C++ side just carries h and calls it
per scene. Size-agnostic (circular pad + 1x1 head), runs on the full field.
Validated: scripted==eager exact (0.0); C++ LibTorch (libtorch_probe/l2_probe)
loads it on Blackwell CUDA and replays the recurrence with hidden-state match
9.5e-7. Required disabling the TorchScript JIT fuser (nvrtc element-wise fusion
fails on Blackwell -arch; production wants no runtime nvrtc) — folds into the
native lib startup in piece 2.
Co-Authored-By:
Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Showing
export_l2_torchscript.py
0 → 100644
Please register or sign in to comment