Helw150 commited on
Commit
7a52d3b
1 Parent(s): 4b2b7f5
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -75,7 +75,7 @@ def response(state: AppState, audio: tuple):
75
  if spaces.config.Config.zero_gpu:
76
  if state.model_outs is not None:
77
  state.model_outs.past_key_values = tuple(
78
- tuple(vec.cuda() for vec in tup)
79
  for tup in state.model_outs.past_key_values
80
  )
81
  prev_outs = state.model_outs
@@ -91,12 +91,12 @@ def response(state: AppState, audio: tuple):
91
  state.conversation[-1]["content"] = resp
92
  # yield state, state.conversation
93
 
94
- # del outs.logits
95
- # del outs.hidden_states
96
- # if spaces.config.Config.zero_gpu:
97
- # outs.past_key_values = tuple(
98
- # tuple(vec.cpu() for vec in tup) for tup in outs.past_key_values
99
- # )
100
  return (
101
  AppState(conversation=state.conversation),
102
  state.conversation,
 
75
  if spaces.config.Config.zero_gpu:
76
  if state.model_outs is not None:
77
  state.model_outs.past_key_values = tuple(
78
+ tuple(torch.tensor(vec).cuda() for vec in tup)
79
  for tup in state.model_outs.past_key_values
80
  )
81
  prev_outs = state.model_outs
 
91
  state.conversation[-1]["content"] = resp
92
  # yield state, state.conversation
93
 
94
+ del outs.logits
95
+ del outs.hidden_states
96
+ if spaces.config.Config.zero_gpu:
97
+ outs.past_key_values = tuple(
98
+ tuple(vec.cpu().numpy for vec in tup) for tup in outs.past_key_values
99
+ )
100
  return (
101
  AppState(conversation=state.conversation),
102
  state.conversation,