Skip to content

Commit 3540351

Browse files
xslingcnYiyanZhai
authored andcommitted
docs: python api reference (#109)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Integrated Vercel Analytics for usage insights. * Automated generation and publication of Python API docs to the web app. * Improved docs routing with targeted caching for faster load times. * **Documentation** * Added a comprehensive Python API reference covering apply, tracing, and schema modules. * **Chores** * Updated build/prebuild flow and packaging to produce and serve docs; added doc build requirements and new ignore patterns. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 4965e9c commit 3540351

19 files changed

+470
-26
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ MANIFEST
3838
!web/**/lib/
3939
!web/**/lib/**
4040

41+
# Sphinx
42+
.sphinx-deps
43+
web/**/public
44+
4145
.claude
4246
.vscode
4347

46.3 KB
Loading
49 KB
Loading

docs/api/conf.py

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
import os
2+
import sys
3+
from datetime import datetime
4+
from pathlib import Path
5+
from typing import Any, List
6+
7+
import tomli
8+
9+
# import tlcpack_sphinx_addon
10+
# Configuration file for the Sphinx documentation builder.
11+
#
12+
# For the full list of built-in configuration values, see the documentation:
13+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
14+
15+
# -- Project information -----------------------------------------------------
16+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
17+
18+
repo_root = Path(__file__).resolve().parents[2]
19+
sys.path.insert(0, str(repo_root))
20+
os.environ["BUILD_DOC"] = "1"
21+
22+
project = "FlashInfer-Bench"
23+
author = "FlashInfer Community"
24+
copyright = f"{datetime.now().year}, {author}"
25+
26+
try:
27+
from setuptools_scm import get_version as scm_get_version
28+
except Exception:
29+
scm_get_version = None
30+
31+
32+
def _compute_version() -> str:
33+
v = os.environ.get("FLASHINFER_BENCH_VERSION")
34+
if v:
35+
return v
36+
if scm_get_version is not None:
37+
try:
38+
return scm_get_version(root=str(repo_root), fallback_version="0.0.0")
39+
except Exception:
40+
pass
41+
try:
42+
with open(repo_root / "pyproject.toml", "rb") as f:
43+
data = tomli.load(f)
44+
v = data.get("project", {}).get("version")
45+
if v:
46+
return v
47+
except Exception:
48+
pass
49+
return "0.0.0+docs"
50+
51+
52+
__version__ = _compute_version()
53+
54+
55+
# -- General configuration ---------------------------------------------------
56+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
57+
58+
extensions = [
59+
"myst_parser",
60+
"sphinx_tabs.tabs",
61+
"sphinx.ext.autodoc",
62+
"sphinx.ext.napoleon",
63+
"sphinx.ext.autosummary",
64+
"sphinx.ext.mathjax",
65+
"sphinxcontrib.autodoc_pydantic",
66+
]
67+
68+
autodoc_mock_imports = [
69+
"torch",
70+
"triton",
71+
"flashinfer._build_meta",
72+
"cuda",
73+
"numpy",
74+
"einops",
75+
"mpi4py",
76+
"safetensors",
77+
]
78+
autodoc_default_flags = ["members"]
79+
autodoc_class_signature = "separated"
80+
autodoc_member_order = "bysource"
81+
autodoc_default_options = {"exclude-members": "model_config"}
82+
autodoc_typehints = "both"
83+
84+
autodoc_pydantic_model_show_validator_summary = False
85+
autodoc_pydantic_model_show_validator_members = False
86+
autodoc_pydantic_model_show_config_summary = False
87+
autodoc_pydantic_field_list_validators = False
88+
autodoc_pydantic_model_summary_list_order = "bysource"
89+
autodoc_pydantic_model_member_order = "bysource"
90+
91+
autosummary_generate = True
92+
93+
source_suffix = [".rst", ".md"]
94+
95+
language = "en"
96+
97+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".sphinx-deps", ".sphinx-deps/**"]
98+
99+
# The name of the Pygments (syntax highlighting) style to use.
100+
pygments_style = "sphinx"
101+
102+
# A list of ignored prefixes for module index sorting.
103+
# If true, `todo` and `todoList` produce output, else they produce nothing.
104+
todo_include_todos = False
105+
106+
myst_enable_extensions = [
107+
"dollarmath",
108+
"amsmath",
109+
"deflist",
110+
"colon_fence",
111+
"html_image",
112+
"linkify",
113+
"substitution",
114+
]
115+
116+
myst_heading_anchors = 3
117+
myst_ref_domains = ["std", "py"]
118+
myst_all_links_external = False
119+
120+
# -- Options for HTML output ----------------------------------------------
121+
122+
html_theme = "shibuya"
123+
124+
templates_path: List[Any] = ["_templates"]
125+
126+
html_static_path = ["_static"]
127+
128+
129+
html_theme_options = {
130+
"accent_color": "indigo",
131+
"logo_target": "/",
132+
"light_logo": "_static/brand/fib-light.png",
133+
"dark_logo": "_static/brand/fib-dark.png",
134+
"nav_links": [{"title": "Docs", "url": f"/docs", "external": True}],
135+
"globaltoc_expand_depth": 1,
136+
}

docs/api/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# FlashInfer-Bench Python API
2+
3+
```{toctree}
4+
:maxdepth: 2
5+
:caption: API Reference
6+
7+
rst/apply
8+
rst/tracing
9+
rst/schema
10+
```

docs/api/requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
autodoc_pydantic>=2.1,<3
2+
myst-parser[linkify]>=4,<5
3+
setuptools-scm>=8
4+
shibuya
5+
sphinx==7.4.*
6+
sphinx-tabs>=3.4.7
7+
sphinx-toolbox
8+
tomli

docs/api/rst/apply.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
flashinfer_bench.apply
2+
======================
3+
4+
.. currentmodule:: flashinfer_bench
5+
6+
``flashinfer_bench.apply`` provides a tool that meets two needs:
7+
8+
1. **Apply** best-performing one from FlashInfer Trace database to the LLM engine
9+
2. **Trace** the kernel in the LLM engine and dump its input as FlashInfer Trace's workload format
10+
11+
.. autofunction:: apply
12+
13+
.. autofunction:: enable_apply
14+
15+
.. autofunction:: disable_apply

docs/api/rst/schema.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FlashInfer Trace Schema Python API
2+
==================================
3+
4+
FlashInfer-Bench provides a schema for the FlashInfer Trace database. This document includes
5+
the Python API for the schema, including
6+
7+
- The :class:`Definition` class, which defines the kernel specification.
8+
- The :class:`Solution` class, which defines the kernel solution.
9+
- The :class:`Trace` class, which defines the kernel execution trace.
10+
- The :class:`TraceSet` class, which defines a set of kernel execution traces.
11+
12+
.. toctree::
13+
:maxdepth: 2
14+
15+
schema_definition
16+
schema_solution
17+
schema_trace
18+
schema_traceset

docs/api/rst/schema_definition.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Definition
2+
==========
3+
4+
.. currentmodule:: flashinfer_bench.data
5+
6+
.. autopydantic_model:: Definition
7+
8+
.. autopydantic_model:: AxisConst
9+
10+
.. autopydantic_model:: AxisVar
11+
12+
.. autopydantic_model:: TensorSpec
13+
14+
.. autoclass:: flashinfer_bench.data.definition.DType
15+
:members:

docs/api/rst/schema_solution.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Solution
2+
========
3+
4+
.. currentmodule:: flashinfer_bench.data
5+
6+
.. autopydantic_model:: Solution
7+
8+
.. autoclass:: SupportedLanguages
9+
:members:
10+
11+
.. autopydantic_model:: SourceFile
12+
13+
.. autopydantic_model:: BuildSpec

0 commit comments

Comments
 (0)