FEA: add sparse tensor support for ngcf_conv and lightgcn_conv #75
+74
−16
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.
为ngcf conv层和lightgcn conv层添加了稀疏矩阵支持,性能基本上维持不变,在测试结果上显存占用变为1/5,提速5x。
对general recommender下面的所有方法都进行了适配(如果用到了ngcf conv或lightgcn conv),所以基于这几个backbone的模型都可以实现提速。为了更好兼容现有代码逻辑,需要手动设置参数才会开启加速。
assert config["enable_sparse"] in [True, False, None]
具体使用方法:
序列推荐其实也有卷积层,也可以进行加速,但是我之前做序列推荐做的比较少,我有时间再研究一下,当作一个todo计划 :)
主要的测试结果:
对于NGCF,15个epoch下,ml-1m数据集
Sparse:占用显存0.18G,训练总时间33.85s
Origin:占用显存1.01G,训练总时间155.79s
对于LightGCN,15个epoch下,ml-1m数据集
Sparse:占用显存0.17G,训练总时间23.99s
Origin:占用显存1.02G,训练总时间102.95s
对于SGL,15个epoch下,ml-1m数据集
Sparse:占用显存0.60G,训练总时间70.84s
Origin:占用显存1.09G,训练总时间382.86s