Skip to content

Conversation

@minettekaum
Copy link
Contributor

@minettekaum minettekaum commented Nov 21, 2025

Description

The ZipAr algorithm was added to Pruna.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

There aren't tests implemented for this algorithm yet. But it has been tested that the script runs.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment @cursor review or bugbot run to trigger another review on this PR

The index of the token in the last column of the last completed row.
"""
# We get its index from the number of completed rows, i.e. the index of the first active row
return self.active_rows[0] * self.num_cols - 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect proxy token selection for new rows

The get_proxy_token_idx_for_new_row method returns the last token of the last completed row, but when starting a new row N, the proxy token should come from the previous row N-1 (which is still being generated), not from the last completed row. The formula active_rows[0] * num_cols - 1 gives the wrong row when multiple rows are active. For example, when starting row 2 with active_rows = [1, 2], it returns the last token of row 0 instead of row 1, violating the spatial adjacency principle described in the ZipAR paper.

Fix in Cursor Fix in Web

attentions=decoder_attentions, # type: ignore
hidden_states=decoder_hidden_states, # type: ignore
past_key_values=outputs.past_key_values,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Wrong scores returned in generation output

The GenerateDecoderOnlyOutput returns scores=scores and logits=raw_logits, but the code builds raw_scores at line 651 which should be used instead of scores. When output_scores is enabled, raw_scores is constructed as a tuple containing the final scores, but the return statement uses the unwrapped scores variable instead. This inconsistency means the output format doesn't match the expected tuple format for scores when return_dict_in_generate and output_scores are both enabled.

Fix in Cursor Fix in Web

@github-actions
Copy link

github-actions bot commented Dec 2, 2025

This PR has been inactive for 10 days and is now marked as stale.

Copy link
Collaborator

@gsprochette gsprochette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, I left a single comment to indicate to the user which transformer version this is compatible with :)

Generate the image tokens using the ZipAR algorithm.

This implementation was inspired by the original implementation of ZipAR:
https://github.com/ThisisBillhe/ZipAR/blob/2a5695ca2525872ac6ee38c9d62be38f0c9e985b/LlamaGen-ZipAR/autoregressive/models/generate_zipar.py.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the instability of Janus code, this generate implementation had to be based on one specific version of transformers, namely 4.54.0 .
I think this would deserve adding a "zipar" extra to pin the transformer version if the user wants to use this algorithm.

  • adding a zipar extra in the pyproject.toml
  • adding a dynamic transformers version check in the model_check_fn function
    Ideally we would test different versions of transformer to see when this breaks, but for a first integration I would say pinning is fine and we can test & fix in a following PR

@gsprochette gsprochette changed the title Feat/decoder algorithm - ZipAr feat: decoder algorithm - ZipAr Dec 12, 2025
@github-actions github-actions bot removed the stale label Dec 13, 2025
@minettekaum minettekaum force-pushed the feat/decoder-algorithm branch from 911b8df to 33c7bdd Compare December 16, 2025 13:46
@minettekaum minettekaum changed the title feat: decoder algorithm - ZipAr feat: decoder algorithm Dec 19, 2025
@minettekaum minettekaum force-pushed the feat/decoder-algorithm branch from 33c7bdd to 492dfeb Compare December 19, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants