Skip to content

Conversation

@CodersAcademy006
Copy link

@CodersAcademy006 CodersAcademy006 commented Oct 18, 2025

This PR introduces two significant code quality improvements to gemma/model.py to enhance maintainability and API clarity. Fix #90

1. Refactor Linear and Embedding with a Base Class

  • The Change: A new QuantizedWeight base class has been created to abstract the shared logic for handling quantized weights. The Linear and Embedding classes now inherit from it.
  • The Reason: This refactor follows the DRY (Don't Repeat Yourself) principle, removing duplicated code and making the implementation cleaner and much easier to maintain.

2. Remove Redundant kv_write_indices Parameter

  • The Change: The kv_write_indices parameter in the GemmaForCausalLM.forward method signature is removed.
  • The Reason: This parameter was immediately overwritten by input_positions and its passed value was never used. Removing it cleans up the API and prevents confusion for developers.

These changes make the codebase more robust and easier to understand without altering functionality.

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.

Refactor: Improve model classes and remove redundant parameters in gemma/model.py

1 participant