Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c2391c4
add some interesting functions to worker (and, update justfile)
acl-cqc Mar 5, 2026
9f1bf66
tests
acl-cqc Mar 5, 2026
4307b17
Merge remote-tracking branch 'origin/main' into acl/test_worker_graphs
acl-cqc Mar 5, 2026
75e2a38
Hide ApplyTwiceInput
acl-cqc Mar 5, 2026
de7aca6
Test that GraphData is a PType
acl-cqc Mar 4, 2026
692b563
Define FinishedGraph, return instead of GraphBuilder via GB.outputs(...)
acl-cqc Mar 5, 2026
05a29f3
GraphBuilder: declare inputs_type
acl-cqc Mar 3, 2026
1f8a6a7
FinishedGraph: frozen=True, remove get_data()
acl-cqc Mar 3, 2026
4a7bd52
Rename GraphBuilder.(=>finish_with_)outputs
acl-cqc Mar 4, 2026
d0fbe1d
Move FinishedGraph into types.py (but keep imports via builder for now)
acl-cqc Mar 4, 2026
aed05b0
types.py: include FinishedGraph in PType
acl-cqc Mar 4, 2026
3f47680
Remove GraphBuilder.get_data(), test worker returns FinishedGraph - v…
acl-cqc Mar 5, 2026
6600e54
Test roundtrip of a FinishedGraph, given annotation; fix
acl-cqc Mar 5, 2026
5794e3f
TypedGraphRef = TKR[FinishedGraph...]+reified inputs, worker funcs ta…
acl-cqc Mar 5, 2026
acfdfa5
fix pyright by Manually copying ApplyTwiceInput from main to stubs w/…
acl-cqc Mar 5, 2026
334b5f6
Error if supposed Struct contains a TKR
acl-cqc Mar 5, 2026
9c29934
Revert "Error if supposed Struct contains a TKR"
acl-cqc Mar 5, 2026
66ec5c5
Better const()
acl-cqc Mar 5, 2026
81db891
fmt
acl-cqc Mar 6, 2026
454c18f
Advanced bodging of stub generator
acl-cqc Mar 6, 2026
def4fd1
Revert "Advanced bodging of stub generator"
acl-cqc Mar 7, 2026
be748ce
much simpler bodge
acl-cqc Mar 7, 2026
3622808
be a lot stricter with asserts
acl-cqc Mar 7, 2026
408ffe5
Merge remote-tracking branch 'origin/main' into acl/test_worker_graphs
acl-cqc Mar 9, 2026
adfd3c0
Merge remote-tracking branch 'origin/main' into acl/test_worker_graphs
acl-cqc Mar 9, 2026
8c2ba50
Merge branch 'acl/test_worker_graphs' into acl/finished-graph
acl-cqc Mar 9, 2026
419c026
Update ipynb's + md's, bleurgh
acl-cqc Mar 9, 2026
138f028
Default GenericType to represent ptype in order to fix parsed types
acl-cqc Mar 9, 2026
1543bfa
Rename FinishedGraph -> Workflow
acl-cqc Mar 15, 2026
deabc7a
GraphBuilder -> Graph
acl-cqc Mar 15, 2026
e30c5bb
Revert/reduce change to test_types.py
acl-cqc Mar 16, 2026
6ccf080
Add ModelConvertible, allowing parametrized; Remove Workflow referenc…
acl-cqc Mar 16, 2026
4910e5d
Visualizer: restore use of Graph
acl-cqc Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/core_concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ From the data dependencies, the runtime environment can infer which tasks it nee
### Types

In Tierkreis, it is possible to associate types with edges (data) at construction.
Type information can be used by the `GraphBuilder` to infer additional information about the graph to prevent runtime errors.
Type information can be used by the `Graph` to infer additional information about the graph to prevent runtime errors.

## Execution model

Expand Down
22 changes: 9 additions & 13 deletions docs/source/examples/data/typed_eval.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import NamedTuple

from tierkreis.builder import GraphBuilder
from tierkreis.builder import Graph
from tierkreis.builtins import iadd, itimes
from tierkreis.controller.data.core import EmptyModel
from tierkreis.controller.data.models import TKR
Expand All @@ -17,34 +17,30 @@ class DoublerOutput(NamedTuple):


def typed_doubler():
g = GraphBuilder(TKR[int], TKR[int])
g = Graph(TKR[int], TKR[int])
out = g.task(itimes(a=g.const(2), b=g.inputs))
g.outputs(out)
return g
return g.finish_with_outputs(out)


def typed_doubler_plus_multi():
g = GraphBuilder(DoublerInput, DoublerOutput)
g = Graph(DoublerInput, DoublerOutput)
mul = g.task(itimes(a=g.inputs.x, b=g.const(2)))
out = g.task(iadd(a=mul, b=g.inputs.intercept))
g.outputs(DoublerOutput(a=g.inputs.x, value=out))
return g
return g.finish_with_outputs(DoublerOutput(a=g.inputs.x, value=out))


def typed_doubler_plus():
g = GraphBuilder(DoublerInput, TKR[int])
g = Graph(DoublerInput, TKR[int])
mul = g.task(itimes(a=g.inputs.x, b=g.const(2)))
out = g.task(iadd(a=mul, b=g.inputs.intercept))
g.outputs(out)
return g
return g.finish_with_outputs(out)


class TypedEvalOutputs(NamedTuple):
typed_eval_output: TKR[int]


def typed_eval():
g = GraphBuilder(EmptyModel, TypedEvalOutputs)
g = Graph(EmptyModel, TypedEvalOutputs)
e = g.eval(typed_doubler_plus(), DoublerInput(x=g.const(6), intercept=g.const(0)))
g.outputs(TypedEvalOutputs(typed_eval_output=e))
return g
return g.finish_with_outputs(TypedEvalOutputs(typed_eval_output=e))
9 changes: 4 additions & 5 deletions docs/source/examples/errors_and_debugging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph, Workflow\n",
"from tierkreis.controller.data.core import EmptyModel\n",
"from tierkreis.controller.data.models import TKR\n",
"\n",
"from error_worker import fail\n",
"\n",
"\n",
"def error_graph() -> GraphBuilder:\n",
" g = GraphBuilder(EmptyModel, TKR[str])\n",
"def error_graph() -> Workflow:\n",
" g = Graph(EmptyModel, TKR[str])\n",
" output = g.task(fail())\n",
" g.outputs(output)\n",
" return g"
" return g.finish_with_outputs(output)"
]
},
{
Expand Down
20 changes: 9 additions & 11 deletions docs/source/examples/hamiltonian.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph\n",
"from tierkreis.controller.data.models import TKR\n",
"from typing import NamedTuple, Literal\n",
"\n",
Expand All @@ -84,7 +84,7 @@
" ansatz: TKR[Literal[\"pytket._tket.circuit.Circuit\"]]\n",
"\n",
"\n",
"simulation_graph = GraphBuilder(SymbolicExecutionInputs, TKR[float])\n",
"simulation_graph = Graph(SymbolicExecutionInputs, TKR[float])\n",
"substituted_circuit = simulation_graph.task(\n",
" substitute(\n",
" simulation_graph.inputs.ansatz,\n",
Expand Down Expand Up @@ -125,7 +125,7 @@
"\n",
"\n",
"def exp_val():\n",
" g = GraphBuilder(SubmitInputs, TKR[float])\n",
" g = Graph(SubmitInputs, TKR[float])\n",
"\n",
" circuit = g.inputs.circuit\n",
" pauli_string = g.inputs.pauli_string\n",
Expand All @@ -137,8 +137,7 @@
"\n",
" backend_result = g.task(submit_single(compiled_circuit, n_shots))\n",
" av = g.task(expectation(backend_result))\n",
" g.outputs(av)\n",
" return g"
" return g.finish_with_outputs(av)"
]
},
{
Expand Down Expand Up @@ -195,14 +194,13 @@
"\n",
"\n",
"def compute_terms():\n",
" g = GraphBuilder(ComputeTermsInputs, TKR[float])\n",
" g = Graph(ComputeTermsInputs, TKR[float])\n",
"\n",
" res_0, res_1 = g.task(untuple(g.inputs.value))\n",
" prod = g.task(times(res_0, res_1))\n",
" sum = g.task(add(g.inputs.accum, prod))\n",
"\n",
" g.outputs(sum)\n",
" return g"
" return g.finish_with_outputs(sum)"
]
},
{
Expand Down Expand Up @@ -243,7 +241,7 @@
"outputs": [],
"source": [
"computed = simulation_graph.eval(fold_graph(compute_terms()), fold_inputs)\n",
"simulation_graph.outputs(computed)"
"workflow = simulation_graph.finish_with_outputs(computed)"
]
},
{
Expand Down Expand Up @@ -340,11 +338,11 @@
"run_graph(\n",
" storage,\n",
" multi_executor,\n",
" simulation_graph,\n",
" workflow,\n",
" inputs,\n",
" polling_interval_seconds=0.2,\n",
")\n",
"output = read_outputs(simulation_graph, storage)\n",
"output = read_outputs(workflow, storage)\n",
"print(output)"
]
}
Expand Down
6 changes: 3 additions & 3 deletions docs/source/examples/hello_world.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from tierkreis.builder import GraphBuilder
from tierkreis.builder import Graph
from tierkreis.controller.data.models import TKR

from hello_world_worker import greet


graph = GraphBuilder(inputs_type=TKR[str], outputs_type=TKR[str])
graph = Graph(inputs_type=TKR[str], outputs_type=TKR[str])
hello = graph.const("Hello ")
output = graph.task(greet(greeting=hello, subject=graph.inputs))
graph.outputs(output)
graph.finish_with_outputs(output)
8 changes: 4 additions & 4 deletions docs/source/examples/hello_world_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph\n",
"from tierkreis.controller.data.models import TKR"
]
},
Expand All @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"graph = GraphBuilder(inputs_type=TKR[str], outputs_type=TKR[str])"
"graph = Graph(inputs_type=TKR[str], outputs_type=TKR[str])"
]
},
{
Expand Down Expand Up @@ -116,7 +116,7 @@
"metadata": {},
"outputs": [],
"source": [
"graph.outputs(output)"
"workflow = graph.finish_with_outputs(output)"
]
},
{
Expand Down Expand Up @@ -148,7 +148,7 @@
"\n",
"def main(input_value: str) -> None:\n",
" run_workflow(\n",
" graph.data,\n",
" workflow,\n",
" {\"value\": input_value},\n",
" name=\"hello_world\",\n",
" run_id=100, # Assign a fixed uuid for our workflow.\n",
Expand Down
9 changes: 4 additions & 5 deletions docs/source/examples/hpc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph, Workflow\n",
"from substitution_worker import substitute\n",
"from tierkreis.pytket_worker import (\n",
" add_measure_all,\n",
Expand All @@ -72,9 +72,9 @@
"from tierkreis.aer_worker import submit_single\n",
"\n",
"\n",
"def symbolic_execution() -> GraphBuilder:\n",
"def symbolic_execution() -> Workflow:\n",
" \"\"\"A graph that substitutes 3 parameters into a circuit and gets an expectation value.\"\"\"\n",
" g = GraphBuilder(SymbolicCircuitsInputs, SymbolicCircuitsOutputs)\n",
" g = Graph(SymbolicCircuitsInputs, SymbolicCircuitsOutputs)\n",
" a = g.inputs.a\n",
" b = g.inputs.b\n",
" c = g.inputs.c\n",
Expand All @@ -88,8 +88,7 @@
" backend_result = g.task(submit_single(circuit=compiled_circuit, n_shots=n_shots))\n",
" av = g.task(expectation(backend_result=backend_result))\n",
"\n",
" g.outputs(SymbolicCircuitsOutputs(expectation=av))\n",
" return g"
" return g.finish_with_outputs(SymbolicCircuitsOutputs(expectation=av))"
]
},
{
Expand Down
20 changes: 10 additions & 10 deletions docs/source/examples/multiple_outputs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,17 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph\n",
"from tierkreis.controller.data.models import TKR\n",
"from multiple_outputs_worker import new_opaque_point, OpaquePoint # noqa: F811\n",
"\n",
"g = GraphBuilder(TKR[float], TKR[OpaquePoint])\n",
"g = Graph(TKR[float], TKR[OpaquePoint])\n",
"diag = g.task(new_opaque_point(g.inputs, g.inputs, g.inputs))\n",
"\n",
"# Uncommenting the following line will give an error.\n",
"# diag.x ## Cannot access attribute \"x\" for class \"TKR[OpaquePoint]\"\n",
"\n",
"g.outputs(diag)"
"workflow = g.finish_with_outputs(diag)"
]
},
{
Expand All @@ -92,8 +92,8 @@
"\n",
"storage = FileStorage(UUID(int=400), do_cleanup=True)\n",
"executor = UvExecutor(Path().parent / \"example_workers\", storage.logs_path)\n",
"run_graph(storage, executor, g, 4)\n",
"outputs = read_outputs(g, storage)\n",
"run_graph(storage, executor, workflow, 4)\n",
"outputs = read_outputs(workflow, storage)\n",
"assert outputs == {\"x\": 4, \"y\": 4, \"z\": 4}"
]
},
Expand Down Expand Up @@ -144,15 +144,15 @@
"metadata": {},
"outputs": [],
"source": [
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import Graph\n",
"from tierkreis.controller.data.models import TKR\n",
"from tierkreis.builtins.stubs import add\n",
"from multiple_outputs_worker import new_point # noqa: F811\n",
"\n",
"g = GraphBuilder(TKR[float], TKR[float])\n",
"g = Graph(TKR[float], TKR[float])\n",
"diag = g.task(new_point(g.inputs, g.inputs, g.inputs))\n",
"sum = g.task(add(diag.x, g.task(add(diag.y, diag.z))))\n",
"g.outputs(sum)"
"workflow = g.finish_with_outputs(sum)"
]
},
{
Expand All @@ -178,8 +178,8 @@
"\n",
"storage = FileStorage(UUID(int=400), do_cleanup=True)\n",
"executor = UvExecutor(Path().parent / \"example_workers\", storage.logs_path)\n",
"run_graph(storage, executor, g, 4)\n",
"outputs = read_outputs(g, storage)\n",
"run_graph(storage, executor, workflow, 4)\n",
"outputs = read_outputs(workflow, storage)\n",
"assert outputs == 12"
]
}
Expand Down
Loading
Loading