← 返回全景索引

1. model_executor/layers(102 文件 · 25,098 行)

模块综述——算子层的非 TileLang 部分 9 文件:attention_backend.py(147 行)prefill_attn_varlen_sparse/decode_mla_mqa_sparse 两个稀疏注意力入口(批不变路径也在其中);sampler.py(684 行)Sampler 全采样逻辑(top-p/top-k/惩罚/确定性);sampler_utils.py(197 行)prompt logprobs 分块计算;rotary_embedding.py(285 行)RoPE+YaRN 全套;linear.py(186 行)bf16_gemm_nt 与 FP8 cast 粒度;mtp_info_pool.py(79 行)MTP 提案的 GPU 常驻池(slot 0 留 padding);layernorm/vocab_parallel_embedding 是薄适配。

deepinfer/model_executor/layers/__init__.py查看源码1 行
deepinfer/model_executor/layers/attention_backend.py查看源码147 行
符号行数 · 说明(ast 提取)
_pad_attention_heads16把 tensor 的 head 维补零到 FlashMLA 允许的头数;已支持时原样返回(第三个返回值为 None)
prefill_attn_varlen_sparse49Args: query: [total_q, num_heads_q, head_dim], bf16 kv_a_with_mqa: [total_k, 1, head_dim], bf16
decode_mla_mqa_sparse70Args: query: [total_q, num_heads_q, head_dim], bf16 key_cache: [num_blocks, block_size, 1, bytes
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/layernorm.py查看源码64 行
符号行数 · 说明(ast 提取)
class RMSNorm50Root mean square normalization. Computes x -> w * x / sqrt(E[x^2] + eps) where w is the learned
└ __init__16
└ forward26
(已列出全部 1 个顶层符号 + 2 个方法)
deepinfer/model_executor/layers/linear.py查看源码186 行
符号行数 · 说明(ast 提取)
get_fp8_casting_granularity2
get_fp8_cast_params8
bf16_gemm_nt7
class ReplicatedLinear150Replicated linear layer. Args: input_size: input dimension of the linear layer. output_size: out
└ __init__35
└ _allocate_output13
└ _has_aligned_output_stride3
└ _flatten_output7
└ _align_output6
└ apply_weight_bf1623
└ apply_weight_fp827
└ apply_weight11
└ forward6
(已列出全部 4 个顶层符号 + 9 个方法)
deepinfer/model_executor/layers/mtp_info_pool.py查看源码79 行
符号行数 · 说明(ast 提取)
get_nextn_pad_token_ids3Return placeholder draft token IDs matching pool slot 0.
class MTPInfoPool65Stable GPU storage for MTP proposals indexed by scheduler slots. Each slot owns ``nextn`` rows.
└ __init__28
└ store25Store batched MTP predictions in their scheduler slots. ``logprobs`` a
(已列出全部 2 个顶层符号 + 2 个方法)
deepinfer/model_executor/layers/rotary_embedding.py查看源码285 行
符号行数 · 说明(ast 提取)
_build_cos_sin_cache7
class RotaryEmbedding63Original rotary positional embedding.
└ __init__17
└ _compute_inv_freq9Compute the inverse frequency.
└ _compute_cos_sin_cache5Compute the cos and sin cache.
└ forward23
_yarn_find_correction_dim7
_yarn_find_correction_range10
_yarn_linear_ramp_mask13
yarn_get_mscale4
class YaRNScalingRotaryEmbedding66RotaryEmbedding extended with YaRN method. Credits to Peng et al. github.com/jquesnelle/yarn
└ __init__35
└ _compute_inv_freq24
get_rope61
(已列出全部 8 个顶层符号 + 6 个方法)
deepinfer/model_executor/layers/sampler.py查看源码684 行
A layer that samples the next tokens from the model's outputs.
符号行数 · 说明(ast 提取)
class Sampler625从模型 hidden states 采样下一个 token,支持 MTP(Multi-Token Prediction)投机采样。 核心流程: 1. 取出需要采样的 hidden states
└ __init__17
└ forward186
└ _get_so_mask107TODO 暂定每一轮固定预测 max MTP value 个,只验证 cur step MTP value 个
└ _verification185
└ _prefill_golden_gen38Prefill 路径的采样(golden 覆盖、top info、sum_smaller_probs);decode(含 nextn=0)走
└ _prepare_top_info13
└ _update_golden_tokens34对 flat sample result 应用 golden token,并还原 force-topk token id。 golden_o
(已列出全部 1 个顶层符号 + 7 个方法)
deepinfer/model_executor/layers/sampler_utils.py查看源码197 行
Sampling and prompt-logprob helpers.
符号行数 · 说明(ast 提取)
get_logits9
split_prompt_logprobs19Split the flat prompt-logprob result back into requests.
_compute_prompt_logprobs_chunk27
compute_prompt_logprobs30Compute prompt logprobs in bounded chunks; only CP rank 0 materializes the result. Every CP rank
process_sampling84Apply temperature, top-p/top-k and log-softmax, with optional sampling and MTP rejection. Args:
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/__init__.py查看源码1 行
deepinfer/model_executor/layers/tilelang_ops/asc/__init__.py查看源码1 行
deepinfer/model_executor/layers/tilelang_ops/asc/candidate_blocks.py查看源码351 行
符号行数 · 说明(ast 提取)
candidate_block_max_tl218
get_candidate_compact_lens_tl50
restore_candidate_indices_inplace_tl68
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/compress.py查看源码408 行
符号行数 · 说明(ast 提取)
compress_and_update_state_prefill_tl189
compress_and_update_state_decode_tl204
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/compute_seqlens_k_zos.py查看源码60 行
符号行数 · 说明(ast 提取)
compute_seqlens_k_zos_tl45
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/dflash.py查看源码151 行
符号行数 · 说明(ast 提取)
confidence_head_fused_tl83
dflash_input_store_tl48
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/dflash_copy.py查看源码130 行
符号行数 · 说明(ast 提取)
copy_dflash_decode_input_tl115Fill the DFlash graph's per-request inputs: rows [0, src_req_cnt) from src, the rest from paddin
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/flash_mla_utils.py查看源码54 行
符号行数 · 说明(ast 提取)
convert_kv_index_tl40
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/fused_sample.py查看源码674 行
符号行数 · 说明(ast 提取)
_get_lse_block_size9
accumulate_search_chunk52
fused_sample_tl591融合 temperature-softmax、top-p/top-k 过滤及 sampling/reject sampling
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/fused_transform.py查看源码900 行
Branch-derived Ascend fused transform candidate (ba146714a5bf).
符号行数 · 说明(ast 提取)
_fused_norm_rope_hadamard_cast_store_kvcache_kernel705Branch SIMD pipeline with the missing reference stages/extensions.
fused_norm_rope_hadamard_cast_store_kvcache_tl161Translate the shared public ABI into branch compile-time descriptors.
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/gather.py查看源码108 行
符号行数 · 说明(ast 提取)
gather_tl92Args: D: row length in elements (== row bytes when dtype is int8) dtype: x/y element dtype (torc
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/gather_engram_tokens_zos.py查看源码146 行
gather_engram_tokens_zos Ascend kernel (decode path, small max_seqlen_q).
符号行数 · 说明(ast 提取)
gather_engram_tokens_zos_tl117
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/gather_input_ids_zos.py查看源码88 行
符号行数 · 说明(ast 提取)
gather_input_ids_zos_tl73
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/get_kv_index.py查看源码264 行
符号行数 · 说明(ast 提取)
load_kv_index_tl100
get_fused_dflash_get_input_tl149Build the fixed-stride draft-token inputs of every request. ftp < 0 marks a padding request: its
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/image_embed_ops.py查看源码403 行
符号行数 · 说明(ast 提取)
replace_input_embeds_tl120Ascend NPU: in-place fill of multimodal embeddings. One vector core per batch of ``B`` consecuti
rgb_pad_to_patches_tl94Ascend NPU: concatenated plain RGB (HWC uint8) pixel data -> normalized bf16 patch tensors, cent
batch_downsample_tl153Ascend NPU: d x d spatial pooling / concatenation of ViT patch features. One output patch per pe
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/kv_index_cat.py查看源码72 行
符号行数 · 说明(ast 提取)
kv_index_cat_tl63Ascend kernel: out[:, :window_size] = kv_index; out[:, window_size:] = kv_ca_index + total_k_swa
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/kv_quant.py查看源码197 行
Register-only BF16 KV quantization primitives for Ascend SIMD.
符号行数 · 说明(ast 提取)
build_reciprocal_table14Build the reciprocal lookup table in one vector register.
make_kv_scale_impl47Encode group maxima and return their exact FP32 inverse scales.
make_kv_quant_impl100Build macros consuming two fp32 registers holding 128 BF16 values. ``compute_scales`` returns an
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/load_paged_kv_cache.py查看源码346 行
符号行数 · 说明(ast 提取)
load_paged_kv_cache_tl329
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/norm.py查看源码432 行
符号行数 · 说明(ast 提取)
load_pair8
pack_bf163
store_pair6
_tile_rows12
norm_tl378
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/prepare_cp_mirror.py查看源码519 行
符号行数 · 说明(ast 提取)
prepare_cp_mirror_tl313Ascend NPU - one fused kernel: hierarchical prefix sums + scatter. A single grid-extent launch w
yoco_cp_boundary_fused_tl182Ascend NPU - prepare YOCO full-to-compact CP redistribution indices. Phase 1 builds per-rank kep
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/prepare_v4_decode_metadata.py查看源码258 行
符号行数 · 说明(ast 提取)
copy_block_tables_tl54
prepare_v4_decode_metadata_tl180
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/random_sampling.py查看源码259 行
符号行数 · 说明(ast 提取)
class Config36Compile-time layout for two-level sampling. Fold `bd`-column chunks into `acc_slots` sums indexe
└ n_chunks2
└ n_slots2
└ n_slots_aligned2
└ n_slots_threads2
└ scale2
accumulate32
inclusive_scan31Scan integer prefixes in place over a multiple of 64 elements inside T.SimdVF(). Carry sums acro
locate8
sample_offset6
sample_select15
draw_random17
random_sampling_tl76Build an Ascend two-level fixed-point sampler (see Config). Encode weights at scale 2**31 and fo
(已列出全部 8 个顶层符号 + 5 个方法)
deepinfer/model_executor/layers/tilelang_ops/asc/rstd_1ulp.py查看源码99 行
Compensated RSTD, matching hai_llm.tilelang_kernels.ascend.helper.rstd_1ulp.
符号行数 · 说明(ast 提取)
split_fp325Split a Python float into two FP32 values whose sum approximates it.
naive_rsqrt3Compute reciprocal square root directly with FP32 SIMD operations.
compensated_rsqrt20Refine an rsqrt estimate against the high and low parts of its input.
compensated_div_add22Return high and low parts of a / c0 + c1.
make_rstd_impl19Build RSTD with compensated input construction and a naive rsqrt estimate.
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/sampler.py查看源码664 行
符号行数 · 说明(ast 提取)
prepare_verification_metadata_tl56
expand_sampling_params_tl35
map_lookup_tl74
remap_draft_topk_tl107
get_accept_result_tl50
finalize_verification_tl285
(已列出全部 6 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/schedule_mtp_varlen.py查看源码122 行
符号行数 · 说明(ast 提取)
compute_seqlens_q_by_confidence_rates_tl106
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/state_cache.py查看源码97 行
符号行数 · 说明(ast 提取)
_state_cache_copy_tl55
select_state_slice_tl7
load_state_to_cache_tl7
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/store_kv_cache.py查看源码311 行
Register-quantized Ascend store with the fixed qy/asc-kv-layout ABI.
符号行数 · 说明(ast 提取)
store_kv_cache_tl284Build a store: BF16 input[n,D], uint8 cache[pages,B,bytes], int32 slots[n]. Plain BF16 uses a BF
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/store_mtp_info.py查看源码68 行
符号行数 · 说明(ast 提取)
store_mtp_info_tl59
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/structure_output.py查看源码103 行
符号行数 · 说明(ast 提取)
apply_token_bitmask_by_step_inplace_tl86
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/sum_smaller_probs.py查看源码100 行
符号行数 · 说明(ast 提取)
sum_smaller_probs_tl85
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/asc/swa_index.py查看源码63 行
符号行数 · 说明(ast 提取)
expand_swa_index_tl51
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cache_common.py查看源码462 行
KV-cache formats, tensor views, and reference helpers.
符号行数 · 说明(ast 提取)
class KVCacheFormat82Logical and physical contents of one token in a KV cache. ``sf_format`` describes the encoded sc
└ __post_init__11
└ num_elements2
└ quantized_bytes5
└ num_scales4
└ sf_dtype8Physical dtype of one scale factor, or None for an unscaled cache.
└ sf_element_size2
└ sf_bytes3Number of physical scale-factor bytes stored for each token.
└ sf_storage_elements5
└ bytes_per_token2
└ stride_alignment3Data token-stride alignment in bytes, capped by the shared block's 32B
get_kv_cache_format17Infer a KV-cache format, using ``sf_format`` to resolve ambiguous byte layouts.
resolve_kv_cache_layout22Infer a cache layout and validate an explicitly supplied one.
class KVCacheTensors40 个方法
alloc_kv_load_output33Allocate the natural load result for a cache format.
alloc_kv_cache18Allocate block-aligned byte storage for a quantized paged cache.
sf_data_as_int328View packed UE8M0 scale bytes in the int32 form used by load kernels.
fp4_cache_kernel_kwargs9Return logical FP4 value/scale strides for TileLang factories.
split_kv_cache33Return block size and typed views of a paged KV cache's sections.
ref_cast_from_bf1627Reference cast from BF16 values to the three logical cache sections.
ref_cast_to_bf1625Reference cast from the three logical cache sections back to BF16.
_supported_test_layout2
kv_cache_benchmark_operation9
kv_cache_benchmark_id3
test_main_cache_layout18Main descriptors cannot opt back into block-wide sections or a BF16 tail.
test_reject_mixed_cache_shape5Former mixed main-cache byte widths must not resolve to a current format.
(已列出全部 16 个顶层符号 + 10 个方法)
deepinfer/model_executor/layers/tilelang_ops/candidate_blocks.py查看源码329 行
符号行数 · 说明(ast 提取)
candidate_block_max37Compute block scores and valid block counts for candidate selection. Each score is the maximum v
candidate_block_max_ref24Return unpadded [num_rows, num_blocks] scores and [num_rows] valid counts.
get_candidate_compact_lens24Return compact token counts for the selected candidate blocks. Args: candidate_blocks: [num_rows
get_candidate_compact_lens_ref9
restore_candidate_indices_inplace40Restore compact token indices to sequence-local or gathered indices in place. Args: compact_indi
restore_candidate_indices_inplace_ref16
_check_inputs8
test_candidate_block_max12
test_restore_candidate_indices_inplace12
test_get_candidate_compact_lens7
test_candidate_block_max_benchmark31
test_get_candidate_compact_lens_benchmark23
test_restore_candidate_indices_inplace_benchmark35
(已列出全部 13 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/common.py查看源码54 行
Constants and small helpers shared by TileLang operators.
符号行数 · 说明(ast 提取)
is_power_of_two2
ceil_div2
align2
customized_finfo_amax7
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/compress.py查看源码664 行
符号行数 · 说明(ast 提取)
_enable_fast_math4compress 内核固定开启 fast math
compress_and_update_state_prefill52Args: score: [total_q | cp_size * cp_mirror_len, dim], fp32 latent: [total_q | cp_size * cp_mirr
compress_and_update_state_decode43Args: score: [total_q, dim], fp32 latent: [total_q, dim], fp32 state_cache: [num_state_slots, st
_get_cuseqlen2
_make_compressed_meta9Build (cu_compressed_seqlens_q, compressed_batch_mapping); each seq reserves >= 1 entry.
_make_strided_state_cache7Random state_cache carved out of a bigger per-slot buffer, so that stride(0) exceeds the state r
compress_and_update_state_prefill_ref65
compress_and_update_state_decode_ref37
_test_compress_state_prefill95Test the prefill compress kernel against the Python reference. prefill_store_extra_size > 0 sele
_test_compress_state_decode68
test_compress_state_prefill7
test_compress_state_decode8
_make_prefill_bench_inputs40
test_compress_prefill_benchmark51
_make_decode_bench_inputs31
test_compress_decode_benchmark47
(已列出全部 16 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/compute_seqlens_k_zos.py查看源码122 行
符号行数 · 说明(ast 提取)
compute_seqlens_k_zos23Compute seqlens_k for ZOS decode step (in-place on GPU). Fuses into a single kernel: seqlens_k[i
compute_seqlens_k_zos_ref18Reference: original Python implementation from _compute_seqlens_k.
test_compute_seqlens_k_zos32
test_compute_seqlens_k_zos_bench29
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/conftest.py查看源码114 行
符号行数 · 说明(ast 提取)
_bind_worker_gpu14Bind each xdist worker to a GPU via CUDA_VISIBLE_DEVICES. Mirrors the old pytest_benchmark_plugi
pytest_collect_file24Collect test files directly under tilelang_ops/ so the directory can be passed to pytest directl
pytest_runtest_call13Skip tests hitting kernels the selected backend has not implemented. ops.KernelUnavailableError
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/__init__.py查看源码1 行
deepinfer/model_executor/layers/tilelang_ops/cuda/candidate_blocks.py查看源码226 行
符号行数 · 说明(ast 提取)
candidate_block_max_tl108
get_candidate_compact_lens_tl36
restore_candidate_indices_inplace_tl44
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/compress.py查看源码293 行
符号行数 · 说明(ast 提取)
_num_threads4Round a per-thread work target to a power-of-two number of full warps.
_compute_dim_block9Return (DIM_BLOCK, NUM_DIM_BLOCKS, threads) for C1/C2 compute. Use power-of-two tiles that divid
compress_and_update_state_prefill_tl147
compress_and_update_state_decode_tl106
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/compute_seqlens_k_zos.py查看源码39 行
符号行数 · 说明(ast 提取)
compute_seqlens_k_zos_tl24
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/dflash.py查看源码120 行
符号行数 · 说明(ast 提取)
confidence_head_fused_tl61
dflash_input_store_tl38
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/dflash_copy.py查看源码83 行
符号行数 · 说明(ast 提取)
copy_dflash_decode_input_tl70Fill the DFlash graph's per-request inputs: rows [0, src_req_cnt) from src, the rest from paddin
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/flash_mla_utils.py查看源码41 行
符号行数 · 说明(ast 提取)
convert_kv_index_tl28
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/fused_sample.py查看源码525 行
符号行数 · 说明(ast 提取)
fused_sample_tl506
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/fused_transform.py查看源码620 行
符号行数 · 说明(ast 提取)
fused_norm_rope_hadamard_cast_store_kvcache_tl603Build an optional norm -> RoPE -> Hadamard -> quantize pipeline.
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/gather.py查看源码70 行
符号行数 · 说明(ast 提取)
gather_tl56
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/gather_engram_tokens_zos.py查看源码77 行
符号行数 · 说明(ast 提取)
gather_engram_tokens_zos_tl64
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/gather_input_ids_zos.py查看源码49 行
符号行数 · 说明(ast 提取)
gather_input_ids_zos_tl34
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/get_kv_index.py查看源码139 行
符号行数 · 说明(ast 提取)
load_kv_index_tl52Expand per-row (offset, len) into kv index rows; columns >= len are -1. Modes for column j < len
get_fused_dflash_get_input_tl62Build the fixed-stride draft-token inputs of every request. One CTA per (request, draft slot). f
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/image_embed_ops.py查看源码276 行
符号行数 · 说明(ast 提取)
replace_input_embeds_tl42One block per token: if input_ids[bx] is the image token, overwrite the embed row with images_em
rgb_pad_to_patches_tl125Convert concatenated plain RGB (HWC uint8) pixel data to normalized patch tensors, center-paddin
batch_downsample_tl78One block per output patch: gather the d x d source window of ViT patch features (zero-filling r
(已列出全部 3 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/kv_index_cat.py查看源码83 行
符号行数 · 说明(ast 提取)
kv_index_cat_tl69
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/load_paged_kv_cache.py查看源码166 行
符号行数 · 说明(ast 提取)
load_paged_kv_cache_tl152Build a compact-range paged-cache load kernel from ``layout``.
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/norm.py查看源码327 行
符号行数 · 说明(ast 提取)
norm_tl309
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/outlier_detection.py查看源码41 行
符号行数 · 说明(ast 提取)
detect_outlier_and_abort_tl32
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/prepare_cp_mirror.py查看源码314 行
符号行数 · 说明(ast 提取)
prepare_cp_mirror_tl160Output-parallel scatter with the prefix scan in one TileLang entry.
yoco_cp_boundary_fused_tl135YOCO flat scatter with the prefix scan in one TileLang entry.
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/prepare_decode_metadata.py查看源码197 行
符号行数 · 说明(ast 提取)
prepare_v4_decode_metadata_tl140ratio 集合全部是编译期常量, 不写死具体倍率: - ca_ratios: 所有压缩倍率 (dense ∪ sparse), 驱动 positions_c / slot_mapping_s
copy_block_tables_tl32
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/quant.py查看源码10 行
符号行数 · 说明(ast 提取)
ue8m0_exp_scale5Round scale up to a power of two: returns -ceil(log2(scale)), the exponent of the quantization m
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/random_sampling.py查看源码259 行
符号行数 · 说明(ast 提取)
class Config27Compile-time layout for two-level sampling: a row is folded into `bd` per-lane sums (over n_chun
└ n_chunks2
└ n_slots2
└ slot_chunks2
└ scale2
float_to_fixed13floor(x * 2**scale_bits) as fixed point; x must be in [0, 1]. The uint64 path computes this exac
block_cumsum_parts3
block_cumsum23Inclusive integer scan using warp segments and block-wide carries.
accumulate7
sample_offset63Coarse search: pick the random target r within [0, total), then locate the BD-lane offset k0 it
sample_select35Fine search over the gathered arithmetic sequence slot_probs (raw f32 probs for columns k0 + m*B
random_sampling_tl52One CTA per row, two-level weighted sampling (see Config). Level 1 folds the row into BD fixed-p
(已列出全部 8 个顶层符号 + 4 个方法)
deepinfer/model_executor/layers/tilelang_ops/cuda/sampler.py查看源码412 行
符号行数 · 说明(ast 提取)
prepare_verification_metadata_tl28
expand_sampling_params_tl33
map_lookup_tl52
remap_draft_topk_tl65
get_accept_result_tl51
finalize_verification_tl124
(已列出全部 6 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/schedule_mtp_varlen.py查看源码84 行
符号行数 · 说明(ast 提取)
compute_seqlens_q_by_confidence_rates_tl70
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/state_cache.py查看源码137 行
符号行数 · 说明(ast 提取)
select_state_slice_tl54Create a tilelang kernel for selecting state slice from cache to tensor. This implements the gat
load_state_to_cache_tl57Tilelang kernel for loading state from tensor to cache. This implements the scatter operation fr
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/store_kv_cache.py查看源码196 行
符号行数 · 说明(ast 提取)
_amax_to_ue8m0_scales7Convert bf16 amax values to fp8 quant multipliers and ue8m0 scales.
store_kv_cache_tl169Build a paged-cache store kernel specialized by its logical layout.
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/store_mtp_info.py查看源码60 行
符号行数 · 说明(ast 提取)
store_mtp_info_tl47
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/structure_output.py查看源码60 行
符号行数 · 说明(ast 提取)
apply_token_bitmask_by_step_inplace_tl42
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/sum_smaller_probs.py查看源码58 行
符号行数 · 说明(ast 提取)
sum_smaller_probs_tl42
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/cuda/swa_index.py查看源码35 行
符号行数 · 说明(ast 提取)
expand_swa_index_tl27
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/dflash.py查看源码225 行
符号行数 · 说明(ast 提取)
confidence_head_fused37Fused ``sigmoid(cat([hidden, markov_emb], -1) @ weight / temperature)``. Args: hidden: [n, n_emb
_sigmoid_with_temperature3
confidence_head_fused_ref21
test_confidence_head19
test_confidence_head_benchmark22
dflash_input_store26Fused mean-reduce over the hc_mult dim and copy into out. Args: hidden_states: [..., hc_mult, n_
dflash_input_store_ref8
test_dflash_input_store22
test_dflash_input_store_benchmark25
(已列出全部 9 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/dflash_copy.py查看源码152 行
符号行数 · 说明(ast 提取)
_mtp_sampling_tensors10
_mtp_decode_tensors5
copy_dflash_decode_input28Fill the DFlash decode inputs of a CUDA graph in one TileLang launch. Args: dst: Destination wit
copy_dflash_decode_input_ref12
_make_sampling_input16
_make_mtp_decode_input14
test_copy_dflash_decode_input14
test_copy_dflash_decode_input_benchmark19
(已列出全部 8 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/flash_mla_utils.py查看源码108 行
符号行数 · 说明(ast 提取)
convert_kv_index28Map topk logical token indices to physical kv-cache slot indices via block_tables. Args: topk_id
convert_kv_index_ref12
_make_convert_kv_index_inputs17
test_convert_kv_index8
test_convert_kv_index_benchmark19
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/fused_sample.py查看源码833 行
符号行数 · 说明(ast 提取)
fused_sample101Apply temperature, top-p/top-k, log-softmax, and optional sampling. Args: logits: [Q, vocab_size
apply_top_p_top_k_ref30Apply stable top-p followed by stable top-k, masking logits in place. Args: logits: [num_tokens,
fused_sample_ref96Run the PyTorch reference implementation of :func:`fused_sample`. Args: logits: [Q, vocab_size],
generate_logits30
_make_top_p8
_make_top_k6
_make_draft_inputs20
_check_top_p_top_k55Validate the top-p/top-k boundary for one logprob output.
generate_test_params21
make_param_id3
_check_fused_sample118
_check_reject_sampling_distribution90
_check_zero_residual32
_check_signed_zero28
_correctness_cases51
test_fused_sample13
test_fused_sample_benchmark75
(已列出全部 17 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/fused_transform.py查看源码1331 行
符号行数 · 说明(ast 提取)
class NormArgs5RMSNorm parameters for the last dimension.
class RopeArgs9RoPE parameters; rotary_dim values start at offset.
class HadamardArgs20 个方法
class CastArgs25Per-channel quantization parameters. fmt is e4m3 FP8 or packed e2m1 FP4. UE8M0 scales are return
└ from_cache_format7
class ContiguousOutArgs30 个方法
class KVCacheOutArgs60 个方法
_resolve_cache_layout6
_validate_cache_cast5
_restore_single_head_axis5
_restore_single_head_axis5
_restore_single_head_axis9
_alloc_quant38
fused_norm_rope_hadamard_cast_store_kvcache171Optionally fuse attention-row transforms and their final store. Args: x: [num_tokens, num_heads,
hadamard_transform_ref25Pure-PyTorch Walsh-Hadamard transform along the last dimension. Requires a power-of-two last dim
fused_norm_rope_hadamard_cast_store_kvcache_ref179Unfused production reference for the optional transform pipeline.
class _FusedTransformCase1002 个方法
└ operation60Return a canonical, field-derived test and benchmark identifier. The f
└ cast_args10
_benchmark_io_bytes18
_allocate_cache12
_make_case92
_clone_out_args26
_assert_result_equal12
test_fused_norm_rope_hadamard_cast_store_kvcache60
test_fused_norm_rope_hadamard_cast_store_kvcache_benchmark34
(已列出全部 23 个顶层符号 + 3 个方法)
deepinfer/model_executor/layers/tilelang_ops/gather.py查看源码137 行
符号行数 · 说明(ast 提取)
_flat_dense_int812
gather37Row gather ``x[index]`` with out-of-range indices zero-filled. Args: x: [n, ...], any dtype (cop
test_gather14
test_gather_benchmark26
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/gather_engram_tokens_zos.py查看源码249 行
符号行数 · 说明(ast 提取)
gather_engram_tokens_zos46Gather ngram_token_ids using two-source logic, branching fresh/prev inside the kernel. With next
gather_engram_tokens_zos_ref60CPU reference for testing.
test_gather_engram_tokens_zos62
test_gather_engram_tokens_zos_bench51
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/gather_input_ids_zos.py查看源码194 行
符号行数 · 说明(ast 提取)
gather_input_ids_zos23Gather input_ids from fresh_tokens or prev sampled/predict tokens. For each (seq i, token j) wit
gather_input_ids_zos_ref63Gather input_ids from fresh_tokens or prev sampled/predict tokens. Pure GPU implementation, no C
test_gather_input_ids_zos45
test_gather_input_ids_zos_bench41
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/get_kv_index.py查看源码519 行
符号行数 · 说明(ast 提取)
get_kv_ca_index_prefill_ref12
get_kv_ca_index_prefill15Args: kv_ca_index_offset_len: [n, 2], int32, (offset, len) per row Returns: kv_ca_index: [n, kv_
get_kv_ca_index_decode_ref17
get_kv_ca_index_decode18Args: kv_ca_index_offset_len: [n, 2], int32, (offset, len) per row, offset in token units block_
get_kv_swa_index_decode_ref15
get_kv_swa_index_decode16Args: kv_swa_index_offset_len: [n, 2], int32, (offset, len) per row Returns: kv_swa_index: [n, w
test_kv_index18
get_fused_dflash_get_input_ref56PyTorch reference implementation. Returns (newx_slot_mapping, positions_out, input_ids, valid_to
get_fused_dflash_get_input66Fill dflash draft-token inputs in one fused kernel. One CTA per (request, draft slot). Each requ
_make_dflash_inputs13Random (slot_mapping_swa, positions, ftp, last_valid_offset) for fused_dflash tests; the last pa
test_fused_dflash_get_input32
test_fused_dflash_get_input_benchmark30
test_kv_index_benchmark42
test_kv_ca_index_decode_benchmark18
test_kv_swa_index_decode_benchmark17
test_kv_ca_index_prefill_benchmark17
(已列出全部 16 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/image_embed_ops.py查看源码631 行
符号行数 · 说明(ast 提取)
replace_input_embeds30In-place fill of multimodal embeddings: the i-th token equal to image_token_id (in sequence orde
rgb_pad_to_patches55Convert concatenated plain RGB (HWC uint8) pixel data to normalized bf16 patch tensors, center-p
replace_input_embeds_ref20Pure PyTorch reference implementation for replace_input_embeds.
build_image_data59Build test data for image embed ops. Args: num_tokens: total number of tokens in input_embeds hi
_mixed_img_sizes14Split total_img_tokens across num_imgs images with *different* (mixed) even sizes, so per-image
_build_test_data14build_image_data with the tests' default config: 2 images (mixed sizes), 3 pad token types. imag
test_replace_input_embeds19
test_replace_input_embeds_benchmark35
_crops_from_sizes8Build (images_spatial_crop, cu_seqlens_vit, total_seqlens_vit) from an explicit list of per-imag
_rect_crops14Mixed, non-square (n_vit_w, n_vit_h) sizes so that w/h transposition and per-image indexing bugs
test_rgb_pad_to_patches37
_build_rgb_data37Build concatenated plain-RGB (HWC uint8) test data for rgb_pad_to_patches. images_spatial_crop u
test_rgb_pad_to_patches_benchmark38
rgb_pad_to_patches_ref55Pure PyTorch reference for rgb_pad_to_patches. Build a grid-sized uint8 canvas filled with pad_c
batch_downsample68Per-image d x d spatial downsample of ViT patch features: channel-concat (downsample_mlp_gelu /
batch_downsample_ref38Per-image unfold(concat)/ 有效块均值(pool);pool 与 kernel 同用 fp32 sum * (1/count) 的舍入
_downsample_crops3混合整除 / ragged / 零占位(缓存图 dummy)行:一次覆盖 ragged 补零分支与 images_id 定位
test_batch_downsample12
test_batch_downsample_benchmark12
(已列出全部 19 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/kv_index_cat.py查看源码118 行
符号行数 · 说明(ast 提取)
kv_index_cat42Args: kv_index: [total_q, window_size], int32 kv_ca_index: [total_q, topk_tokens], int32 total_k
kv_index_cat_ref13
test_kv_index_cat15
test_kv_index_cat_benchmark17
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/load_paged_kv_cache.py查看源码383 行
符号行数 · 说明(ast 提取)
load_paged_kv_cache81Load compact physical-block ranges through one cache-layout API. Args: kv_cache: [num_blocks, bl
load_paged_kv_cache_ref79PyTorch reference for :func:`load_paged_kv_cache`.
_make_cache14
_make_load_segments24
_make_merged_index_load_segments18
test_load_paged_kv_cache44
test_load_paged_kv_cache_benchmark58
(已列出全部 7 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/norm.py查看源码588 行
符号行数 · 说明(ast 提取)
_check_vectorized_strides5
_alloc_fp8_sf40分配 fp8 cast 的 sf,返回 (对外视图, kernel 实参)。布局与 tile_kernels.quant 一致: - row-major: float32 (B, M, d_s
norm188RMSNorm 前向,可选融合 residual 加与 fp8 cast。 Args: x: [B, d] 或 [B, M, d],bf16/fp32 weight: [d],与 x 同 dt
norm_ref18RMSNorm reference: x -> w * x / sqrt(E[x^2] + eps).
_out_form_id4
_make_inputs7
_shared_sf_ref10把 row-major packed sf [M, packs] 转成 shared_l1_acts_sf 参照([rows, packs] M-major,pad 行为 0): 与 Deep
test_norm120
test_norm_benchmark78
(已列出全部 9 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/ops.py查看源码33 行
Kernel dispatcher: interface modules do ``from deepinfer.model_executor.layers.tilelang_ops import ops`` and call ``ops.xxx_tl``; backend selection happens only in this file.
符号行数 · 说明(ast 提取)
class KernelUnavailableError4Selected backend lacks this kernel factory; conftest.py turns it into a test skip on non-cuda ba
__getattr__2
(已列出全部 2 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/outlier_detection.py查看源码27 行
CUDA outlier detection and PyTorch reference.
符号行数 · 说明(ast 提取)
detect_outlier_and_abort17Queue a CUDA assertion for NaN, infinity, or values outside (-MAX_ABS, MAX_ABS). The check runs
(已列出全部 1 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/prepare_cp_mirror.py查看源码395 行
符号行数 · 说明(ast 提取)
prepare_cp_mirror66Prepare mirror-CP indices with one TileLang entry and an output-parallel scatter. Both backends
yoco_cp_boundary_fused45Prepare YOCO CP boundary indices through one TileLang entry. Args: cu_seqlens_q: [batch_size + 1
prepare_cp_mirror_ref32Pure Python reference that directly expands the zigzag definition.
yoco_cp_boundary_fused_ref27Pure Python reference for YOCO consumer CP boundary redistribution.
_make_cu_seqlens13
_mirror_cp_sizes3
_yoco_contrib_pad_len9
test_prepare_cp_mirror30
test_prepare_cp_mirror_benchmark39
test_yoco_cp_boundary_fused20
test_yoco_cp_boundary_fused_benchmark30
(已列出全部 11 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/prepare_v4_decode_metadata.py查看源码546 行
符号行数 · 说明(ast 提取)
prepare_v4_decode_metadata87Compute V4 decode metadata on GPU via TileLang. Main kernel: one CTA per sequence; block_tables_
prepare_v4_decode_metadata_ref175Compute V4 decode metadata on GPU via pure PyTorch (no CPU-GPU sync).
_build_compact_block_tables13Build random compact block tables; returns (block_tables_in, block_tables_offsets, actual_max_bl
test_prepare_v4_decode_metadata136
test_prepare_v4_decode_metadata_bench84
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/random_sampling.py查看源码333 行
符号行数 · 说明(ast 提取)
random_sampling28Sample one column per row, weighted by probs with each row summing to at most 1. Deterministic i
_seeds2
_pos2
i642
urshift3
_hash_to_uniform10SplitMix64 hash of seed -> uniform f64 in [0, 1); int64 ops emulate uint64.
random_sampling_ref15Pure-PyTorch sampler: hash (seq_seeds, 3 * sample_positions + case) to a uniform and invert the
_make_probs12
test_random_sampling60
test_random_sampling_benchmark22
_gof_distributions12
_draw_counts9
test_random_sampling_gof31
test_random_sampling_degenerate13
test_random_sampling_extreme_scale13
test_random_sampling_tiny_prob18
test_random_sampling_batch_invariant23
(已列出全部 17 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/sampler.py查看源码1081 行
符号行数 · 说明(ast 提取)
prepare_verification_metadata_ref13
prepare_verification_metadata26Build metadata for request rows packed along the ``total_q`` dimension. Args: ftp: [req_cnt], in
expand_sampling_params_ref11
expand_sampling_params41Expand per-request sampling parameters to packed ``total_q`` rows. Args: params: SamplingKernelI
map_lookup_ref16
map_lookup33Look up each row's value by matching a key or by a column index. Args: key: [rows, width], int32
remap_draft_topk39Align previous draft info to the current target top-k space. Args: draft_topk_index: [pool_rows,
remap_draft_topk_ref19
get_accept_result_ref22Apply golden-token overrides and prefix acceptance to raw decisions.
get_accept_result49Apply golden-token overrides and prefix acceptance to raw decisions. Args: raw_accept: [total_q]
class FinalizedVerification160 个方法
finalize_verification_ref80Finalize each request and produce packed verified and request payloads.
finalize_verification179Finalize packed verification rows and request-level sampled payloads. ``total_q`` rows contain c
compute_confidence_error_ref6
test_prepare_verification_metadata12
test_expand_sampling_params21
_random_topk_indices6
test_map_lookup25
test_remap_draft_topk15
test_get_accept_result37
_first_rejected_rows_for_test6
test_finalize_verification94
test_map_lookup_benchmark25
test_remap_draft_topk_benchmark21
test_prepare_verification_metadata_benchmark18
test_expand_sampling_params_benchmark29
test_get_accept_result_benchmark36
test_finalize_verification_benchmark62
(已列出全部 28 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/schedule_mtp_varlen.py查看源码167 行
符号行数 · 说明(ast 提取)
compute_seqlens_q_by_confidence_rates22Distribute total_q tokens across sequences based on MTP confidence rates. Fuses remap scatter: c
compute_seqlens_q_by_confidence_rates_ref64Distribute total_q tokens across sequences based on MTP confidence rates. Fuses remap scatter: c
test_compute_seqlens_q_by_confidence_rates22
test_compute_seqlens_q_benchmark23
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/state_cache.py查看源码221 行
Tilelang implementations for state cache operations.
符号行数 · 说明(ast 提取)
select_state_slice23Gather the window ending at last_hit_position from circular state_cache into state_tensor. Args:
select_state_slice_ref9
load_state_to_cache23Scatter state_tensor into the window ending at last_hit_position of circular state_cache. Args:
load_state_to_cache_ref9
_make_state_tensors16Create random uint8 (state_tensor, state_cache) whose layer stride is padded up to a multiple of
test_select_state_slice15
test_load_state_to_cache15
test_select_state_slice_benchmark21
test_load_state_to_cache_benchmark21
(已列出全部 9 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/store_kv_cache.py查看源码381 行
符号行数 · 说明(ast 提取)
_flatten_kv8
store_kv_cache46Store BF16 tokens through one format-inferred paged-cache API. Args: kv: [n, ..., layout.num_ele
_slot_scatter11``cache[block, offset] = values``,在 Ascend 上绕开 IndexPutV2 的 32 位偏移回绕
_masked_cache_store21
store_kv_cache_ref33PyTorch reference for :func:`store_kv_cache`.
_store_test_slots32Unique valid slots; random and sequential use the same set [0, n).
_guarded_store_cache45Independent actual/reference byte backings, including every canary/gap.
test_store_cache60
test_store_cache_benchmark32
(已列出全部 9 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/store_mtp_info.py查看源码227 行
符号行数 · 说明(ast 提取)
store_mtp_info68Write one contiguous ``nextn`` block per request into MTP pools. Args: write_slots: [req_cnt], i
store_mtp_info_ref24PyTorch reference implementation of :func:`store_mtp_info`.
test_store_mtp_info57
test_store_mtp_info_benchmark55
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/structure_output.py查看源码151 行
符号行数 · 说明(ast 提取)
apply_token_bitmask_by_step_inplace26Args: logits: [total_q, vocab_size], fp32, packed by request, in-place output bitmask: [num_requ
apply_token_bitmask_by_step_inplace_ref22
test_apply_token_bitmask_by_step_inplace_without_ftp13
test_apply_token_bitmask_by_step_inplace16
test_apply_token_bitmask_by_step_inplace_without_ftp_benchmark22
test_apply_token_bitmask_by_step_inplace_benchmark24
(已列出全部 6 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/sum_smaller_probs.py查看源码84 行
符号行数 · 说明(ast 提取)
get_sum_smaller_probs19Inclusive CDF after sorting tokens by ascending probability. Per row, sum probabilities through
sum_smaller_probs_ref14
test_sum_smaller_probs11
test_sum_smaller_probs_benchmark19
(已列出全部 4 个顶层符号)
deepinfer/model_executor/layers/tilelang_ops/swa_index.py查看源码118 行
符号行数 · 说明(ast 提取)
expand_swa_index23Expand two KV segments per token into dense prefill SWA indices. Args: pivots: Contiguous int32
expand_swa_index_ref10Original PyTorch expansion of int32 [num_tokens, 4] into [num_tokens, width].
_make_pivots21
test_expand_swa_index12
test_expand_swa_index_benchmark16
(已列出全部 5 个顶层符号)
deepinfer/model_executor/layers/vocab_parallel_embedding.py查看源码31 行
符号行数 · 说明(ast 提取)
class VocabParallelEmbedding152 个方法
└ __init__10
└ forward3
class ParallelLMHead41 个方法
└ forward3
(已列出全部 2 个顶层符号 + 3 个方法)
首页