Commit 7be00cd
perf(timeseries): stop per-element GPU host reads in Autoformer/Informer/TFT forwards (#1897)
These three sequence models read GPU-resident tensors ELEMENT BY ELEMENT inside their
forward passes. On the DirectGpu engine each such index is a separate device->host
transfer that flushes the pipeline, so a single forward stalled the GPU hundreds to
thousands of times.
Two sites, both on the hot path:
1. Autoformer AutoCorrelationEngine top-k selection read the [corrLen] correlation
vector one element at a time (corrLen syncs per call, x4 call sites per forward:
encoder self-attn x2, decoder self+cross). Now downloads it once via GetCpuData().
2. All three assemble the per-window/per-batch positional encoding by indexing the
_positionalEncoding tensor per element every forward (seqLen*dim for Autoformer,
batch*seqLen*dim for Informer and TFT). The PE is CONSTANT after construction, so
it is now downloaded to a host array once and cached (refreshed on deserialize).
Behavior is unchanged - same values, same gradients; the correlation top-k choice was
already non-differentiable and the PE was already a constant, no-grad input. This is
purely about how the values reach the host.
Measured on an RTX 3080 (FCHL research sweep, float models, 15-min bars):
GPU utilization during heavy-transformer training: ~7% -> 10-15%
HONEST SCOPE - what this does NOT fix: these models were also timing out in that sweep,
and this change does NOT resolve that. That turned out not to be a code defect at all:
one research cell runs 7 full trainings (6 walk-forward folds + 1 hold-out refit), and at
8 epochs that needs ~300-520s against the harness's 300s cap. Measured cost is ~9.3s per
training at 1 epoch; given an adequate budget the same cells complete with 0 timeouts and
0 faults. So this PR is a genuine but incremental GPU-efficiency fix, not a fix for the
timeouts.
Builds clean on net10.0, net8.0 and net471.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent 259d58b commit 7be00cd
3 files changed
Lines changed: 29 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
112 | 116 | | |
| |||
195 | 199 | | |
196 | 200 | | |
197 | 201 | | |
| 202 | + | |
198 | 203 | | |
199 | 204 | | |
200 | 205 | | |
| |||
468 | 473 | | |
469 | 474 | | |
470 | 475 | | |
471 | | - | |
| 476 | + | |
| 477 | + | |
472 | 478 | | |
473 | 479 | | |
474 | 480 | | |
| |||
572 | 578 | | |
573 | 579 | | |
574 | 580 | | |
575 | | - | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
576 | 586 | | |
577 | | - | |
| 587 | + | |
578 | 588 | | |
579 | 589 | | |
580 | 590 | | |
| |||
886 | 896 | | |
887 | 897 | | |
888 | 898 | | |
| 899 | + | |
889 | 900 | | |
890 | 901 | | |
891 | 902 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
| |||
170 | 174 | | |
171 | 175 | | |
172 | 176 | | |
| 177 | + | |
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| |||
727 | 732 | | |
728 | 733 | | |
729 | 734 | | |
| 735 | + | |
730 | 736 | | |
731 | 737 | | |
732 | 738 | | |
733 | | - | |
| 739 | + | |
734 | 740 | | |
735 | 741 | | |
736 | 742 | | |
| |||
751 | 757 | | |
752 | 758 | | |
753 | 759 | | |
754 | | - | |
| 760 | + | |
755 | 761 | | |
756 | 762 | | |
757 | 763 | | |
| |||
972 | 978 | | |
973 | 979 | | |
974 | 980 | | |
| 981 | + | |
975 | 982 | | |
976 | 983 | | |
977 | 984 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
133 | 136 | | |
134 | 137 | | |
135 | 138 | | |
| 139 | + | |
136 | 140 | | |
137 | 141 | | |
138 | 142 | | |
| |||
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
| 355 | + | |
351 | 356 | | |
352 | 357 | | |
353 | 358 | | |
354 | | - | |
| 359 | + | |
355 | 360 | | |
356 | 361 | | |
357 | 362 | | |
| |||
0 commit comments