text
stringlengths
0
89.3k
42 Techniques for Efficiency and Effectiveness
In this section we discuss some techniques to improve the efficiency
and effectiveness of HiCom The efficiency perspective is important
as LLMs can have multibillion parameters with considerable GPU
memory requirements We thus introduce implementation tech
niques for batch processing of neighborhoods with different sizes
and reducing the memory consumption of unnecessary padding
These techniques are not restricted to the HiCom algorithm and can
be used for general LLMs to optimize GPU utilization on graph data
From the effectiveness perspective we discuss the idea of summary
accumulation which shares a similar idea to skip connection
421 Batch Processing of Neighborhoods with Different Sizes Algo
rithm 1 presents a straightforward version of HiCom for individual
nodes offering a fundamental understanding of the algorithm In
practice batch processing is essential for maximizing the efficiency
of GPU utilization but it also introduces specific challenges Since
LLMs are innately designed for sequential data the challenge in
adapting HiCom with LLMs for batch processing primarily arises
from the variablelength inputs produced by graph data which
complicates the batching of data instances To address these chal
lenges a more sophisticated padding strategy is needed to uniform
both the length of the text sequence on each node and the number
of neighbors of each node for all nodes in the same level of the
hierarchy Algorithm 2 outlines HiCom for processing nodes in
batches We discuss the algorithm in detail in Appendix A1
422 Pretokenization and Rearrange and Trim Another effective
implementation technique employed in the HiCom framework to
reduce the computational overhead associated with LLMs is pre
tokenization which involves preprocessing the text data into to
kens and padding them with dummy tokens to ensure uniformity in
sequence lengths before the training starts Pretokenization saves
the redundant time cost of raw text encoding when a node belongsAlgorithm 1 HiCom for processing individual nodes
1InputGV𝑿 fanouts𝑛1𝑛𝐿𝐶𝑜𝑚𝑝 a target
node𝑣V
2Output Summary vectors 𝑠𝑣of node𝑣
3V𝐵𝐿𝑣 a batch with a single node ie index 𝐵𝐿𝑣
4for𝑙𝐿to1do
5V𝐵𝑙1Sample up to 𝑛𝑙neighbors of 𝑣𝑣𝑉𝐵𝑙
6 𝑿𝐵𝑙1Collect𝑥𝑣𝑣𝑉𝐵𝑙1
7end for
8𝑺𝐵0
9for𝑙1to𝐿do
10 𝑿𝐶
𝐵𝑙 Concat 𝑿𝐵𝑙1
11 𝑺𝐶
𝐵𝑙 Concat 𝑺𝐵𝑙1
12 𝑺𝐵𝑙𝐶𝑜𝑚𝑝𝑺𝐶
𝐵𝑙𝑿𝐶
𝐵𝑙
13end for
14return 𝑺𝐵𝐿 which is𝑠𝑣
Algorithm 2 HiCom for processing nodes in batches
1InputGV𝑿 fanouts𝑛1𝑛𝐿𝐶𝑜𝑚𝑝 a batch of
target nodesV𝐵V indexed by𝐵 The sequence length is 𝑡
and the number of summary tokens is 𝑘
2Output Summary vectors 𝑺𝐵of nodesV𝐵
3V𝐵𝐿V𝐵
4for𝑙𝐿to1do
5V𝐵𝑙1Sample up to 𝑛𝑙neighbors of 𝑣𝑣𝑉𝐵𝑙
6 𝑿𝐵𝑙1Collect𝑥𝑣and pad to length 𝑡𝑣𝑉𝐵𝑙1
7end for
8𝑺𝐵0 A placeholder of all zeros with shape 𝑉𝐵0𝑘
9for𝑙1to𝐿do
10 𝑿𝐶
𝐵𝑙 A placeholder of all zeros with shape 𝑉𝐵𝑙𝑛𝑙𝑡
11 𝑺𝐶
𝐵𝑙 A placeholder of all zeros with shape 𝑉𝐵𝑙𝑛𝑙𝑘
12 𝑿𝐶
𝐵𝑙𝐵𝑙1𝑿𝐵𝑙1
13 𝑺𝐶
𝐵𝑙𝐵𝑙1𝑺𝐵𝑙1
14 𝑿𝐶
𝐵𝑙 Reshape 𝑿𝐶
𝐵𝑙to𝑉𝐵𝑙𝑛𝑙𝑡
15 𝑺𝐶
𝐵𝑙 Reshape 𝑺𝐶
𝐵𝑙to𝑉𝐵𝑙𝑛𝑙𝑘
16 𝑺𝐵𝑙𝐶𝑜𝑚𝑝𝑺𝐶
𝐵𝑙𝑿𝐶
𝐵𝑙
17end for
18return 𝑺𝐵𝐿 which is 𝑺𝐵
to multiple neighborhoods and is thus involved in multiple compu
tations However one inefficiency that arises from pretokenization
is the presence of dummy tokens within the concatenated sequences
for compression and batching further complicates this problem
For instance in the example in Figure 2 when sequences 𝑥4𝑥8
𝑥9 and 𝑥5𝑥6 are batched into a 29tensor only 7 tokens in
each sequence are meaningful with the remainder being dummy
tokens but appear in different places of the tensor
To optimize memory usage and computation time especially
when processing batched sequences a technique to rearrange and
trim the sequences is employed This technique pushes all dummy
tokens to one end of the sequence allowing them to be trimmed off
thereby conserving memory and speeding up computation In theConference acronym XX June 0305 2018 Woodstock NY Zhang et al
same example the 29tensor can be rearranged and trimmed to 27
to save computation This rearrangeandtrim method optimizes
the efficiency of the HiCom framework It is particularly effective
when node text has diverse lengths or when the fanout parameter
is large We show a pseudocode of this function in Appendix A2