Add pre-allocated output tensor & offsets for VBE #3624
Closed
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.
Summary:
Context
Mixing SSD offloading and non-SSD TBE with VBE enabled can cause a ~30% QPS regression compared to the baseline (HBM+UVM) for the Jupiter V1 model. Investigation shows that the regression is due to the inefficient tensor splits in
_merge_variable_batch_embeddings(). This function is invoked only when:The second step above happens in CPU that makes GPU idle for a significant period of time.
To mitigate the regression, we proposed a different path to work around the inefficient splits and merge the output at FBGEMM op level:
Changes
GroupedPooledEmbeddingsLookup:BaseBatchedEmbeddingBagand its child classes).forwardfunction for better readability, and reserved the original path without pre-allocation.KeyValueModelParallelTest:test_ssd_mixed_kernels_with_vbe) by assigning different sets of optimizer parameters to different dtypes so that FP32 can be tested with a higher precision and FP16 can be tested with better numerical stability.BaseBatchedEmbeddingBagand its child classes:forwardmethod to take the two new optional parameters:vbe_outputandvbe_output_offsets.NOTE:
QuantBatchedEmbeddingBagfrom inference is a child class ofBaseBatchedEmbeddingBagso itsforward()is also impacted. Technically it should not have these VBE params and we should add extra abstractions to fully correct this.Reviewed By: TroyGarden
Differential Revision: D67681796