n00b001 commited on
Commit
ba1df97
·
unverified ·
1 Parent(s): 8f66118
Files changed (2) hide show
  1. app.py +1 -1
  2. tests/test_app.py +18 -1
app.py CHANGED
@@ -97,7 +97,7 @@ def compress_and_upload(
97
 
98
  # --- 1. Load Model and Tokenizer ---
99
  model = AutoModelForCausalLM.from_pretrained(
100
- model_id, torch_dtype="auto", device_map=None, token=token
101
  )
102
 
103
  output_dir = f"{model_id.split('/')[-1]}-{quant_method}"
 
97
 
98
  # --- 1. Load Model and Tokenizer ---
99
  model = AutoModelForCausalLM.from_pretrained(
100
+ model_id, torch_dtype="auto", device_map=None, token=token, trust_remote_code=True
101
  )
102
 
103
  output_dir = f"{model_id.split('/')[-1]}-{quant_method}"
tests/test_app.py CHANGED
@@ -112,7 +112,7 @@ def test_compress_and_upload_success(
112
 
113
  mock_whoami.assert_called_once_with(token="test_token")
114
  mock_auto_model_for_causal_lm.from_pretrained.assert_called_once_with(
115
- model_id, torch_dtype="auto", device_map=None, token="test_token"
116
  )
117
  mock_oneshot.assert_called_once()
118
  assert mock_oneshot.call_args[1]["model"] == mock_auto_model_for_causal_lm.from_pretrained.return_value
@@ -135,6 +135,23 @@ def test_compress_and_upload_success(
135
  assert "✅ Success!" in result
136
  assert "https://huggingface.co/test_user/test_model-AWQ" in result
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  def test_compress_and_upload_model_no_architecture(
139
  mock_hf_api,
140
  mock_whoami,
 
112
 
113
  mock_whoami.assert_called_once_with(token="test_token")
114
  mock_auto_model_for_causal_lm.from_pretrained.assert_called_once_with(
115
+ model_id, torch_dtype="auto", device_map=None, token="test_token", trust_remote_code=True
116
  )
117
  mock_oneshot.assert_called_once()
118
  assert mock_oneshot.call_args[1]["model"] == mock_auto_model_for_causal_lm.from_pretrained.return_value
 
135
  assert "✅ Success!" in result
136
  assert "https://huggingface.co/test_user/test_model-AWQ" in result
137
 
138
+ def test_compress_and_upload_with_trust_remote_code(
139
+ mock_hf_api,
140
+ mock_whoami,
141
+ mock_auto_model_for_causal_lm,
142
+ mock_oneshot,
143
+ mock_model_card,
144
+ mock_gr_oauth_token,
145
+ ):
146
+ model_id = "org/test_model"
147
+ quant_method = "AWQ"
148
+ compress_and_upload(model_id, quant_method, mock_gr_oauth_token)
149
+
150
+ mock_auto_model_for_causal_lm.from_pretrained.assert_called_once_with(
151
+ model_id, torch_dtype="auto", device_map=None, token="test_token", trust_remote_code=True
152
+ )
153
+
154
+
155
  def test_compress_and_upload_model_no_architecture(
156
  mock_hf_api,
157
  mock_whoami,