-
Notifications
You must be signed in to change notification settings - Fork 199
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
Fallback resource adaptor #1665
base: branch-24.10
Are you sure you want to change the base?
Fallback resource adaptor #1665
Conversation
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.
Let's pre-empt #1661
template <typename PrimaryUpstream, | ||
typename AlternateUpstream, | ||
typename ExceptionType = rmm::out_of_memory> |
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.
issue: We are moving away from having templated adaptors and instead just using type-erased resource_ref objects (see #1661). To avoid introducing a new such class here, can we immediately move to the new model:
template<typename ExceptionType = rmm::out_of_memory>
class failure_alternate_resource_adaptor final : public device_memory_resource {
...
failure_alternate_resource_adaptor(device_async_resource_ref primary, device_async_resource_ref alternate) : ... {}
Or, if we can't type-erase yet, we should at least accept resource refs as an alternate constructor, and store resource_refs rather than templated type-specific usptreams.
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.
Done in cbd7f43, which rely on implicit type conversion from device_memory_resource*
to device_async_resource_ref
Devil's advocating: couldn't we implement this using |
Not as-is. The callback function in It is possible to write a new resource that can handle both |
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.
Mostly doc comments. However also needs C++ tests.
* @throws `exception_type` if the requested allocation could not be fulfilled | ||
* by the primary or the alternate upstream resource. |
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 think it's ExceptionType
. But actually I don't think you can say what type of exception will be thrown by alternate_upstream
if it fails to allocate. It could be a CUDA error, or it could be rmm::out_of_memory
, or some other exception.
The alternate upstream should document what exceptions it may throw.
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.
fixed
Added C++ tests |
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.
Looks great, good C++ tests.
* @tparam ExceptionType The type of exception that this adaptor should respond to. | ||
*/ | ||
template <typename ExceptionType = rmm::out_of_memory> | ||
class failure_alternate_resource_adaptor final : public device_memory_resource { |
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.
nit: fallback_resource_adapater
feels like a more concise name.
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.
+1
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.
+1, will rename.
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.
done
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.
Approving with request to rename test files appropriately.
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.
We're still discussing the use cases of this feature offline -- for now, I'm requesting changes so that we don't merge this with typos in the API and filename name.
…lternate_resource_adaptor
Let's put this on hold until we get some more use cases. |
New resource adaptor that uses an alternate upstream resource when the primary throws a specified exception type.
The motivation here is to provide NO-OOM by using managed memory when the primary device resource runs out of memory.
Checklist