Skip to content

Commit 9d92aa8

Browse files
committed
api docs
1 parent 4b068e6 commit 9d92aa8

File tree

6 files changed

+44
-17
lines changed

6 files changed

+44
-17
lines changed

docs/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
API
2+
===
3+
4+
5+
.. autoclass:: klay.Circuit()
6+
:members:
7+
:undoc-members:

docs/circuit_creation.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ An SDD can be loaded from a file as follows.
1212

1313
.. code-block:: Python
1414
15-
import klaycircuits
15+
from klaycircuits import Circuit
1616
17-
circuit = klaycircuits.Circuit()
17+
circuit = Circuit()
1818
circuit.add_SDD_from_file("path/to/my.sdd")
1919
2020
Similarly, for d4 we can use
2121

2222
.. code-block:: Python
2323
24-
circuit = klaycircuits.Circuit()
24+
circuit = Circuit()
2525
circuit.add_D4_from_file("path/to/my.nnf")
2626
2727
SDDs can also be loaded directly from a PySDD :code:`SddNode` object.
@@ -33,7 +33,7 @@ SDDs can also be loaded directly from a PySDD :code:`SddNode` object.
3333
manager = SddManager(var_count = 2)
3434
sdd_node = manager.literal(1) & manager.literal(2)
3535
36-
circuit = klaycircuits.Circuit()
36+
circuit = Circuit()
3737
circuit.add_sdd(sdd_node)
3838
3939
@@ -44,7 +44,7 @@ If you want to evaluate multiple circuits in parallel, you can merge them into a
4444

4545
.. code-block:: Python
4646
47-
circuit = klaycircuits.Circuit()
47+
circuit = Circuit()
4848
circuit.add_sdd(first_sdd)
4949
circuit.add_sdd(second_sdd)
5050
@@ -60,7 +60,7 @@ We start by defining some literals.
6060

6161
.. code-block:: Python
6262
63-
circuit = klaycircuits.Circuit()
63+
circuit = Circuit()
6464
a = circuit.literal_node(1)
6565
b = circuit.literal_node(-2)
6666

docs/circuit_eval.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.. _circuit_eval:
2+
3+
Circuit Evaluation
4+
==================
5+
6+
Once you created a circuit, you probably want to evaluate. KLay supports multiple backends to support this evaluation.
7+
8+
PyTorch
9+
*******
10+
11+
TODO.
12+
13+
Jax
14+
***
15+
16+
TODO.

docs/conf.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
# -- General configuration ---------------------------------------------------
1515
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1616

17-
extensions = []
17+
extensions = [
18+
"sphinx.ext.duration",
19+
"sphinx.ext.doctest",
20+
"sphinx.ext.autodoc",
21+
"sphinx.ext.autosummary",
22+
"sphinx.ext.intersphinx",
23+
]
1824

1925
templates_path = ['_templates']
2026
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

docs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ KLay Documentation
99
KLay is a Python library for accelerating inference on sparse arithmetic circuits.
1010

1111
At its core, KLay transforms sparse directed acyclic graphs into layers that can be executed in parallel.
12+
The design of KLay is described in our paper `KLay: Accelerating Arithmetic Circuits for Neurosymbolic AI <https://arxiv.org/pdf/2410.11415>`_, published at ICLR 2025.
1213

1314
.. image:: _static/scatter_reduce.png
1415
:width: 400
@@ -23,4 +24,6 @@ Contents
2324
Home <self>
2425
quickstart
2526
circuit_creation
27+
circuit_eval
28+
api
2629

docs/quickstart.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ For more information, check out the :ref:`circuit_construction` guide.
2222

2323
.. code-block:: Python
2424
25-
import klaycircuits
25+
from klaycircuits import Circuit
2626
27-
circuit = klaycircuits.Circuit()
27+
circuit = Circuit()
2828
circuit.add_sdd(sdd_node)
2929
3030
Now that we have the circuit, we can evaluate it. To do this, we first turn the circuit into a PyTorch module.
@@ -36,18 +36,13 @@ Now that we have the circuit, we can evaluate it. To do this, we first turn the
3636
module = circuit.to_torch_module()
3737
module = module.to("cuda:0")
3838
39-
We can use our circuit as any other PyTorch module. The input should be a tensor with the weights for each literal, and the output is the result of evaluating circuit.
39+
We can use our circuit as any other PyTorch module.
40+
The input should be a tensor with the weights for each literal, and the output is the result of evaluating circuit.
41+
For more details, see the :ref:`circuit_eval` guide.
4042

4143
.. code-block:: Python
4244
4345
weights = torch.tensor([...], device="cuda:0")
4446
result = module(weights)
4547
result.backward()
4648
47-
Backends
48-
********
49-
50-
KLay needs a backend to evaluate the circuit in. So far, we implemented two different backends.
51-
52-
- PyTorch: :code:`torch_module = circuit.to_torch_module()`
53-
- Jax: :code:`jax_function = circuit.to_jax_function()`

0 commit comments

Comments
 (0)