Vansh Chugh commited on
Commit
9da6de5
·
1 Parent(s): 3ebe4e2

try torch 2.10.0 to match xformers build, shrink gpu duration for testing

Browse files
Files changed (3) hide show
  1. app.py +1 -1
  2. requirements.txt +2 -2
  3. src/audiocraft/models/loaders.py +4 -6
app.py CHANGED
@@ -147,7 +147,7 @@ def _beat_aligned_length(path, min_length, max_length, unit_size=0.02, length_re
147
  return length
148
 
149
 
150
- @spaces.GPU(duration=300)
151
  @torch.inference_mode()
152
  def process_fn(description: str, min_length: float, max_length: float, seed: int) -> str:
153
  """Generates a seamlessly loopable music clip: a MusicGen hint is used to
 
147
  return length
148
 
149
 
150
+ @spaces.GPU(duration=120)
151
  @torch.inference_mode()
152
  def process_fn(description: str, min_length: float, max_length: float, seed: int) -> str:
153
  """Generates a seamlessly loopable music clip: a MusicGen hint is used to
requirements.txt CHANGED
@@ -1,7 +1,7 @@
1
  git+https://github.com/TEAMuP-dev/pyharp.git@develop
2
  # model-specific deps below:
3
- torch==2.11.0
4
- torchaudio==2.11.0
5
  av>=12,<13
6
  xformers==0.0.35
7
  flashy
 
1
  git+https://github.com/TEAMuP-dev/pyharp.git@develop
2
  # model-specific deps below:
3
+ torch==2.10.0
4
+ torchaudio==2.10.0
5
  av>=12,<13
6
  xformers==0.0.35
7
  flashy
src/audiocraft/models/loaders.py CHANGED
@@ -112,8 +112,6 @@ def load_lm_model(file_or_url_or_id: tp.Union[Path, str], device='cpu', cache_di
112
  _delete_param(cfg, 'conditioners.self_wav.chroma_stem.cache_path')
113
  _delete_param(cfg, 'conditioners.args.merge_text_conditions_p')
114
  _delete_param(cfg, 'conditioners.args.drop_desc_p')
115
- # Deviation: xformers has no kernel for ZeroGPU's current hardware.
116
- cfg.transformer_lm.memory_efficient = False
117
  model = builders.get_lm_model(cfg)
118
  model.load_state_dict(pkg['best_state'])
119
  model.eval()
@@ -137,10 +135,10 @@ def load_lm_model_magnet(file_or_url_or_id: tp.Union[Path, str], compression_mod
137
  cfg.transformer_lm.segment_duration = cfg.dataset.segment_duration
138
  cfg.transformer_lm.span_len = cfg.masking.span_len
139
 
140
- # Deviation: xformers has no kernel for ZeroGPU's current hardware
141
- # (Blackwell, capability 12.0 > xformers' 9.0 cap). Disable memory_efficient
142
- # rather than switch to 'torch' backend, which ignores custom attn_mask.
143
- cfg.transformer_lm.memory_efficient = False
144
 
145
  model = builders.get_lm_model(cfg)
146
  model.load_state_dict(pkg['best_state'])
 
112
  _delete_param(cfg, 'conditioners.self_wav.chroma_stem.cache_path')
113
  _delete_param(cfg, 'conditioners.args.merge_text_conditions_p')
114
  _delete_param(cfg, 'conditioners.args.drop_desc_p')
 
 
115
  model = builders.get_lm_model(cfg)
116
  model.load_state_dict(pkg['best_state'])
117
  model.eval()
 
135
  cfg.transformer_lm.segment_duration = cfg.dataset.segment_duration
136
  cfg.transformer_lm.span_len = cfg.masking.span_len
137
 
138
+ # MAGNeT models v1 support only xformers backend.
139
+ from src.audiocraft.modules.transformer import set_efficient_attention_backend
140
+ if cfg.transformer_lm.memory_efficient:
141
+ set_efficient_attention_backend("xformers")
142
 
143
  model = builders.get_lm_model(cfg)
144
  model.load_state_dict(pkg['best_state'])