Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory improvements (3/3): Introduce new runner and executor API #1690

Merged
merged 75 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
39a1598
Mem (1/3): introduce new DAL and core Pydantic models
cjao Jun 23, 2023
9389b3b
Mem (1/3): Fix schemas
cjao Jul 11, 2023
23761a7
Mem (1/3): DAL PR: temporarily redirect core dispatcher tests
cjao Jun 23, 2023
69def08
Mem (1/3): DAL PR: fix tests
cjao Jun 28, 2023
f942531
Mem (1/3): Fix requirements workflow
cjao Jul 12, 2023
4693404
Mem (1/3): Uncomment boilerplate in disabled unit tests
cjao Jul 14, 2023
8bb0adb
Mem (1/3): Add unit test for format_server_url
cjao Jul 14, 2023
b18db33
Mem (1/3): defer copy_file_locally to next PR
cjao Jul 14, 2023
f792432
Mem (1/3): update changelog
cjao Jun 30, 2023
cb8ae1d
Mem (1/3): Core DAL improvements
cjao Sep 22, 2023
9edb062
Mem (2/3): Revert "DAL PR: fix tests"
cjao Jun 29, 2023
dd09f89
Mem (2/3): Revert "Mem (1/3): defer copy_file_locally to next PR"
cjao Jul 14, 2023
9a5152d
Mem (2/3): Revert "Mem (1/3): Uncomment boilerplate in disabled unit …
cjao Jul 14, 2023
17a6785
Mem (2/3): Revert "Mem (1/3): Fix requirements workflow"
cjao Jul 13, 2023
6d254e1
Mem (2/3): Revert "DAL PR: temporarily redirect core dispatcher tests"
cjao Jun 29, 2023
c99805a
Mem (2/3): Core migration -- Re-enable electron_tests
cjao Jun 23, 2023
eb04d44
Mem (2/3): migrate core to new DAL
cjao Jun 29, 2023
ccf9aaf
Mem (2/3): redirect dispatcher to in-memory runner
cjao Aug 15, 2023
047ed01
Mem (2/3): Update changelog
cjao Jun 30, 2023
b9bad87
Mem (3/3): Revert "Mem (2/3): redirect dispatcher to in-memory runner"
cjao Jun 30, 2023
b91cdf1
Mem (3/3): introduce new runner and executor API
cjao Jun 29, 2023
5860ca6
Mem (3/3): Update changelog
cjao Jun 30, 2023
a7cd026
Synced with develop
kessler-frost Oct 11, 2023
c923381
Merge branch 'develop' into memory-improvements-pr-2
kessler-frost Oct 12, 2023
e9b8d39
updated license to Apache
kessler-frost Oct 12, 2023
1933955
some fixes to make dispatching work
kessler-frost Oct 12, 2023
e5db68a
Merge branch 'develop' into memory-improvements-pr-2
kessler-frost Oct 12, 2023
83a06c8
reverted some changes to make the funcs sync
kessler-frost Oct 12, 2023
1008312
changes after reviewing
kessler-frost Oct 13, 2023
d8c427e
synced with develop
kessler-frost Oct 16, 2023
a154967
fixing tests, removed cancel_requested from Electron model
kessler-frost Oct 17, 2023
ef78b7c
fixing tests, sublattice issue fixed
kessler-frost Oct 17, 2023
c695aa3
Merge branch 'develop' into memory-improvements-pr-2
kessler-frost Oct 17, 2023
c317a18
fixing tests, cancellation issue fixed
kessler-frost Oct 17, 2023
eea43b7
Merge branch 'memory-improvements-pr-2' of github.com:AgnostiqHQ/cova…
kessler-frost Oct 17, 2023
4f0ba0a
fixing tests, sdk issue fixed
kessler-frost Oct 17, 2023
7f6babc
cancel_tasks import location changed
kessler-frost Oct 17, 2023
49e5f3e
tg utils import location changed
kessler-frost Oct 17, 2023
8d48180
fixing tests
kessler-frost Oct 17, 2023
4a1ef38
fixing tests
kessler-frost Oct 18, 2023
568cfe4
fixing tests
kessler-frost Oct 18, 2023
4bf18ae
fixing tests
kessler-frost Oct 18, 2023
f779cec
fixing tests
kessler-frost Oct 18, 2023
9702de2
fixing tests
kessler-frost Oct 18, 2023
4d11867
fixing tests
kessler-frost Oct 18, 2023
218c0e8
fixing tests
kessler-frost Oct 18, 2023
e861daa
fixing tests
kessler-frost Oct 18, 2023
3406f22
fixing tests
kessler-frost Oct 18, 2023
ae51050
fixing tests
kessler-frost Oct 18, 2023
d2c4640
fixing tests
kessler-frost Oct 18, 2023
13288de
fixing tests, skipping some ui backend tests
kessler-frost Oct 18, 2023
6664036
Fix UI backend tests
cjao Oct 18, 2023
28da4f4
Undo some changes to UI assert data
cjao Oct 19, 2023
4979e0e
renamed core dispatcher tests
kessler-frost Oct 19, 2023
bbfdd22
removing the _db/load.py file
kessler-frost Oct 19, 2023
0c75db3
syncing with 2/3 which includes develop
kessler-frost Oct 19, 2023
c3baad8
fixing license
kessler-frost Oct 19, 2023
40534cf
syncing with develop
kessler-frost Oct 19, 2023
a02425a
fixing tests
kessler-frost Oct 19, 2023
6457980
synced with develop
kessler-frost Oct 19, 2023
2a31fb7
fixing tests
kessler-frost Oct 20, 2023
dd96d77
fixing tests
kessler-frost Oct 20, 2023
1919748
reverting dask related changes
kessler-frost Oct 20, 2023
a235ccb
fixed dask issue
kessler-frost Oct 20, 2023
9a896a6
skipping test as it requires rewriting it
kessler-frost Oct 20, 2023
a67e38e
DAL: Remember to update Record attrs on Record.update()
cjao Nov 1, 2023
6701bb0
Tests: force task packing for ft
cjao Nov 1, 2023
59444f6
Merge branch 'develop' into os-enhancements-preview-testmerge
kessler-frost Nov 2, 2023
9d1d15e
Tests: Revert force task packing for ft
cjao Nov 2, 2023
3c4f708
Tests: enable task packing during FT
cjao Nov 2, 2023
a5cbb95
SDK: don't pickle lattice_imports or cova_imports
cjao Nov 2, 2023
31f0479
Fix race condition when recording Dask cluster state
cjao Nov 7, 2023
e66cd82
added more dask tests
kessler-frost Nov 9, 2023
1ea6d3e
added local executor tests
kessler-frost Nov 9, 2023
acad32a
added more local executor tests
kessler-frost Nov 9, 2023
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
11 changes: 10 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,25 @@ jobs:
run: |
covalent db migrate
if [ "${{ matrix.backend }}" = 'dask' ] ; then
covalent start -d
COVALENT_ENABLE_TASK_PACKING=1 covalent start -d
elif [ "${{ matrix.backend }}" = 'local' ] ; then
covalent start --no-cluster -d
else
echo "Invalid backend specified in test matrix."
exit 1
fi
cat $HOME/.config/covalent/covalent.conf
env:
COVALENT_EXECUTOR_DIR: doc/source/how_to/execution/custom_executors

- name: Print Covalent status
if: env.BUILD_AND_RUN_ALL
id: covalent_status
run: |
covalent status
covalent cluster --info
covalent cluster --logs

- name: Run functional tests and measure coverage
id: functional-tests
if: env.BUILD_AND_RUN_ALL
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Documentation and test cases for database triggers.
- Added the `__pow__` method to the `Electron` class
- New Runner and executor API to bypass server-side memory when running tasks.

### Docs

- Added federated learning showcase code
- Updated tutorial for redispatching workflows with Streamlit
- Updated tutorial for redispatching workflows with Streamlit

### Tests

Expand Down
4 changes: 2 additions & 2 deletions covalent/_serialize/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"inputs": AssetType.TRANSPORTABLE,
"named_args": AssetType.TRANSPORTABLE,
"named_kwargs": AssetType.TRANSPORTABLE,
"cova_imports": AssetType.OBJECT,
"lattice_imports": AssetType.OBJECT,
"cova_imports": AssetType.JSONABLE,
"lattice_imports": AssetType.TEXT,
"deps": AssetType.JSONABLE,
"call_before": AssetType.JSONABLE,
"call_after": AssetType.JSONABLE,
Expand Down Expand Up @@ -93,8 +93,8 @@

try:
workflow_func_string = lat.workflow_function_string
except AttributeError:
workflow_func_string = ""

Check warning on line 97 in covalent/_serialize/lattice.py

View check run for this annotation

Codecov / codecov/patch

covalent/_serialize/lattice.py#L96-L97

Added lines #L96 - L97 were not covered by tests
workflow_func_str_asset = save_asset(
workflow_func_string,
ASSET_TYPES["workflow_function_string"],
Expand Down Expand Up @@ -224,7 +224,7 @@

def deserialize_lattice(model: LatticeSchema) -> Lattice:
def dummy_function(x):
return x

Check warning on line 227 in covalent/_serialize/lattice.py

View check run for this annotation

Codecov / codecov/patch

covalent/_serialize/lattice.py#L227

Added line #L227 was not covered by tests

lat = Lattice(dummy_function)

Expand Down
4 changes: 2 additions & 2 deletions covalent/_shared_files/schemas/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
LATTICE_DEPS_FILENAME = "deps.json"
LATTICE_CALL_BEFORE_FILENAME = "call_before.json"
LATTICE_CALL_AFTER_FILENAME = "call_after.json"
LATTICE_COVA_IMPORTS_FILENAME = "cova_imports.pkl"
LATTICE_LATTICE_IMPORTS_FILENAME = "lattice_imports.pkl"
LATTICE_COVA_IMPORTS_FILENAME = "cova_imports.json"
LATTICE_LATTICE_IMPORTS_FILENAME = "lattice_imports.txt"
LATTICE_STORAGE_TYPE = "file"


Expand Down Expand Up @@ -120,5 +120,5 @@
if v is not None:
for key in v:
if key in ASSET_FILENAME_MAP:
raise ValueError(f"Asset {key} conflicts with built-in key")

Check warning on line 123 in covalent/_shared_files/schemas/lattice.py

View check run for this annotation

Codecov / codecov/patch

covalent/_shared_files/schemas/lattice.py#L123

Added line #L123 was not covered by tests
return v
11 changes: 4 additions & 7 deletions covalent/_shared_files/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import shutil
import socket
from datetime import timedelta
from typing import Any, Callable, Dict, Set, Tuple
from typing import Any, Callable, Dict, List, Tuple

import cloudpickle
from pennylane._device import Device
Expand All @@ -37,9 +37,6 @@
DEFAULT_UI_PORT = get_config("user_interface.port")


# Dictionary to map Dask clients to their scheduler addresses
_address_client_mapper = {}

_IMPORT_PATH_SEPARATOR = ":"


Expand Down Expand Up @@ -141,7 +138,7 @@
return function_str + "\n\n"


def get_imports(func: Callable) -> Tuple[str, Set[str]]:
def get_imports(func: Callable) -> Tuple[str, List[str]]:
"""
Given an input workflow function, find the imports that were used, and determine
which ones are Covalent-related.
Expand All @@ -155,7 +152,7 @@
"""

imports_str = ""
cova_imports = set()
cova_imports = []
for i, j in func.__globals__.items():
if inspect.ismodule(j) or (
inspect.isfunction(j) and j.__name__ in ["lattice", "electron"]
Expand All @@ -167,7 +164,7 @@

if j.__name__ in ["covalent", "lattice", "electron"]:
import_line = f"# {import_line}"
cova_imports.add(i)
cova_imports.append(i)

imports_str += import_line

Expand Down Expand Up @@ -257,12 +254,12 @@
if src_uri.startswith(scheme_prefix):
src_path = src_uri[len(scheme_prefix) :]
else:
raise TypeError(f"{src_uri} is not a valid URI")

Check warning on line 257 in covalent/_shared_files/utils.py

View check run for this annotation

Codecov / codecov/patch

covalent/_shared_files/utils.py#L257

Added line #L257 was not covered by tests
# src_path = src_uri
if dest_uri.startswith(scheme_prefix):
dest_path = dest_uri[len(scheme_prefix) :]
else:
raise TypeError(f"{dest_uri} is not a valid URI")

Check warning on line 262 in covalent/_shared_files/utils.py

View check run for this annotation

Codecov / codecov/patch

covalent/_shared_files/utils.py#L262

Added line #L262 was not covered by tests

shutil.copyfile(src_path, dest_path)

Expand Down
4 changes: 1 addition & 3 deletions covalent/_workflow/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def __init__(
self.named_kwargs = None
self.electron_outputs = {}
self.lattice_imports, self.cova_imports = get_imports(self.workflow_function)
self.cova_imports.update({"electron"})

self.workflow_function = TransportableObject.make_transportable(self.workflow_function)

Expand Down Expand Up @@ -110,13 +109,11 @@ def serialize_to_json(self) -> str:
for node_name, output in self.electron_outputs.items():
attributes["electron_outputs"][node_name] = output.to_dict()

attributes["cova_imports"] = list(self.cova_imports)
return json.dumps(attributes)

@staticmethod
def deserialize_from_json(json_data: str) -> None:
attributes = json.loads(json_data)
attributes["cova_imports"] = set(attributes["cova_imports"])

for node_name, object_dict in attributes["electron_outputs"].items():
attributes["electron_outputs"][node_name] = TransportableObject.from_dict(object_dict)
Expand Down Expand Up @@ -211,6 +208,7 @@ def build_graph(self, *args, **kwargs) -> None:
self.inputs = TransportableObject({"args": args, "kwargs": kwargs})
self.named_args = TransportableObject(named_args)
self.named_kwargs = TransportableObject(named_kwargs)
self.lattice_imports, self.cova_imports = get_imports(workflow_function)

# Set any lattice metadata not explicitly set by the user
constraint_names = {"executor", "workflow_executor", "deps", "call_before", "call_after"}
Expand Down
2 changes: 1 addition & 1 deletion covalent/executor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from .._shared_files import logger
from .._shared_files.config import get_config, update_config
from ..quantum import QCluster, Simulator
from .base import BaseExecutor, wrapper_fn
from .base import BaseExecutor

app_log = logger.app_log
log_stack_info = logger.log_stack_info
Expand Down
Loading
Loading