o
    i                     @   sZ   d Z ddlZddlZddlZddlmZ ddlmZm	Z	m
Z
 ddlmZ defdd	ZdS )
a3  
Copyright (c) 2025 by FlashInfer team.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    N   )env)JitSpecgen_jit_specsm90a_nvcc_flags)write_if_differentreturnc                  C   sj  d} t j|  }tj|dd g }tt jd }t| }W d   n1 s)w   Y  ddg}|D ]Z\}}t	j
ddgd	d
D ]L\}}	}
}| dt| dt|	 dt|
 dt| 	}d| d}|| }|| |j|t| t|	 t|
 t| d}t|| qAq4dD ]}t j| }||j }|| t||  qt| |tddg dS )uG  Generate JIT module for GDN prefill kernel with separate compilation.

    This generates 32 separate kernel instantiation files (2 dtypes × 16 boolean combinations)
    plus the original launcher file. The separate files enable parallel compilation by ninja,
    significantly reducing build time on multi-core machines.
    gdn_prefill_sm90T)exist_okz"gdn_prefill_sm90_kernel_inst.jinjaN)halfr   )bf16nv_bfloat16F   )repeat_gbaigdn_prefill_kernel_z.cu)dtypeis_gva
needs_betaneeds_alpha
init_state)zgdn_prefill_launcher.cuz!prefill_kernel_delta_rule_sm90.cuz-DFLAT_SM90A_ENABLEDz
-std=c++20)extra_cuda_cflags)jit_envFLASHINFER_GEN_SRC_DIRosmakedirsopenFLASHINFER_CSRC_DIRjinja2Templateread	itertoolsproductintappendrenderstrlowerr   name	read_textr   r   )urigen_directorysource_pathsfkernel_inst_templdtypes
dtype_namer   r   r   r   r   suffixfilename	dest_pathsourcesrc_path r9   H/home/ubuntu/vllm_env/lib/python3.10/site-packages/flashinfer/jit/gdn.pygen_gdn_prefill_sm90_module   sF   
0








r;   )__doc__r$   r   r!    r   r   corer   r   r   utilsr   r;   r9   r9   r9   r:   <module>   s    