-
Notifications
You must be signed in to change notification settings - Fork 192
update qwen-image text token length error #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,11 @@ async def _wait_task_and_stream_result(task_id: str, timeout_seconds: int, poll_ | |
| raise HTTPException(status_code=500, detail=f"Task completed but no in-memory image found: {task_id}") | ||
|
|
||
| if status == TaskStatus.FAILED.value: | ||
| raise HTTPException(status_code=500, detail=task_status.get("error", "Task failed")) | ||
| error_type = task_status.get("error_type", "") | ||
| error_detail = task_status.get("error", "Task failed") | ||
| if error_type == "ValueError": | ||
| raise HTTPException(status_code=413, detail=error_detail) | ||
|
Comment on lines
+39
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mapping all |
||
| raise HTTPException(status_code=500, detail=error_detail) | ||
|
|
||
| if status == TaskStatus.CANCELLED.value: | ||
| raise HTTPException(status_code=409, detail=task_status.get("error", "Task cancelled")) | ||
|
|
@@ -108,6 +112,8 @@ async def create_image_task(message: ImageTaskRequest): | |
| save_result_path=message.save_result_path, | ||
| ) | ||
| except RuntimeError as e: | ||
| if getattr(e, "original_error_type", "") == "ValueError": | ||
| raise HTTPException(status_code=413, detail=str(e)) | ||
|
Comment on lines
+115
to
+116
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check for |
||
| raise HTTPException(status_code=503, detail=str(e)) | ||
| except Exception as e: | ||
| logger.error(f"Failed to create image task: {e}") | ||
|
|
@@ -168,6 +174,8 @@ async def create_image_task_sync( | |
| raise | ||
|
|
||
| except RuntimeError as e: | ||
| if getattr(e, "original_error_type", "") == "ValueError": | ||
| raise HTTPException(status_code=413, detail=str(e)) | ||
| raise HTTPException(status_code=503, detail=str(e)) | ||
| except HTTPException: | ||
| raise | ||
|
|
@@ -229,6 +237,8 @@ async def save_file_async(file: UploadFile, target_dir: Path) -> str: | |
| save_result_path=message.save_result_path, | ||
| ) | ||
| except RuntimeError as e: | ||
| if getattr(e, "original_error_type", "") == "ValueError": | ||
| raise HTTPException(status_code=413, detail=str(e)) | ||
| raise HTTPException(status_code=503, detail=str(e)) | ||
| except Exception as e: | ||
| logger.error(f"Failed to create image form task: {e}") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tokenizer is called twice for the same input text: once here to calculate lengths and again on the following line to generate the tensors. This is inefficient, especially for large batches or long prompts.\n\nConsider calling the tokenizer once with
padding=Trueandreturn_tensors="pt", then checking the length of the resultinginput_idstensor before moving it to the device.