[Model] Support IQuestCoder Model#16574
Conversation
Summary of ChangesHello @yxing-bj, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates the IQuestCoder and IQuestLoopCoder models into the SGLang framework, expanding the range of supported code-focused large language models. The changes include adding specific model implementations for IQuestLoopCoder's unique multi-loop attention, adapting the KV cache handling for this architecture, and updating model configuration to correctly reflect its structure. This enables users to leverage these new models for autonomous software engineering and code intelligence tasks on the SGLang platform. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds support for the IQuestCoder and IQuestLoopCoder models. The changes include a new model implementation for IQuestLoopCoder, which features a multi-loop attention mechanism with cross-layer KV cache sharing. The modifications to the model configuration and attention backend correctly accommodate this new architecture. The code is generally well-structured, but I have a couple of suggestions to improve code clarity and address a potential issue.
| self.num_attention_layers = self.num_hidden_layers | ||
| if "LongcatFlashForCausalLM" in self.hf_config.architectures: | ||
| self.num_attention_layers = self.num_hidden_layers * 2 | ||
| if "IQuestLoopCoderForCausalLM" in self.hf_config.architectures: |
There was a problem hiding this comment.
This if condition should likely be an elif. If hf_config.architectures could contain both LongcatFlashForCausalLM and IQuestLoopCoderForCausalLM, the current logic would have the calculation for IQuestLoopCoderForCausalLM overwrite the one for LongcatFlashForCausalLM. Using elif would make the choices mutually exclusive, which seems more correct for different model architectures.
| gate_logits = gate_logits.transpose(0, 1) | ||
| gate_logits = gate_logits.unsqueeze(-1) | ||
|
|
||
| # Apply sigmoid | ||
| gate = torch.sigmoid(gate_logits) | ||
|
|
||
| # Expand and reshape to match q shape: [num_tokens, num_heads * head_dim] | ||
| gate = gate.transpose(0, 1) | ||
| gate = gate.expand(-1, -1, head_dim) | ||
| gate = gate.reshape(num_tokens, num_heads * head_dim) |
There was a problem hiding this comment.
The logic to reshape gate_logits can be simplified. The current implementation uses a transpose, unsqueeze, and then another transpose which is a bit convoluted. You can achieve the same result more directly by removing the unnecessary transpositions.
| gate_logits = gate_logits.transpose(0, 1) | |
| gate_logits = gate_logits.unsqueeze(-1) | |
| # Apply sigmoid | |
| gate = torch.sigmoid(gate_logits) | |
| # Expand and reshape to match q shape: [num_tokens, num_heads * head_dim] | |
| gate = gate.transpose(0, 1) | |
| gate = gate.expand(-1, -1, head_dim) | |
| gate = gate.reshape(num_tokens, num_heads * head_dim) | |
| gate_logits = gate_logits.unsqueeze(-1) | |
| # Apply sigmoid | |
| gate = torch.sigmoid(gate_logits) | |
| # Expand and reshape to match q shape: [num_tokens, num_heads * head_dim] | |
| gate = gate.expand(-1, -1, head_dim) | |
| gate = gate.reshape(num_tokens, -1) |
d8f5a54 to
e595b4d
Compare
e595b4d to
ac9d4b3
Compare
Motivation
IQuest-Coder-V1 is a new family of code large language models (LLMs) designed to advance autonomous software engineering and code intelligence. We built a repo about IQuestCoder.
We had uploaded these models to Hugging Face, including IQuestCoder and IQuestLoopCoder. To make them easier for everyone to use, we support these models on sglang platform.
Modifications
Support IQuestCoder and IQuestLoopCoder.
At the same time, thanking for @attack204 efforts about PR
Tests
Firstly, we launch sglang server
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci) or contact authorized users to do so.