[PR #137] [CLOSED] Fix: Handle past_key_values AttributeError in generate Function #221

Closed
opened 2026-10-26 21:14:15 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/deepseek-ai/Janus/pull/137
Author: @scifisatan
Created: 2/4/2025
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (1)

  • 25466b5 fix: streamline past_key_values handling in generate function

📊 Changes

1 file changed (+9 additions, -14 deletions)

View changed files

📝 demo/app_janusflow.py (+9 -14)

📄 Description

Issue

The generate function in app_janusflow.py encountered the following error:

AttributeError: 'tuple' object has no attribute 'get_seq_length'

image

I was running Python 3.10.12 and it error occured when i ran python3 demo/app_janusflow.py

Cause:
The error occurred because past_key_values was being passed as a tuple to vl_gpt.language_model.model, while the expected structure required either None or a properly formatted past key-value state.

Fix

  • Ensured that past_key_values is correctly initialized as None at the start (step == 0).
  • Properly handled its reassignment in subsequent steps:
    if step == 0:
        past_key_values = None  # Ensure it starts as None
    else:
        past_key_values = tuple(past_key_values) if past_key_values else None  # Convert only if it's valid
    
  • This prevents the tuple from being incorrectly accessed when past_key_values is None.

Testing

  • Verified that the model runs without throwing an AttributeError.
  • Checked inference results to ensure correctness.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/deepseek-ai/Janus/pull/137 **Author:** [@scifisatan](https://github.com/scifisatan) **Created:** 2/4/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`25466b5`](https://github.com/deepseek-ai/Janus/commit/25466b5f408655d4d99e08e8b42b087e60af2f6f) fix: streamline past_key_values handling in generate function ### 📊 Changes **1 file changed** (+9 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `demo/app_janusflow.py` (+9 -14) </details> ### 📄 Description #### **Issue** The `generate` function in `app_janusflow.py` encountered the following error: ``` AttributeError: 'tuple' object has no attribute 'get_seq_length' ``` ![image](https://github.com/user-attachments/assets/2abdfaa8-31d0-48f6-b1ce-acba1c21946d) I was running `Python 3.10.12` and it error occured when i ran `python3 demo/app_janusflow.py` **Cause:** The error occurred because `past_key_values` was being passed as a `tuple` to `vl_gpt.language_model.model`, while the expected structure required either `None` or a properly formatted past key-value state. #### **Fix** - Ensured that `past_key_values` is correctly initialized as `None` at the start (`step == 0`). - Properly handled its reassignment in subsequent steps: ```python if step == 0: past_key_values = None # Ensure it starts as None else: past_key_values = tuple(past_key_values) if past_key_values else None # Convert only if it's valid ``` - This prevents the `tuple` from being incorrectly accessed when `past_key_values` is `None`. #### **Testing** - Verified that the model runs without throwing an AttributeError. - Checked inference results to ensure correctness. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-26 21:14:15 +00:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/Janus#221
No description provided.