Skip to content
Open
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
34 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
76f8160
doc improvements
acl-cqc Mar 23, 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
12 changes: 4 additions & 8 deletions docs/source/examples/data/typed_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,21 @@ class DoublerOutput(NamedTuple):
def typed_doubler():
g = GraphBuilder(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)
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])
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):
Expand All @@ -46,5 +43,4 @@ class TypedEvalOutputs(NamedTuple):
def typed_eval():
g = GraphBuilder(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))
7 changes: 3 additions & 4 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 GraphBuilder, FinishedGraph\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",
"def error_graph() -> FinishedGraph:\n",
" g = GraphBuilder(EmptyModel, TKR[str])\n",
" output = g.task(fail())\n",
" g.outputs(output)\n",
" return g"
" return g.finish_with_outputs(output)"
]
},
{
Expand Down
12 changes: 5 additions & 7 deletions docs/source/examples/hamiltonian.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -201,8 +200,7 @@
" 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
2 changes: 1 addition & 1 deletion docs/source/examples/hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
graph = GraphBuilder(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)
4 changes: 2 additions & 2 deletions docs/source/examples/hello_world_graph.ipynb
Original file line number Diff line number Diff line change
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
7 changes: 3 additions & 4 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 GraphBuilder, FinishedGraph\n",
"from substitution_worker import substitute\n",
"from tierkreis.pytket_worker import (\n",
" add_measure_all,\n",
Expand All @@ -72,7 +72,7 @@
"from tierkreis.aer_worker import submit_single\n",
"\n",
"\n",
"def symbolic_execution() -> GraphBuilder:\n",
"def symbolic_execution() -> FinishedGraph:\n",
" \"\"\"A graph that substitutes 3 parameters into a circuit and gets an expectation value.\"\"\"\n",
" g = GraphBuilder(SymbolicCircuitsInputs, SymbolicCircuitsOutputs)\n",
" a = g.inputs.a\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
12 changes: 6 additions & 6 deletions docs/source/examples/multiple_outputs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"# 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 @@ -152,7 +152,7 @@
"g = GraphBuilder(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
15 changes: 6 additions & 9 deletions docs/source/examples/parallelism.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
" )\n",
" )\n",
" res = g.task(aer_run(compiled_circuit, circuit_shots.b))\n",
" g.outputs(res)\n",
" return g\n",
" return g.finish_with_outputs(res)\n",
"\n",
"\n",
"def qulacs_simulate_single():\n",
Expand All @@ -83,8 +82,7 @@
" )\n",
" )\n",
" res = g.task(qulacs_run(compiled_circuit, circuit_shots.b))\n",
" g.outputs(res)\n",
" return g"
" return g.finish_with_outputs(res)"
]
},
{
Expand Down Expand Up @@ -116,8 +114,7 @@
" g.task(str_eq(g.inputs.simulator_name, g.const(\"aer\"))), aer_res, qulacs_res\n",
" )\n",
"\n",
" g.outputs(res)\n",
" return g"
" return g.finish_with_outputs(res)"
]
},
{
Expand Down Expand Up @@ -207,7 +204,7 @@
"source": [
"res = g.map(compile_simulate_single(), job_inputs)\n",
"\n",
"g.outputs(res)"
"workflow = g.finish_with_outputs(res)"
]
},
{
Expand Down Expand Up @@ -268,7 +265,7 @@
"inputs[\"simulator_name\"] = \"aer\"\n",
"print(\"Simulating using aer...\")\n",
"start = time.time()\n",
"run_graph(storage, executor, g, inputs, polling_interval_seconds=0.1)\n",
"run_graph(storage, executor, workflow, inputs, polling_interval_seconds=0.1)\n",
"print(f\"time taken: {time.time() - start}\")"
]
},
Expand All @@ -292,7 +289,7 @@
"print(\"Simulating using qulacs...\")\n",
"storage.clean_graph_files()\n",
"start = time.time()\n",
"run_graph(storage, executor, g, inputs, polling_interval_seconds=0.1)\n",
"run_graph(storage, executor, workflow, inputs, polling_interval_seconds=0.1)\n",
"print(f\"time taken: {time.time() - start}\")"
]
},
Expand Down
13 changes: 6 additions & 7 deletions docs/source/examples/qsci.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,12 @@
"outputs": [],
"source": [
"from tierkreis.aer_worker import submit_single\n",
"from tierkreis.builder import GraphBuilder\n",
"from tierkreis.builder import GraphBuilder, FinishedGraph\n",
"from tierkreis.controller.data.models import TKR, OpaqueType\n",
"from tierkreis.quantinuum_worker import compile_circuit_quantinuum\n",
"\n",
"\n",
"def _compile_and_run() -> GraphBuilder[\n",
"def _compile_and_run() -> FinishedGraph[\n",
" TKR[OpaqueType[\"pytket._tket.circuit.Circuit\"]], # noqa: F821\n",
" TKR[OpaqueType[\"pytket.backends.backendresult.BackendResult\"]], # noqa: F821\n",
"]:\n",
Expand All @@ -361,8 +361,7 @@
" compiled_circuit = g.task(compile_circuit_quantinuum(g.inputs))\n",
" backend_result = g.task(submit_single(compiled_circuit, n_shots))\n",
"\n",
" g.outputs(backend_result)\n",
" return g"
" return g.finish_with_outputs(backend_result)"
]
},
{
Expand Down Expand Up @@ -474,7 +473,7 @@
" ),\n",
")\n",
"\n",
"qsci_graph.outputs(QSCIOutputs(energy))"
"workflow = qsci_graph.finish_with_outputs(QSCIOutputs(energy))"
]
},
{
Expand Down Expand Up @@ -522,7 +521,7 @@
"run_graph(\n",
" storage,\n",
" multi_executor,\n",
" qsci_graph,\n",
" workflow,\n",
" {\n",
" k: json.dumps(v).encode()\n",
" for k, v in (\n",
Expand Down Expand Up @@ -556,7 +555,7 @@
" },\n",
" polling_interval_seconds=0.01,\n",
")\n",
"output = read_outputs(qsci_graph, storage)"
"output = read_outputs(workflow, storage)"
]
}
],
Expand Down
10 changes: 5 additions & 5 deletions docs/source/examples/scipy.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"\n",
"twodim = sample_graph.task(reshape(onedim, sample_graph.const([5, 10])))\n",
"a = sample_graph.task(transpose(twodim))\n",
"sample_graph.outputs(ScipyOutputs(a, scalar))"
"workflow = sample_graph.finish_with_outputs(ScipyOutputs(a, scalar))"
]
},
{
Expand Down Expand Up @@ -163,9 +163,9 @@
"\n",
"storage = FileStorage(UUID(int=207), do_cleanup=True, name=\"scipy_graph\")\n",
"executor = UvExecutor(Path().parent / \"example_workers\", storage.logs_path)\n",
"run_graph(storage, executor, sample_graph, {})\n",
"run_graph(storage, executor, workflow, {})\n",
"\n",
"outputs = read_outputs(sample_graph, storage)"
"outputs = read_outputs(workflow, storage)"
]
},
{
Expand Down Expand Up @@ -211,9 +211,9 @@
"source": [
"os.environ[\"SER_METHOD\"] = \"tolist\"\n",
"storage.clean_graph_files()\n",
"run_graph(storage, executor, sample_graph, {})\n",
"run_graph(storage, executor, workflow, {})\n",
"\n",
"outputs = read_outputs(sample_graph, storage)"
"outputs = read_outputs(workflow, storage)"
]
}
],
Expand Down
15 changes: 6 additions & 9 deletions docs/source/examples/signing_graph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@
"\n",
" signing_result = g.task(sign(private_key, passphrase, message)).hex_signature\n",
" verification_result = g.task(verify(public_key, signing_result, message))\n",
" g.outputs(verification_result)\n",
"\n",
" return g"
" return g.finish_with_outputs(verification_result)"
]
},
{
Expand Down Expand Up @@ -218,8 +216,8 @@
"from tierkreis.storage import read_outputs\n",
"from tierkreis import run_graph\n",
"\n",
"run_graph(storage, executor, signing_graph().get_data(), {})\n",
"is_verified = read_outputs(signing_graph().get_data(), storage)\n",
"run_graph(storage, executor, signing_graph(), {})\n",
"is_verified = read_outputs(signing_graph(), storage)\n",
"print(is_verified)"
]
},
Expand Down Expand Up @@ -254,14 +252,13 @@
" message = g.const(b\"dummymessage\")\n",
" output = g.task(script(\"tee\", message))\n",
"\n",
" g.outputs(output)\n",
" return g\n",
" return g.finish_with_outputs(output)\n",
"\n",
"\n",
"storage.clean_graph_files()\n",
"stdinout = StdInOut(registry_path, storage.workflow_dir)\n",
"run_graph(storage, stdinout, stdinout_graph().get_data(), {})\n",
"out = read_outputs(stdinout_graph().get_data(), storage)\n",
"run_graph(storage, stdinout, stdinout_graph(), {})\n",
"out = read_outputs(stdinout_graph(), storage)\n",
"print(out)"
]
}
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/storage_and_executors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
" device_name=g.const(\"H2-1SC\"),\n",
" ),\n",
")\n",
"g.outputs(results)"
"workflow = g.finish_with_outputs(results)"
]
},
{
Expand Down Expand Up @@ -171,7 +171,7 @@
"from tierkreis import run_graph\n",
"\n",
"circuit = circuit_from_qasm(Path().parent / \"data\" / \"ghz_state_n23.qasm\")\n",
"run_graph(storage, executor, g, circuit)"
"run_graph(storage, executor, workflow, circuit)"
]
},
{
Expand Down
Loading
Loading