Skip to content

Add GPU KNN to Generate Truth - #336

Merged
MaggieQi merged 45 commits into
microsoft:mainfrom
caijiediego:master
Oct 8, 2022
Merged

MaggieQi merged 45 commits into
microsoft:mainfrom
caijiediego:master

Conversation

@caijiediego

Copy link
Copy Markdown
Contributor

Add GPU KNN branch to Generate Truth

Code changes including:

  1. Add Implementation of GPU KNN kernel code to KNN.hxx file
  2. Adding TruthSet.cpp.
    To save implementation of Generate Truth to avoid compiling issue.
  3. Relocate the Point to GPUKNNDistance.hxx
    In order to detach GPU KNN generation from GPU Index build
  4. Add TransposedPoint Structure to avoid GPU bank conflict
  5. Recover functions for Point Structure in ThreapHeap from deprecated
  6. Reduce Thread Number per Block from 64 to 32, in order to suit more GPU with limited shared memory size
  7. Fixed a minor bug for some version of Windows compiler in [cuda_unit_tests.cu]

Cmake Build Change:

  1. Update Arch to sm_70, sm_75, sm_80 in cmake
  2. Modified CmakeList to suit submodule zstd

Diego-Cai and others added 30 commits May 17, 2022 15:09
Only included need files in Kernel.cu
query_KNN has transpose and all shared memory.
query_KNN has transpose and heamMem in local.
2. Tested batch splitting on 35M
3. Moved the malloc before launching to avoid waste of memry
Comment thread .gitignore Outdated
/packages
/out/build/x64-Debug
/sgKey.snk
/out/build/x64-Debug

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already add x64-Debug, you do not need to add the files in that folder, all files in that folder will be ignored.

Comment thread AnnService/GPUSSDServing.vcxproj Outdated
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\SSDServing\main.cpp" />
<!--<ClCompile Include="src\SSDServing\main.cpp" />-->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this itemgroup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I actually should put it back, since we have already fixed the Build issue by having TruthSet.cpp separately.

Comment thread AnnService/inc/Core/Common/TruthSet.h Outdated
}
}

//#define DefineVectorValueType(Name, Type) template static void GenerateTruth<Type>(std::shared_ptr<SPTAG::VectorSet> querySet, std::shared_ptr<SPTAG::VectorSet> vectorSet, const std::string truthFile, const SPTAG::DistCalcMethod distMethod, const int K, const SPTAG::TruthFileType p_truthFileType, const std::shared_ptr<SPTAG::COMMON::IQuantizer> & quantizer);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these lines?

@MaggieQi
MaggieQi merged commit 55ca655 into microsoft:main Oct 8, 2022
L1ray (L1-ray) pushed a commit to L1-ray/SPTAG that referenced this pull request May 9, 2026
* GPU KNN Intergrate

* Merged cuda hxx files

* Remove extra files, fix CoreLibrary build

* GPU code needs to be in cu file

* break circular including

* Rearranged the method

* Included the files like Neighborhood Graph. h did.
Only included need files in Kernel.cu

* Relocate the Quey_KNN to KNN.hxx (templates cannot be in kernel.cu

* Try to Instantizate before compile

* Fixed compile error. Need GPU to test rest

* Set Mem Failure

* Adjusted the max dimension for vectors up ot 184

* Change DistCalMethod

* Print Thread Start/End

* Shared memory

* Cannot launch Kernelr with 60% MaxSharedMemory

* Root Cause: Transpose_Mem

* L2 480s, Cosine 703s after Transpose

* Two functions for Shared and local ThreadHeap, two launch setting with shared and local DistPair

* Test version for Ben. 32 Threads defined in params.h
query_KNN has transpose and all shared memory.
query_KNN has transpose and heamMem in local.

* Found the debugger issue, next step: fix dist calc

* 1. Fixed int8 dist calc
2. Tested batch splitting on 35M
3. Moved the malloc before launching to avoid waste of memry

* 45cap, monitor mem usage, track where Convert failed

* Succeed on 400M 100D, Fixed int overflow, major change: int to size_t

* Multi-GPU detection

* Fixed the CPU mem over-usage, located the bug in updating results

* Fixed multi free results

* Fixed hard coded Cosine DistCalcMethod

* Relocate the Point & Transposed Point to GPUKNNDistance.hxx

* Merge SPTAG current changes, complaining about cuh cuda lib

* Move Generate Truth to TruthSet.cpp

* Fix optimization issue, add GPUCoreLibrary/GPUSSDServing to default build

* Fix Error for Linux cmake.

* Remove Unnecessary Changes.

* restore datasets

* missing s in folder name

* Restore build config to Lib, restore sln Config

* update tlog for lib config

* Remove Wrappers

* Removed not ignored log info

* Remove Static in TruthSet.cpp
Remove debug command, build GPU SSDServing to exe in Debug

* Recover CL compile for GPU SSDServing/main.cpp

Co-authored-by: diegocai <diegocai@microsoft.com>
Co-authored-by: Philip Adams <philipadams@microsoft.com>
Co-authored-by: Diego-Cai <103398280+Diego-Cai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants