Spaces:
Runtime error
Runtime error
Update optimization.py
Browse files- optimization.py +3 -9
optimization.py
CHANGED
|
@@ -11,10 +11,6 @@ from torch.utils._pytree import tree_map_only
|
|
| 11 |
from torchao.quantization import quantize_
|
| 12 |
from torchao.quantization import Float8DynamicActivationFloat8WeightConfig
|
| 13 |
|
| 14 |
-
from optimization_utils import capture_component_call
|
| 15 |
-
from optimization_utils import aoti_compile
|
| 16 |
-
from optimization_utils import cudagraph
|
| 17 |
-
|
| 18 |
|
| 19 |
P = ParamSpec('P')
|
| 20 |
|
|
@@ -41,7 +37,7 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
|
|
| 41 |
@spaces.GPU(duration=1500)
|
| 42 |
def compile_transformer():
|
| 43 |
|
| 44 |
-
with
|
| 45 |
pipeline(*args, **kwargs)
|
| 46 |
|
| 47 |
dynamic_shapes = tree_map_only((torch.Tensor, bool), lambda t: None, call.kwargs)
|
|
@@ -58,8 +54,6 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
|
|
| 58 |
dynamic_shapes=dynamic_shapes,
|
| 59 |
)
|
| 60 |
|
| 61 |
-
return aoti_compile(exported, INDUCTOR_CONFIGS)
|
| 62 |
|
| 63 |
-
|
| 64 |
-
pipeline.transformer = compile_transformer()
|
| 65 |
-
pipeline.transformer.config = transformer_config # pyright: ignore[reportAttributeAccessIssue]
|
|
|
|
| 11 |
from torchao.quantization import quantize_
|
| 12 |
from torchao.quantization import Float8DynamicActivationFloat8WeightConfig
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
P = ParamSpec('P')
|
| 16 |
|
|
|
|
| 37 |
@spaces.GPU(duration=1500)
|
| 38 |
def compile_transformer():
|
| 39 |
|
| 40 |
+
with spaces.aoti_capture(pipeline.transformer) as call:
|
| 41 |
pipeline(*args, **kwargs)
|
| 42 |
|
| 43 |
dynamic_shapes = tree_map_only((torch.Tensor, bool), lambda t: None, call.kwargs)
|
|
|
|
| 54 |
dynamic_shapes=dynamic_shapes,
|
| 55 |
)
|
| 56 |
|
| 57 |
+
return spaces.aoti_compile(exported, INDUCTOR_CONFIGS)
|
| 58 |
|
| 59 |
+
spaces.aoti_apply(compile_transformer(), pipeline.transformer)
|
|
|
|
|
|