For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Mojo function
filtered_topk_block
def filtered_topk_block[in_dtype: DType, RB: RowBound, so: MutOrigin, //, sig_bits: Int = _hsel_sig_bits[in_dtype](), poison: Int = Int(0)](in_scores: ImmPointer[Scalar[in_dtype], ImmutAnyOrigin], out_idxs: MutPointer[Int32, MutAnyOrigin], N: Int, K: Int, row_bounds: RB, fallback: MutPointer[UInt8, MutAnyOrigin], smem: MutPointer[UInt32, so, address_space=AddressSpace.SHARED], row: Int, tid: Int)
Selects one row with the filtered select, or flags it for the full one.
One CTA's work: tid is the thread in a block of _PTOPK_BLOCK, smem
the CTA's FILTER_SMEM_BYTES of shared memory (8-byte aligned). Writes
fallback[row], 1 when the row's bound did not hold and nothing else was
written for it.
Parameters:
- in_dtype (
DType): Score dtype (inferred). - RB (
RowBound): Row bound type (inferred). - so (
MutOrigin): Origin ofsmem(inferred). - sig_bits (
Int): Significant bits of a score'sphi. - poison (
Int): A planted fault (FILTER_POISONS), 0 for none.
Args:
- in_scores (
ImmPointer[Scalar[in_dtype], ImmutAnyOrigin]): Row-major scores[rows, N]. - out_idxs (
MutPointer[Int32, MutAnyOrigin]): Row-major output[rows, K]. - N (
Int): Score columns per row, the row stride. - K (
Int): Columns selected per row. - row_bounds (
RB): Per-row live column counts and output sinks. - fallback (
MutPointer[UInt8, MutAnyOrigin]): One flag per row. - smem (
MutPointer[UInt32, so, address_space=AddressSpace.SHARED]): The CTA's shared memory. - row (
Int): The row. - tid (
Int): The thread in the block.