The invention provides a large
language model kernel generation method and
system and a
text generation method, and the method comprises the steps: firstly obtaining a hardware constraint parameter, and constructing a resource constraint
perception rule comprising a
degree of parallelism and a cyclic partitioning rule according to the hardware constraint parameter; then,
space exploration is performed based on the rules and a sequence decision
algorithm to generate a target kernel. The sequence decision
algorithm sequentially traverses according to the
memory hierarchy and the cycle dimension, the parallelism degree of each dimension and the feasible interval of the
block size are determined,
memory hierarchy configuration parameters are obtained step by step and finally summarized into target kernel configuration parameters, and a target large
language model kernel is generated according to the target kernel configuration parameters. According to the large
language model kernel generation method provided by the invention, the resource constraint
perception rule is dynamically constructed based on the hardware constraint parameter of the target large language model, so that the high-performance target large language model kernel is quickly generated, the kernel
generation time is shortened, and the kernel generation efficiency is improved. And the calculation efficiency and the
resource utilization rate of the large language model on special hardware are improved.