Skip to content

Commit 75d753d

Browse files
fix trust remote code error handling (#1627)
SUMMARY: Our error handling logic for when `trust_remote_code=True` is flawed. Currently I hit the following error when trying out `tencent/Hunyuan-A13B-Instruct`: ``` Traceback (most recent call last): File "/home/bdellabe/projects/_scratch/awq_one_shot.py", line 91, in <module> oneshot( File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/oneshot.py", line 308, in oneshot one_shot = Oneshot(**clean_local_args, **kwargs) File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/oneshot.py", line 128, in __init__ pre_process(model_args) File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/utils.py", line 59, in pre_process model_args.processor = initialize_processor_from_path( File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/utils.py", line 244, in initialize_processor_from_path if "trust_remote_code=True" in exception.value: AttributeError: 'ValueError' object has no attribute 'value' ``` This updates to fix the error message using the `.args` field on an instance of `ValueError`. No `.value` field exists in python 3.10. TEST PLAN: Now error is reported correctly: ``` Traceback (most recent call last): File "/home/bdellabe/projects/_scratch/awq_one_shot.py", line 91, in <module> oneshot( File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/oneshot.py", line 307, in oneshot one_shot = Oneshot(**local_args, **kwargs) File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/oneshot.py", line 128, in __init__ pre_process(model_args) File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/utils.py", line 59, in pre_process model_args.processor = initialize_processor_from_path( File "/home/bdellabe/projects/llm-compressor/src/llmcompressor/entrypoints/utils.py", line 245, in initialize_processor_from_path raise ValueError( ValueError: The repository for tencent/Hunyuan-A13B-Instruct contains custom code which must be executed to correctly load the tokenizer/processor. You can inspect the repository content at https://hf.co/tencent/Hunyuan-A13B-Instruct. Please pass the argument `trust_remote_code_model=True`. ``` --------- Signed-off-by: Brian Dellabetta <bdellabe@redhat.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 3c8ff73 commit 75d753d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/llmcompressor/entrypoints/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def initialize_processor_from_path(
241241
)
242242

243243
except ValueError as exception:
244-
if "trust_remote_code=True" in exception.value:
244+
if any("trust_remote_code=True" in arg for arg in exception.args):
245245
raise ValueError(
246246
f"The repository for {processor_src} contains custom code which must "
247247
"be executed to correctly load the tokenizer/processor. You can "

0 commit comments

Comments
 (0)