Use tf.function for list column operations #938
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses NVIDIA-Merlin/dataloader#74.
Goals ⚽
In Tensorflow >= 2.10, there seems to be a race condition or some thread safety issue when Dataloader is loading list columns. The errors described in the above issue happen non-deterministically. When the list column tensors are copied successfully by the time tensorflow begins its execution, the tests run successfully. If the copy is incomplete, the tests fail. This PR proposes a workaround for this issue by using the
@tf.function
decorator on the methods that involve list columns.Implementation Details 🚧
Some observations:
The above two observations suggest two workarounds:
with tf.device("CPU")
).tf.function
).The second workaround seems to be the superior approach. One could also argue that all methods, not just the ones involving list columns, that were written in eager mode should be wrapped with
@tf.function
for efficiency. However, I consider it to be out of scope for this PR. This PR has the minimum changes required to have the unit tests complete successfully; the@tf.function
decorator is applied only to the methods that are failing unit tests in Tensorflow 2.10.Also has a minor fix due to
cudf.RangeIndex
not having anempty
property anymore, which was copied from #904 (comment).Testing Details 🔍
Removed the upper bound on tensorflow from
2.10
to2.11
inGPU CI / gpu-ci (pull_request)
.This issue is currently blocking the
22.12
release pipeline. Tested manually withnvcr.io/nvstaging/merlin/tmp-merlin-tensorflow-stg:22.12
(which has tensorflow 2.10).