cbensimon HF Staff commited on
Commit
3af4a0e
·
1 Parent(s): fc3f0ed
Files changed (2) hide show
  1. optimization.py +8 -5
  2. requirements.txt +0 -2
optimization.py CHANGED
@@ -16,6 +16,13 @@ from zerogpu import aoti_compile
16
  P = ParamSpec('P')
17
 
18
 
 
 
 
 
 
 
 
19
  INDUCTOR_CONFIGS = {
20
  'conv_1x1_as_mm': True,
21
  'epilogue_fusion': False,
@@ -34,12 +41,8 @@ def optimize_pipeline_(pipeline: Callable[P, Any], *args: P.args, **kwargs: P.kw
34
  with capture_component_call(pipeline, 'transformer') as call:
35
  pipeline(*args, **kwargs)
36
 
37
- hidden_dim = torch.export.Dim('hidden', min=4096, max=8212)
38
  dynamic_shapes = tree_map_only((torch.Tensor, bool), lambda t: None, call.kwargs)
39
- dynamic_shapes |= {
40
- 'hidden_states': {1: hidden_dim},
41
- 'img_ids': {0: hidden_dim},
42
- }
43
 
44
  pipeline.transformer.fuse_qkv_projections()
45
 
 
16
  P = ParamSpec('P')
17
 
18
 
19
+ TRANSFORMER_HIDDEN_DIM = torch.export.Dim('hidden', min=4096, max=8212)
20
+
21
+ TRANSFORMER_DYNAMIC_SHAPES = {
22
+ 'hidden_states': {1: TRANSFORMER_HIDDEN_DIM},
23
+ 'img_ids': {0: TRANSFORMER_HIDDEN_DIM},
24
+ }
25
+
26
  INDUCTOR_CONFIGS = {
27
  'conv_1x1_as_mm': True,
28
  'epilogue_fusion': False,
 
41
  with capture_component_call(pipeline, 'transformer') as call:
42
  pipeline(*args, **kwargs)
43
 
 
44
  dynamic_shapes = tree_map_only((torch.Tensor, bool), lambda t: None, call.kwargs)
45
+ dynamic_shapes |= TRANSFORMER_DYNAMIC_SHAPES
 
 
 
46
 
47
  pipeline.transformer.fuse_qkv_projections()
48
 
requirements.txt CHANGED
@@ -3,5 +3,3 @@ git+https://github.com/huggingface/diffusers.git
3
  accelerate
4
  safetensors
5
  sentencepiece
6
- torchao
7
-
 
3
  accelerate
4
  safetensors
5
  sentencepiece