-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace hard-wired DFT functions with IDFT #136
Conversation
This can only be an improvement as the garbage return value was being ignored by all callers.
Tests still needed.
Some mid-PR notes: The above commits replace use of the old hard-wired DFT functions from Here is a source file level list of current
Some of these source files define more than one component. These are the types of changes to the configuration which are needed and will come in subsequent commits:
|
… code into the one and only subclass
…nding the problem
That last commit added an IDFT config to all locations I could find. A few caveats and comments. There is a really distressing amount of copy-paste that has crept into our configuration. I think we must wait for PR #105 to be ready and merged before coming up with a serious rewrite. The local default_tools = tools_maker(params)
local tools = std.mergePatch(default_tools, {
dft: {type: "TorchDFT", data: {device: "gpu"}}}); However, the Top level Here is a summary of the files changed:
|
Some additional info Besides the unit tests passing, this high-level test gives reasonable looking results:
There is also a correctness tester:
Note, this sometimes "fails" due to round-off errors slightly greater than 1e-6. And, run it from the top of And there is a benchmark program. It runs with
or Torch/CPU:
or Torch/GPU:
and then make plots from the *.json files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to comment out this line due to removal of gen/inc/WireCellGen/ImpactZipper.h
#include "WireCellUtil/NamedFactory.h" | ||
|
||
#include <torch/script.h> | ||
#include <torch/csrc/api/include/torch/fft.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems this file is not available for older libtorch versions, e.g. 1.6 which is the latest version on gpvm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this takes me by surprise.
Fermilab should upgrade. IIRC, they also do not build libtorch with CUDA support which also limits their usefulness.
I am inclined to say that we simply do not include WCT's pytorch
sub-package for the wirecell
UPS product until they upgrade. To avoid a build-time error in the case that libtorch is found automatically would rquire adding --with-libtorch=no
to wcb configure
. My own intention is to use this new torch support in a stand-alone build of WCT so I don't care about this UPS breakage.
An innocent bystander of that choice would be that dnnroi will also not be available in a UPS environment until Fermilab upgrades. If we "hide" the libtorch based DFT behind some #ifdef
then at least dnnroi could run on CPU at Fermilab. But, I don't know if doing that is on any immediate goal (is it?).
What's your opinion on either of these approaches, @HaiwangYu ? Any other solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems this fft.h
is available from 1.7. https://github.com/pytorch/pytorch/tree/v1.6.0/torch/csrc/api/include/torch
And the versioning macros are available from 1.8 https://pytorch.org/cppdocs/notes/versioning.html
I think we can skip the pytorch
folder until gpvm has a newer version. Before that, if DNNROI is needed, we can remove DFT.cxx
source file in the building shims. How about this? @brettviren
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds very good to me. Thanks.
My build was picking up a stale copy in the install dir
} | ||
}, nin=1, nout=1), | ||
}, nin=1, nout=1, uses[tools.dft]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uses=[tools.dft]
cfg/pgrapher/common/tools.jsonnet
Outdated
// The IDFT FFT implementation | ||
dft : { | ||
type: "FftwDFT", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
},
I did some tests for Vertical Drift 3view30 with default |
This PR is on top of #135 and will stay draft until that one is merged. I also still need to do more testing on this one.
This removes and replaces the hard-wired DFT functions from Waveform and Array used in various components and tests with methods called through an IDFT.