From d27410ec8ad5baa69af21c6f984134efe2fb4f88 Mon Sep 17 00:00:00 2001 From: cereallarceny Date: Tue, 30 Jul 2019 13:35:17 +0100 Subject: [PATCH 1/3] Closes #2412, remove simplification and detailing for plans that already have this done --- .../Part 8 - Introduction to Plans.ipynb | 310 ++++++++++++++++-- syft/federated/plan.py | 5 +- 2 files changed, 291 insertions(+), 24 deletions(-) diff --git a/examples/tutorials/Part 8 - Introduction to Plans.ipynb b/examples/tutorials/Part 8 - Introduction to Plans.ipynb index 61170150b59..278d101f6d8 100644 --- a/examples/tutorials/Part 8 - Introduction to Plans.ipynb +++ b/examples/tutorials/Part 8 - Introduction to Plans.ipynb @@ -90,6 +90,26 @@ "devices = device_1, device_2" ] }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'0.1.21a1'" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sy.__version__" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -101,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -121,16 +141,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -154,18 +174,18 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(Wrapper)>[PointerTensor | me:39792523445 -> device_1:44607711120]\n", + "(Wrapper)>[PointerTensor | me:41918042322 -> device_1:2708715446]\n", "\tTags: input_data \n", "\tShape: torch.Size([2])" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -184,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -193,7 +213,7 @@ "False" ] }, - "execution_count": 7, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -204,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -214,8 +234,8 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# This cell fails\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mplan_double_abs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m~/PySyft/syft/federated/plan.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, force, *locations)\u001b[0m\n\u001b[1;32m 526\u001b[0m \"\"\"\n\u001b[1;32m 527\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_built\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mforce\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 528\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"A plan needs to be built before being sent to a worker.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 529\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 530\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlocations\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mowner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_worker\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlocation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlocation\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlocations\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# This cell fails\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mplan_double_abs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/usr/local/lib/python3.7/site-packages/syft-0.1.21a1-py3.7.egg/syft/federated/plan.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, force, *locations)\u001b[0m\n\u001b[1;32m 526\u001b[0m \"\"\"\n\u001b[1;32m 527\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_built\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mforce\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 528\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"A plan needs to be built before being sent to a worker.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 529\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 530\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlocations\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mowner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_worker\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlocation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlocation\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlocations\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mRuntimeError\u001b[0m: A plan needs to be built before being sent to a worker." ] } @@ -234,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -243,7 +263,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -252,7 +272,7 @@ "True" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -261,6 +281,156 @@ "plan_double_abs.is_built" ] }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[[6,\n", + " [1,\n", + " [6,\n", + " [[6,\n", + " [[5, [b'__add__']],\n", + " [18, [86740191509, 21352736503, 18986127193, None, [2], False]],\n", + " [6, [[18, [86740191509, 21352736503, 18986127193, None, [2], False]]]],\n", + " [0, []]]],\n", + " [1, [42195613209]]]]]],\n", + " [6,\n", + " [1,\n", + " [6,\n", + " [[6,\n", + " [[5, [b'torch.abs']],\n", + " None,\n", + " [6, [[18, [75885061374, 42195613209, 18986127193, None, None, True]]]],\n", + " [0, []]]],\n", + " [1, [23105997167]]]]]],\n", + " [6, [9, 42195613209]]]" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plan_double_abs.readable_plan" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1,\n", + " (('__add__',\n", + " [PointerTensor | me:86740191509 -> 18986127193:21352736503],\n", + " ([PointerTensor | me:86740191509 -> 18986127193:21352736503],),\n", + " {}),\n", + " [42195613209]))" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sy.serde._detail(sy.local_worker, plan_double_abs.readable_plan[0])" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1,\n", + " (('torch.abs',\n", + " None,\n", + " ([PointerTensor | me:75885061374 -> 18986127193:42195613209],),\n", + " {}),\n", + " [23105997167]))" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sy.serde._detail(sy.local_worker, plan_double_abs.readable_plan[1])" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[23105997167]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plan_double_abs.result_ids" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(, (0, ))\n", + "(, (1, ))\n", + "(, (2, ))\n", + "(, (3, ))\n", + "(, (4, ))\n", + "(, (5, ))\n", + "(, (6, ))\n", + "(, (7, ))\n", + "(, (8, ))\n", + "(, (9, ))\n", + "(, (10, ))\n", + "(, (10, ))\n", + "(, (11, ))\n", + "(, (12, ))\n", + "(, (13, ))\n", + "(, (14, ))\n", + "(, (15, ))\n", + "(, (16, ))\n", + "(, (17, ))\n", + "(, (18, ))\n", + "(, (19, ))\n", + "(, (20, ))\n", + "(, (21, ))\n", + "(, (22, ))\n", + "(, (23, ))\n" + ] + } + ], + "source": [ + "for each in sy.serde.simplifiers.items():\n", + " print(each)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -270,16 +440,114 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "(1,\n", + " [0,\n", + " (5, (b'one',)),\n", + " (2, (0, 10, 1)),\n", + " (4, (0, 10, None)),\n", + " (1,\n", + " [(3, [0, 1, 2]),\n", + " (5, (b'three',)),\n", + " (0,\n", + " [((5, (b'key',)), (5, (b'value',))),\n", + " ((5, (b'key2',)), (5, (b'value2',)))])])])" ] }, - "execution_count": 11, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sy.serde._simplify([0, 'one', range(0, 10), slice(0, 10), [{0, 1, 2} , 'three', {'key': 'value', 'key2': 'value2'}]])" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[6, [9, 42195613209]]" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "plan_double_abs.readable_plan[2]" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(17,\n", + " ([[6,\n", + " [1,\n", + " [6,\n", + " [[6,\n", + " [[5, [b'__add__']],\n", + " [18, [86740191509, 21352736503, 18986127193, None, [2], False]],\n", + " [6,\n", + " [[18, [86740191509, 21352736503, 18986127193, None, [2], False]]]],\n", + " [0, []]]],\n", + " [1, [42195613209]]]]]],\n", + " [6,\n", + " [1,\n", + " [6,\n", + " [[6,\n", + " [[5, [b'torch.abs']],\n", + " None,\n", + " [6,\n", + " [[18, [75885061374, 42195613209, 18986127193, None, None, True]]]],\n", + " [0, []]]],\n", + " [1, [23105997167]]]]]],\n", + " [6, [9, 42195613209]]],\n", + " 18986127193,\n", + " (1, [21352736503]),\n", + " (1, [23105997167]),\n", + " (5, (b'plan_double_abs',)),\n", + " None,\n", + " None,\n", + " True))" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sy.serde._simplify(plan_double_abs)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -311,14 +579,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(Wrapper)>[PointerTensor | me:46234399619 -> device_1:939504340]\n" + "(Wrapper)>[PointerTensor | me:30222076202 -> device_1:52269952605]\n" ] } ], @@ -814,7 +1082,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.7" + "version": "3.7.3" } }, "nbformat": 4, diff --git a/syft/federated/plan.py b/syft/federated/plan.py index 00b47019518..316c71cf45e 100644 --- a/syft/federated/plan.py +++ b/syft/federated/plan.py @@ -624,9 +624,8 @@ def simplify(plan: "Plan") -> tuple: tuple: a tuple holding the unique attributes of the Plan object """ - readable_plan = sy.serde._simplify(plan.readable_plan) return ( - readable_plan, + plan.readable_plan, # We're not simplifying because readable_plan is already simplified sy.serde._simplify(plan.id), sy.serde._simplify(plan.arg_ids), sy.serde._simplify(plan.result_ids), @@ -656,7 +655,7 @@ def detail(worker: AbstractWorker, plan_tuple: tuple) -> "Plan": id=id, arg_ids=arg_ids, result_ids=result_ids, - readable_plan=sy.serde._detail(worker, readable_plan), + readable_plan=readable_plan, # We're not detailing, see simplify() for details is_built=is_built, ) From af0f74d7a687491d1adb88dbc6dce84e8004778a Mon Sep 17 00:00:00 2001 From: cereallarceny Date: Tue, 30 Jul 2019 13:39:07 +0100 Subject: [PATCH 2/3] Reverting example --- .../Part 8 - Introduction to Plans.ipynb | 312 ++---------------- 1 file changed, 22 insertions(+), 290 deletions(-) diff --git a/examples/tutorials/Part 8 - Introduction to Plans.ipynb b/examples/tutorials/Part 8 - Introduction to Plans.ipynb index 278d101f6d8..21592b3807b 100644 --- a/examples/tutorials/Part 8 - Introduction to Plans.ipynb +++ b/examples/tutorials/Part 8 - Introduction to Plans.ipynb @@ -90,26 +90,6 @@ "devices = device_1, device_2" ] }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'0.1.21a1'" - ] - }, - "execution_count": 4, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sy.__version__" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -121,7 +101,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -141,16 +121,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 6, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -174,18 +154,18 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(Wrapper)>[PointerTensor | me:41918042322 -> device_1:2708715446]\n", + "(Wrapper)>[PointerTensor | me:39792523445 -> device_1:44607711120]\n", "\tTags: input_data \n", "\tShape: torch.Size([2])" ] }, - "execution_count": 7, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -204,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -213,7 +193,7 @@ "False" ] }, - "execution_count": 8, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -224,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -234,8 +214,8 @@ "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# This cell fails\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mplan_double_abs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;32m/usr/local/lib/python3.7/site-packages/syft-0.1.21a1-py3.7.egg/syft/federated/plan.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, force, *locations)\u001b[0m\n\u001b[1;32m 526\u001b[0m \"\"\"\n\u001b[1;32m 527\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_built\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mforce\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 528\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"A plan needs to be built before being sent to a worker.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 529\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 530\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlocations\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mowner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_worker\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlocation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlocation\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlocations\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# This cell fails\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mplan_double_abs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdevice_1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/PySyft/syft/federated/plan.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, force, *locations)\u001b[0m\n\u001b[1;32m 526\u001b[0m \"\"\"\n\u001b[1;32m 527\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_built\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mforce\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 528\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mRuntimeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"A plan needs to be built before being sent to a worker.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 529\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 530\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlocations\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mowner\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_worker\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mlocation\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlocation\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mlocations\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mRuntimeError\u001b[0m: A plan needs to be built before being sent to a worker." ] } @@ -254,7 +234,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -263,7 +243,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -272,7 +252,7 @@ "True" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -281,156 +261,6 @@ "plan_double_abs.is_built" ] }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[[6,\n", - " [1,\n", - " [6,\n", - " [[6,\n", - " [[5, [b'__add__']],\n", - " [18, [86740191509, 21352736503, 18986127193, None, [2], False]],\n", - " [6, [[18, [86740191509, 21352736503, 18986127193, None, [2], False]]]],\n", - " [0, []]]],\n", - " [1, [42195613209]]]]]],\n", - " [6,\n", - " [1,\n", - " [6,\n", - " [[6,\n", - " [[5, [b'torch.abs']],\n", - " None,\n", - " [6, [[18, [75885061374, 42195613209, 18986127193, None, None, True]]]],\n", - " [0, []]]],\n", - " [1, [23105997167]]]]]],\n", - " [6, [9, 42195613209]]]" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "plan_double_abs.readable_plan" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1,\n", - " (('__add__',\n", - " [PointerTensor | me:86740191509 -> 18986127193:21352736503],\n", - " ([PointerTensor | me:86740191509 -> 18986127193:21352736503],),\n", - " {}),\n", - " [42195613209]))" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sy.serde._detail(sy.local_worker, plan_double_abs.readable_plan[0])" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1,\n", - " (('torch.abs',\n", - " None,\n", - " ([PointerTensor | me:75885061374 -> 18986127193:42195613209],),\n", - " {}),\n", - " [23105997167]))" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sy.serde._detail(sy.local_worker, plan_double_abs.readable_plan[1])" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[23105997167]" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "plan_double_abs.result_ids" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(, (0, ))\n", - "(, (1, ))\n", - "(, (2, ))\n", - "(, (3, ))\n", - "(, (4, ))\n", - "(, (5, ))\n", - "(, (6, ))\n", - "(, (7, ))\n", - "(, (8, ))\n", - "(, (9, ))\n", - "(, (10, ))\n", - "(, (10, ))\n", - "(, (11, ))\n", - "(, (12, ))\n", - "(, (13, ))\n", - "(, (14, ))\n", - "(, (15, ))\n", - "(, (16, ))\n", - "(, (17, ))\n", - "(, (18, ))\n", - "(, (19, ))\n", - "(, (20, ))\n", - "(, (21, ))\n", - "(, (22, ))\n", - "(, (23, ))\n" - ] - } - ], - "source": [ - "for each in sy.serde.simplifiers.items():\n", - " print(each)" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -440,114 +270,16 @@ }, { "cell_type": "code", - "execution_count": 17, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(1,\n", - " [0,\n", - " (5, (b'one',)),\n", - " (2, (0, 10, 1)),\n", - " (4, (0, 10, None)),\n", - " (1,\n", - " [(3, [0, 1, 2]),\n", - " (5, (b'three',)),\n", - " (0,\n", - " [((5, (b'key',)), (5, (b'value',))),\n", - " ((5, (b'key2',)), (5, (b'value2',)))])])])" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sy.serde._simplify([0, 'one', range(0, 10), slice(0, 10), [{0, 1, 2} , 'three', {'key': 'value', 'key2': 'value2'}]])" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[6, [9, 42195613209]]" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "plan_double_abs.readable_plan[2]" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(17,\n", - " ([[6,\n", - " [1,\n", - " [6,\n", - " [[6,\n", - " [[5, [b'__add__']],\n", - " [18, [86740191509, 21352736503, 18986127193, None, [2], False]],\n", - " [6,\n", - " [[18, [86740191509, 21352736503, 18986127193, None, [2], False]]]],\n", - " [0, []]]],\n", - " [1, [42195613209]]]]]],\n", - " [6,\n", - " [1,\n", - " [6,\n", - " [[6,\n", - " [[5, [b'torch.abs']],\n", - " None,\n", - " [6,\n", - " [[18, [75885061374, 42195613209, 18986127193, None, None, True]]]],\n", - " [0, []]]],\n", - " [1, [23105997167]]]]]],\n", - " [6, [9, 42195613209]]],\n", - " 18986127193,\n", - " (1, [21352736503]),\n", - " (1, [23105997167]),\n", - " (5, (b'plan_double_abs',)),\n", - " None,\n", - " None,\n", - " True))" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "sy.serde._simplify(plan_double_abs)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" + "" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -579,14 +311,14 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "(Wrapper)>[PointerTensor | me:30222076202 -> device_1:52269952605]\n" + "(Wrapper)>[PointerTensor | me:46234399619 -> device_1:939504340]\n" ] } ], @@ -1082,9 +814,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.3" + "version": "3.6.7" } }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file From e728e6dd4c56cce6e41aff407bb6bb9049a670aa Mon Sep 17 00:00:00 2001 From: cereallarceny Date: Tue, 30 Jul 2019 13:49:49 +0100 Subject: [PATCH 3/3] Black --- syft/federated/plan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syft/federated/plan.py b/syft/federated/plan.py index 316c71cf45e..ec326f8d5ea 100644 --- a/syft/federated/plan.py +++ b/syft/federated/plan.py @@ -655,7 +655,7 @@ def detail(worker: AbstractWorker, plan_tuple: tuple) -> "Plan": id=id, arg_ids=arg_ids, result_ids=result_ids, - readable_plan=readable_plan, # We're not detailing, see simplify() for details + readable_plan=readable_plan, # We're not detailing, see simplify() for details is_built=is_built, )