HaiwangYu commited on
Commit
a209d8a
·
verified ·
1 Parent(s): 3bff02c

Upload README.md

Browse files
Files changed (1) hide show
  1. dnn-roi/pdhd/20260615/README.md +120 -0
dnn-roi/pdhd/20260615/README.md ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PDHD DNN-ROI TorchScript models
2
+
3
+ TorchScript (`.ts`) models loaded by the wire-cell-toolkit DNN-ROI nodes
4
+ (`DNNROIFinding` / `DNNROIFindingMultiPlane`). All are exported with
5
+ `DNN_ROI_SP/scripts/to_torchscript.py` and output `sigmoid` probabilities
6
+ in `[0, 1]` (no extra sigmoid needed in Wire-Cell).
7
+
8
+ | file | input ch | precision | size | run with |
9
+ |---|---|---|---|---|
10
+ | `CP43.ts` | 3 | FP32 | 20.4 MB | `run_nf_sp_dnnroi_evt.sh -n 3` (default) |
11
+ | `kd_mbv3_transformer_bnKD_6ch.ts` | 6 | FP32 | 20.4 MB | `run_nf_sp_dnnroi_evt.sh -n 6` |
12
+ | `qat_mbv3_transformer_bnKD_6ch_int8.ts` | 6 | INT8 (QAT) | 10.8 MB | `run_nf_sp_dnnroi_evt.sh -n 6 -D cpu` |
13
+ | `pipe_base_mbv3_6ch.ts` | 6 | FP32 | 20.4 MB | `run_nf_sp_dnnroi_evt.sh -n 6` |
14
+ | `pipe_distill_transformer_6ch.ts` | 6 | FP32 | 20.4 MB | `run_nf_sp_dnnroi_evt.sh -n 6` |
15
+ | `pipe_qat_transformer_6ch_int8.ts` | 6 | INT8 (QAT) | 10.8 MB | `run_nf_sp_dnnroi_evt.sh -n 6 -D cpu` |
16
+
17
+ ## Provenance
18
+
19
+ | field | `CP43.ts` | `kd_..._6ch.ts` | `qat_..._6ch_int8.ts` |
20
+ |---|---|---|---|
21
+ | Architecture | MobileNetV3-large UNet | MobileNetV3-large UNet | QuantizableMobileNetV3-UNet, INT8 |
22
+ | Source repo | `DNN_ROI_SP/` | `DNN_ROI_SP/` | `DNN_ROI_SP/` |
23
+ | Run-id | `bs1_20260511-210525` | `distill_mbv3_transformer_bnKD_6ch_th150_ep100_l40s_ddp2` | `qat_distill_mbv3_transformer_bnKD_6ch_th150_ep20_l40s_ddp2` |
24
+ | Checkpoint | `CP43.pth` | `CP70.pth` | `qat_int8_state.pth` |
25
+ | Training | 3-ch baseline | Transformer teacher + bottleneck-feature KD | QAT-KD-C, warm-started from `CP70.pth` |
26
+ | TorchScript mode | trace | trace | trace |
27
+ | Held-out test Dice / ROI-eff | — | 0.9118 / 0.7609 | 0.8932 / 0.7274 |
28
+
29
+ `to_torchscript.py` falls back to `torch.jit.trace` because `torch.jit.script`
30
+ hits the `break` in the encoder loop; the INT8 quantized graph also cannot be
31
+ scripted. The traced UNets are fully convolutional and run at both the
32
+ per-plane (`800`) and stacked (`1600`) channel heights.
33
+
34
+ ### Pipeline-reproduced models (2026-05-16)
35
+
36
+ `pipe_base_mbv3_6ch.ts`, `pipe_distill_transformer_6ch.ts`, and
37
+ `pipe_qat_transformer_6ch_int8.ts` are the three models deployed by the
38
+ end-to-end run documented in `DNN_ROI_SP/docs/full_pipeline.md` — a baseline,
39
+ the best distillation, and its QAT INT8 model, all 6-channel and trained on the
40
+ same corpus and split.
41
+
42
+ | field | `pipe_base_mbv3_6ch.ts` | `pipe_distill_transformer_6ch.ts` | `pipe_qat_transformer_6ch_int8.ts` |
43
+ |---|---|---|---|
44
+ | Architecture | MobileNetV3-large UNet | MobileNetV3-large UNet | QuantizableMobileNetV3-UNet, INT8 |
45
+ | Run-id | `pipe_base_mbv3_6ch` | `pipe_distill_transformer_6ch` | `pipe_qat_transformer_6ch` |
46
+ | Training | 6-ch baseline, no KD | Transformer teacher + bottleneck-feature KD | QAT-KD, warm-started from the distillation |
47
+ | Held-out test Dice / ROI-eff | 0.9120 / 0.7474 | 0.9107 / 0.7454 | 0.8900 / 0.7305 |
48
+
49
+ All three pass the toolkit-vs-standalone replay validation (max abs diff
50
+ < 1.4e-6; the INT8 model bit-exact) — see `full_pipeline.md` §4.3.
51
+
52
+ ## Input layout
53
+
54
+ C++ tensor order is `(batch=1, ntags, nchannels, nticks)`:
55
+
56
+ - `nchannels` = `800` per plane in per-plane (`pp`) mode, or `1600`
57
+ (U+V stacked) in stacked (`mp`) mode. The W collection plane is not consumed.
58
+ - `nticks` = `1500`, from PDHD's raw `6000` after `tick_per_slice=4`
59
+ downsampling inside the C++ node.
60
+
61
+ **3-channel model** (`CP43.ts`) — `ntags=3`, in order:
62
+
63
+ ```
64
+ loose_lf{APA}, mp2_roi{APA}, mp3_roi{APA}
65
+ ```
66
+
67
+ **6-channel models** — `ntags=6`, in order:
68
+
69
+ ```
70
+ loose_lf{APA}, mp2_roi{APA}, mp3_roi{APA}, tight_lf{APA}, decon_charge{APA}, gauss{APA}
71
+ ```
72
+
73
+ All six tags are emitted by the standard PDHD `OmnibusSigProc` chain
74
+ (debug + multi-plane-protection mode) and require no SP-config change.
75
+
76
+ ## Per-channel normalization (6-ch models)
77
+
78
+ The 6-ch models are trained on inputs divided by **per-channel** z-scales:
79
+
80
+ ```
81
+ [944.6256, 4000.0, 4000.0, 803.7348, 1927.6997, 530.75]
82
+ ```
83
+
84
+ Wire-Cell's `DNNROIFinding` can only apply one **scalar** `input_scale` to all
85
+ channels, so the per-channel division is **baked into the `.ts` module** as a
86
+ fixed normalization layer. Consequently the 6-ch models must run with
87
+ `input_scale = 1.0` — the `run_nf_sp_dnnroi_evt.sh -n 6` path sets this
88
+ automatically (`dnnroi_pp.jsonnet`). `CP43.ts` keeps the C++ default
89
+ `input_scale = 1/4000`.
90
+
91
+ ## Tick padding
92
+
93
+ The C++ node rebins the time axis by `tick_per_slice=4` before inference and
94
+ needs the input tick count to be a multiple of the model's stride alignment.
95
+ For the PDHD MobileNetV3-large UNet (no deep stride-2 cascade in the tick
96
+ axis: post-rebin width 1500 = 4·375 is not divisible by 8 or higher powers
97
+ of 2), the alignment requirement is just `nticks % tick_per_slice == 0`,
98
+ i.e. **`nticks` must be a multiple of 4**. PDHD's standard `nticks=6000`
99
+ satisfies this with no padding.
100
+
101
+ The `dnnroi_pp.jsonnet` for PDHD leaves `tick_pad_multiple` unset (defaults
102
+ to `tick_per_slice=4`). The C++ node pads to the next 4-multiple before
103
+ inference, then crops back to `input_ticks` — a no-op for any
104
+ `nticks % 4 == 0` (including 6000, 6400, 8000).
105
+
106
+ ## Consumer
107
+
108
+ Loaded by the toolkit C++ node `DNNROIFinding` (per-plane sequential: U
109
+ and V each run their own forward call sharing one TorchService). Wired by
110
+ `cfg/pgrapher/experiment/pdhd/dnnroi_pp.jsonnet`; driven by
111
+ `wcp-porting-img/pdhd/run_nf_sp_dnnroi_evt.sh` (`-n 3|6` selects the
112
+ input-channel set, `-M <model>` selects the `.ts`).
113
+
114
+ ## Limitations
115
+
116
+ - Trained on **APA0 only**. Inference on APAs 1–3 is out-of-domain.
117
+ - W plane is not processed; downstream jsonnet routes it through a
118
+ `PlaneSelector` passthrough.
119
+ - The INT8 QAT model runs on **CPU only** (x86/fbgemm quantized backend);
120
+ it cannot be placed on a GPU device.