autofusex 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- afx/__init__.py +5 -0
- afx/__main__.py +5 -0
- autofusex/__init__.py +4 -0
- autofusex/__main__.py +5 -0
- autofusex/adapters/__init__.py +59 -0
- autofusex/adapters/base.py +44 -0
- autofusex/adapters/detection.py +59 -0
- autofusex/adapters/inductor_autofuse.py +38 -0
- autofusex/adapters/jax.py +20 -0
- autofusex/adapters/pytorch.py +635 -0
- autofusex/adapters/tensorflow.py +20 -0
- autofusex/agent.py +282 -0
- autofusex/artifact_io.py +56 -0
- autofusex/autofuse_graph.py +239 -0
- autofusex/camodel.py +86 -0
- autofusex/cli.py +599 -0
- autofusex/compare.py +1394 -0
- autofusex/fuzz/__init__.py +1 -0
- autofusex/fuzz/__main__.py +3 -0
- autofusex/fuzz/client/__init__.py +8 -0
- autofusex/fuzz/client/backend_names.py +3 -0
- autofusex/fuzz/client/backends/__init__.py +14 -0
- autofusex/fuzz/client/backends/autofuse_coverage.py +102 -0
- autofusex/fuzz/client/backends/base.py +36 -0
- autofusex/fuzz/client/backends/device_lease.py +51 -0
- autofusex/fuzz/client/backends/mlir_capability.py +49 -0
- autofusex/fuzz/client/backends/torch.py +196 -0
- autofusex/fuzz/client/case_spec.py +78 -0
- autofusex/fuzz/client/cli.py +275 -0
- autofusex/fuzz/client/config.py +169 -0
- autofusex/fuzz/client/contracts.py +200 -0
- autofusex/fuzz/client/core_logs.py +135 -0
- autofusex/fuzz/client/diagnostics.py +128 -0
- autofusex/fuzz/client/environment.py +68 -0
- autofusex/fuzz/client/execution.py +147 -0
- autofusex/fuzz/client/failure_details.py +90 -0
- autofusex/fuzz/client/generation/__init__.py +26 -0
- autofusex/fuzz/client/generation/categories.py +37 -0
- autofusex/fuzz/client/generation/fingerprint.py +16 -0
- autofusex/fuzz/client/generation/nnsmith_dynamic.py +65 -0
- autofusex/fuzz/client/generation/nnsmith_sampled.py +198 -0
- autofusex/fuzz/client/generation/operator_catalog.py +46 -0
- autofusex/fuzz/client/generation/runtime.py +20 -0
- autofusex/fuzz/client/generation/sampling.py +100 -0
- autofusex/fuzz/client/generation/torch_dialect.py +99 -0
- autofusex/fuzz/client/help.py +31 -0
- autofusex/fuzz/client/limits.py +7 -0
- autofusex/fuzz/client/nnsmith/__init__.py +5 -0
- autofusex/fuzz/client/nnsmith/aten_catalog.py +272 -0
- autofusex/fuzz/client/nnsmith/aten_dialect.py +335 -0
- autofusex/fuzz/client/resources.py +229 -0
- autofusex/fuzz/client/runtime.py +124 -0
- autofusex/fuzz/client/scheduling/__init__.py +1 -0
- autofusex/fuzz/client/scheduling/artifacts.py +97 -0
- autofusex/fuzz/client/scheduling/budgets.py +133 -0
- autofusex/fuzz/client/scheduling/campaign.py +70 -0
- autofusex/fuzz/client/scheduling/cli.py +156 -0
- autofusex/fuzz/client/scheduling/devices.py +24 -0
- autofusex/fuzz/client/scheduling/hosting.py +208 -0
- autofusex/fuzz/client/scheduling/ledger.py +201 -0
- autofusex/fuzz/client/scheduling/ownership.py +25 -0
- autofusex/fuzz/client/scheduling/placement.py +45 -0
- autofusex/fuzz/client/scheduling/pool.py +216 -0
- autofusex/fuzz/client/scheduling/stage_worker.py +191 -0
- autofusex/fuzz/client/scheduling/staged.py +470 -0
- autofusex/fuzz/client/scheduling/stages.py +65 -0
- autofusex/fuzz/client/scheduling/supervisor.py +314 -0
- autofusex/fuzz/client/scheduling/worker.py +72 -0
- autofusex/fuzz/client/storage/__init__.py +4 -0
- autofusex/fuzz/client/storage/comparison.py +31 -0
- autofusex/fuzz/client/storage/lifecycle.py +72 -0
- autofusex/fuzz/client/storage/queries.py +275 -0
- autofusex/fuzz/client/storage/records.py +102 -0
- autofusex/fuzz/client/storage/repository.py +181 -0
- autofusex/fuzz/client/storage/schema.py +47 -0
- autofusex/fuzz/client/storage/sqlite_utils.py +23 -0
- autofusex/fuzz/client/storage/stage_facts.py +129 -0
- autofusex/fuzz/client/storage/transfer.py +176 -0
- autofusex/fuzz/client/sync/__init__.py +1 -0
- autofusex/fuzz/client/sync/client.py +166 -0
- autofusex/fuzz/client/sync/daemon.py +8 -0
- autofusex/fuzz/client/sync/facts.py +182 -0
- autofusex/fuzz/client/sync/outbox.py +91 -0
- autofusex/fuzz/client/sync/retests.py +241 -0
- autofusex/fuzz/client/telemetry.py +27 -0
- autofusex/fuzz/client/tensors.py +34 -0
- autofusex/fuzz/daemon/__init__.py +24 -0
- autofusex/fuzz/daemon/client_update.py +4 -0
- autofusex/fuzz/daemon/management/__init__.py +1 -0
- autofusex/fuzz/daemon/management/agent_api.py +253 -0
- autofusex/fuzz/daemon/management/artifacts.py +158 -0
- autofusex/fuzz/daemon/management/cancellation.py +12 -0
- autofusex/fuzz/daemon/management/central.py +294 -0
- autofusex/fuzz/daemon/management/cli.py +366 -0
- autofusex/fuzz/daemon/management/client_updates.py +64 -0
- autofusex/fuzz/daemon/management/config.py +179 -0
- autofusex/fuzz/daemon/management/environments.py +184 -0
- autofusex/fuzz/daemon/management/operations.py +99 -0
- autofusex/fuzz/daemon/management/provenance.py +27 -0
- autofusex/fuzz/daemon/management/results.py +29 -0
- autofusex/fuzz/daemon/management/store.py +106 -0
- autofusex/fuzz/daemon/management/task_worker.py +63 -0
- autofusex/fuzz/daemon/management/tasks.py +148 -0
- autofusex/fuzz/daemon/management/updates.py +69 -0
- autofusex/fuzz/daemon/management/uploads.py +35 -0
- autofusex/fuzz/daemon/onboarding.py +53 -0
- autofusex/fuzz/daemon/runtime.py +255 -0
- autofusex/fuzz/daemon/supervisor.py +57 -0
- autofusex/fuzz/server/__init__.py +6 -0
- autofusex/fuzz/server/central/__init__.py +1 -0
- autofusex/fuzz/server/central/backup.py +28 -0
- autofusex/fuzz/server/central/cache.py +149 -0
- autofusex/fuzz/server/central/cleanup.py +56 -0
- autofusex/fuzz/server/central/control_api.py +195 -0
- autofusex/fuzz/server/central/issue_groups.py +320 -0
- autofusex/fuzz/server/central/maintenance.py +76 -0
- autofusex/fuzz/server/central/repairs.py +230 -0
- autofusex/fuzz/server/central/repository.py +203 -0
- autofusex/fuzz/server/central/retests.py +414 -0
- autofusex/fuzz/server/central/runtime.py +208 -0
- autofusex/fuzz/server/central/server.py +294 -0
- autofusex/fuzz/server/central/sessions.py +59 -0
- autofusex/fuzz/server/reporting/__init__.py +1 -0
- autofusex/fuzz/server/reporting/cases.py +171 -0
- autofusex/fuzz/server/reporting/compact.py +20 -0
- autofusex/fuzz/server/reporting/efficiency.py +98 -0
- autofusex/fuzz/server/reporting/failure_origin.py +197 -0
- autofusex/fuzz/server/reporting/incremental.py +251 -0
- autofusex/fuzz/server/reporting/index.py +169 -0
- autofusex/fuzz/server/reporting/materialized.py +217 -0
- autofusex/fuzz/server/reporting/outcomes.py +30 -0
- autofusex/fuzz/server/reporting/report.py +23 -0
- autofusex/fuzz/server/reporting/search.py +136 -0
- autofusex/fuzz/server/reporting/shared_content.py +16 -0
- autofusex/fuzz/server/reporting/statistics.py +131 -0
- autofusex/fuzz/server/view/__init__.py +1 -0
- autofusex/fuzz/server/view/server.py +139 -0
- autofusex/fuzz/server/view/static/app.js +581 -0
- autofusex/fuzz/server/view/static/charts.js +267 -0
- autofusex/fuzz/server/view/static/favicon.svg +8 -0
- autofusex/fuzz/server/view/static/index.html +137 -0
- autofusex/fuzz/server/view/static/issues.css +1 -0
- autofusex/fuzz/server/view/static/issues.js +55 -0
- autofusex/fuzz/server/view/static/manage.css +2 -0
- autofusex/fuzz/server/view/static/manage.html +1 -0
- autofusex/fuzz/server/view/static/manage.js +70 -0
- autofusex/fuzz/server/view/static/retests.css +22 -0
- autofusex/fuzz/server/view/static/retests.js +148 -0
- autofusex/fuzz/server/view/static/runtime.js +113 -0
- autofusex/fuzz/server/view/static/session.js +70 -0
- autofusex/fuzz/server/view/static/style.css +492 -0
- autofusex/graph.py +227 -0
- autofusex/html.py +3293 -0
- autofusex/inductor_autofuse.py +1586 -0
- autofusex/normalization.py +289 -0
- autofusex/npu_examples.py +1088 -0
- autofusex/platform/__init__.py +6 -0
- autofusex/platform/aggregates.py +160 -0
- autofusex/platform/auth.py +148 -0
- autofusex/platform/backup.py +161 -0
- autofusex/platform/cli.py +126 -0
- autofusex/platform/client.py +879 -0
- autofusex/platform/ingest.py +568 -0
- autofusex/platform/issues.py +620 -0
- autofusex/platform/knowledge.py +231 -0
- autofusex/platform/ops.py +175 -0
- autofusex/platform/profile.py +172 -0
- autofusex/platform/queries.py +283 -0
- autofusex/platform/regression.py +223 -0
- autofusex/platform/retests.py +307 -0
- autofusex/platform/schema.py +535 -0
- autofusex/platform/search.py +209 -0
- autofusex/platform/server.py +520 -0
- autofusex/platform/static/app.css +338 -0
- autofusex/platform/static/app.js +1398 -0
- autofusex/platform/static/favicon.svg +1 -0
- autofusex/platform/static/index.html +34 -0
- autofusex/platform/store.py +175 -0
- autofusex/progress.py +94 -0
- autofusex/runner.py +79 -0
- autofusex/script_runner.py +233 -0
- autofusex/shell_entry.py +298 -0
- autofusex/torch_model.py +1300 -0
- autofusex-0.2.0.dist-info/METADATA +241 -0
- autofusex-0.2.0.dist-info/RECORD +188 -0
- autofusex-0.2.0.dist-info/WHEEL +5 -0
- autofusex-0.2.0.dist-info/entry_points.txt +2 -0
- autofusex-0.2.0.dist-info/top_level.txt +2 -0
afx/__init__.py
ADDED
afx/__main__.py
ADDED
autofusex/__init__.py
ADDED
autofusex/__main__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from autofusex.adapters.base import BackendAdapter, CapturedInvocation, FrameworkAdapter
|
|
4
|
+
from autofusex.adapters.detection import detect_framework, find_cann_ge_root
|
|
5
|
+
from autofusex.adapters.jax import JaxAdapter
|
|
6
|
+
from autofusex.adapters.inductor_autofuse import InductorAutofuseBackend
|
|
7
|
+
from autofusex.adapters.pytorch import PyTorchAdapter
|
|
8
|
+
from autofusex.adapters.tensorflow import TensorFlowAdapter
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_FRAMEWORK_ADAPTERS: dict[str, type[FrameworkAdapter]] = {
|
|
12
|
+
"pytorch": PyTorchAdapter,
|
|
13
|
+
"tensorflow": TensorFlowAdapter,
|
|
14
|
+
"jax": JaxAdapter,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_BACKEND_ADAPTERS: dict[str, type[BackendAdapter]] = {
|
|
18
|
+
"inductor_autofuse": InductorAutofuseBackend,
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def framework_names() -> tuple[str, ...]:
|
|
23
|
+
return tuple(_FRAMEWORK_ADAPTERS)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def get_framework_adapter(name: str) -> FrameworkAdapter:
|
|
27
|
+
resolved = "pytorch" if name == "auto" else name
|
|
28
|
+
adapter_type = _FRAMEWORK_ADAPTERS.get(resolved)
|
|
29
|
+
if adapter_type is None:
|
|
30
|
+
raise ValueError(f"unsupported framework: {name}")
|
|
31
|
+
return adapter_type()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def backend_names() -> tuple[str, ...]:
|
|
35
|
+
return tuple(_BACKEND_ADAPTERS)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_backend_adapter(name: str) -> BackendAdapter:
|
|
39
|
+
adapter_type = _BACKEND_ADAPTERS.get(name)
|
|
40
|
+
if adapter_type is None:
|
|
41
|
+
raise ValueError(f"unsupported backend: {name}")
|
|
42
|
+
return adapter_type()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
__all__ = [
|
|
46
|
+
"BackendAdapter",
|
|
47
|
+
"CapturedInvocation",
|
|
48
|
+
"FrameworkAdapter",
|
|
49
|
+
"JaxAdapter",
|
|
50
|
+
"InductorAutofuseBackend",
|
|
51
|
+
"PyTorchAdapter",
|
|
52
|
+
"TensorFlowAdapter",
|
|
53
|
+
"backend_names",
|
|
54
|
+
"detect_framework",
|
|
55
|
+
"find_cann_ge_root",
|
|
56
|
+
"framework_names",
|
|
57
|
+
"get_backend_adapter",
|
|
58
|
+
"get_framework_adapter",
|
|
59
|
+
]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass(frozen=True)
|
|
10
|
+
class CapturedInvocation:
|
|
11
|
+
framework: str
|
|
12
|
+
model: Any
|
|
13
|
+
args: tuple[Any, ...]
|
|
14
|
+
kwargs: dict[str, Any]
|
|
15
|
+
name: str
|
|
16
|
+
metadata: dict[str, Any] = field(default_factory=dict)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class FrameworkAdapter(ABC):
|
|
20
|
+
name: str
|
|
21
|
+
implemented: bool = False
|
|
22
|
+
|
|
23
|
+
@abstractmethod
|
|
24
|
+
def capture(
|
|
25
|
+
self,
|
|
26
|
+
*,
|
|
27
|
+
script: str | Path,
|
|
28
|
+
script_args: tuple[str, ...] = (),
|
|
29
|
+
capture_call: int = 0,
|
|
30
|
+
module_pattern: str | None = None,
|
|
31
|
+
) -> CapturedInvocation:
|
|
32
|
+
raise NotImplementedError
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class BackendAdapter(ABC):
|
|
36
|
+
name: str
|
|
37
|
+
supported_frameworks: tuple[str, ...]
|
|
38
|
+
|
|
39
|
+
def supports(self, framework: str) -> bool:
|
|
40
|
+
return framework in self.supported_frameworks
|
|
41
|
+
|
|
42
|
+
@abstractmethod
|
|
43
|
+
def run(self, invocation: CapturedInvocation, **kwargs: Any) -> dict[str, Any]:
|
|
44
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import ast
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_FRAMEWORK_MODULES = {
|
|
8
|
+
"torch": "pytorch",
|
|
9
|
+
"torch_npu": "pytorch",
|
|
10
|
+
"torchair": "pytorch",
|
|
11
|
+
"inductor_npu_ext": "pytorch",
|
|
12
|
+
"tensorflow": "tensorflow",
|
|
13
|
+
"jax": "jax",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def find_cann_ge_root(script: str | Path) -> Path | None:
|
|
18
|
+
"""Find the repository root that provides a cann-ge/Baize ``libs`` package."""
|
|
19
|
+
path = Path(script).resolve()
|
|
20
|
+
for candidate in (path.parent, *path.parents):
|
|
21
|
+
if (candidate / "libs" / "__init__.py").is_file() and (candidate / "feature").is_dir():
|
|
22
|
+
return candidate
|
|
23
|
+
return None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _import_roots(tree: ast.AST) -> set[str]:
|
|
27
|
+
roots: set[str] = set()
|
|
28
|
+
for node in ast.walk(tree):
|
|
29
|
+
if isinstance(node, ast.Import):
|
|
30
|
+
names = (item.name for item in node.names)
|
|
31
|
+
elif isinstance(node, ast.ImportFrom) and node.module:
|
|
32
|
+
names = (node.module,)
|
|
33
|
+
else:
|
|
34
|
+
continue
|
|
35
|
+
roots.update(name.split(".", 1)[0] for name in names)
|
|
36
|
+
return roots
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def detect_framework(script: str | Path) -> str:
|
|
40
|
+
"""Detect the model framework from imports without executing the script."""
|
|
41
|
+
path = Path(script).resolve()
|
|
42
|
+
try:
|
|
43
|
+
tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path))
|
|
44
|
+
except (OSError, UnicodeError, SyntaxError) as exc:
|
|
45
|
+
raise ValueError(f"cannot inspect framework imports in {path}: {exc}") from exc
|
|
46
|
+
|
|
47
|
+
roots = _import_roots(tree)
|
|
48
|
+
detected = {framework for module, framework in _FRAMEWORK_MODULES.items() if module in roots}
|
|
49
|
+
if len(detected) > 1:
|
|
50
|
+
names = ", ".join(sorted(detected))
|
|
51
|
+
raise ValueError(
|
|
52
|
+
f"framework auto-detection found multiple frameworks in {path}: {names}; "
|
|
53
|
+
"pass --framework explicitly"
|
|
54
|
+
)
|
|
55
|
+
if detected:
|
|
56
|
+
return detected.pop()
|
|
57
|
+
|
|
58
|
+
# Keep old scripts working when the model class is imported from another module.
|
|
59
|
+
return "pytorch"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from autofusex.adapters.base import BackendAdapter, CapturedInvocation
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InductorAutofuseBackend(BackendAdapter):
|
|
9
|
+
name = "inductor_autofuse"
|
|
10
|
+
supported_frameworks = ("pytorch",)
|
|
11
|
+
|
|
12
|
+
def run(self, invocation: CapturedInvocation, **kwargs: Any) -> dict[str, Any]:
|
|
13
|
+
if not self.supports(invocation.framework):
|
|
14
|
+
raise ValueError(f"{self.name} does not support framework {invocation.framework}")
|
|
15
|
+
|
|
16
|
+
from autofusex.torch_model import TorchCase, run_torch_case
|
|
17
|
+
|
|
18
|
+
case = TorchCase(
|
|
19
|
+
model=invocation.model,
|
|
20
|
+
inputs=invocation.args,
|
|
21
|
+
kwargs=invocation.kwargs,
|
|
22
|
+
name=str(kwargs.pop("name", None) or invocation.name),
|
|
23
|
+
fullgraph=bool(kwargs.pop("fullgraph", False)),
|
|
24
|
+
dynamic=bool(kwargs.pop("dynamic", False)),
|
|
25
|
+
training=invocation.metadata.get("execution", {}).get("training"),
|
|
26
|
+
grad_enabled=bool(invocation.metadata.get("execution", {}).get("grad_enabled", True)),
|
|
27
|
+
autocast=dict(invocation.metadata.get("execution", {}).get("autocast", {})),
|
|
28
|
+
rewrite_device_hints=bool(kwargs.pop("rewrite_device_hints", False)),
|
|
29
|
+
)
|
|
30
|
+
script = invocation.metadata.get("script")
|
|
31
|
+
if not script:
|
|
32
|
+
raise ValueError("captured invocation does not contain its source script")
|
|
33
|
+
return run_torch_case(
|
|
34
|
+
case=case,
|
|
35
|
+
script=script,
|
|
36
|
+
invocation_metadata=invocation.metadata,
|
|
37
|
+
**kwargs,
|
|
38
|
+
)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from autofusex.adapters.base import CapturedInvocation, FrameworkAdapter
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class JaxAdapter(FrameworkAdapter):
|
|
9
|
+
name = "jax"
|
|
10
|
+
|
|
11
|
+
def capture(
|
|
12
|
+
self,
|
|
13
|
+
*,
|
|
14
|
+
script: str | Path,
|
|
15
|
+
script_args: tuple[str, ...] = (),
|
|
16
|
+
capture_call: int = 0,
|
|
17
|
+
module_pattern: str | None = None,
|
|
18
|
+
) -> CapturedInvocation:
|
|
19
|
+
del script, script_args, capture_call, module_pattern
|
|
20
|
+
raise NotImplementedError("JaxAdapter is reserved but not implemented")
|