Instructions to use marcsun13/topk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Kernels
How to use marcsun13/topk with Kernels:
# !pip install kernels from kernels import get_kernel # a version (or an explicit revision) is required; see the "Files and versions" tab for the available ones kernel = get_kernel("marcsun13/topk", version=1) - Notebooks
- Google Colab
- Kaggle
Download build.toml from marcsun13/topk: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/marcsun13/topk/resolve/main/build.toml
- Command line
-
hf download hf://marcsun13/topk/build.toml
-
curl -L -o build.toml https://huggingface.co/marcsun13/topk/resolve/main/build.toml
1.04 kB
| # One backend per `[kernel.*]` section, all implementing the entry points declared in | |
| # torch-ext/torch_binding.h. | |
| # | |
| # The backend lives in `topk_metal/` while the package is just `topk`: a CUDA port would be a | |
| # `topk_cuda/` section beside it, with no change to the bindings' schema or the Python API. | |
| # | |
| # Unlike the `ggml-*` packages there is no `vendor/`: this kernel is not a port of anything upstream. | |
| # ggml has no top-k of its own -- `GGML_OP_TOP_K` dispatches `kernel_argsort_f32_i32_desc`, a full | |
| # bitonic sort -- so there was nothing to vendor and this is written against `metal_stdlib` alone. | |
| [general] | |
| name = "topk" | |
| version = 1 | |
| license = "MIT" | |
| backends = ["metal"] | |
| [general.hub] | |
| repo-id = "marcsun13/topk" | |
| [torch] | |
| src = [ | |
| "torch-ext/torch_binding.cpp", | |
| "torch-ext/torch_binding.h", | |
| ] | |
| [kernel.topk_metal] | |
| backend = "metal" | |
| depends = ["torch"] | |
| include = ["topk_metal", "torch-ext"] | |
| src = [ | |
| "topk_metal/topk_metal.cpp", | |
| "topk_metal/dispatch.mm", | |
| "topk_metal/common.h", | |
| "topk_metal/top_k.metal", | |
| ] | |