Skip to content

Add support for Qwen3-4B-Thinking-2507 - #2428

Merged
copybara-service[bot] merged 1 commit into
mainfrom
rbierneni-qwen3-dense-checkpoint
Oct 13, 2025
Merged

Add support for Qwen3-4B-Thinking-2507#2428
copybara-service[bot] merged 1 commit into
mainfrom
rbierneni-qwen3-dense-checkpoint

Conversation

@Rohan-Bierneni

@Rohan-Bierneni Rohan-Bierneni commented Sep 30, 2025

Copy link
Copy Markdown
Collaborator

Description

Maxtext already has support for Qwen3-4B architechture, but not for the -Thinking variant out of the box. This pr aims to leverage the already implemented dense Qwen3 architechture in Maxtext to add support for the Thinking variant of Qwen3-4B.

FIXES: b/440393388

Tests

Ran forward_pass_logit_checker.py on on a converted huggingface to maxtext checkpoint via the checkpoint util and achieved a acceptable average kl-divergencevalue of 0.000514: https://paste.googleplex.com/6706050174681088

Checklist

Before submitting this PR, please make sure (put X in square brackets):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed.

@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

🤖 Hi @Rohan-Bierneni, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@RissyRan

RissyRan commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator

🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

It seems being throttle again:

Attempt 1 failed with status 429. Retrying with backoff... ApiError: {"error":{"message":"{\n  \"error\": {\n    \"code\": 429,\n    \"message\": \"You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: [https://ai.google.dev/gemini-api/docs/rate-limits.\\n*](https://ai.google.dev/gemini-api/docs/rate-limits.//n*) Quota exceeded for metric: generativelanguage.googleapis.com/generate_content_free_tier_requests, limit: 2\\nPlease retry in 54.749946391s.\",\n    \"status\": \"RESOURCE_EXHAUSTED\",\n    \"details\": [\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.QuotaFailure\",\n        \"violations\": [\n          {\n            \"quotaMetric\": \"generativelanguage.googleapis.com/generate_content_free_tier_requests\",\n            \"quotaId\": \"GenerateRequestsPerMinutePerProjectPerModel-FreeTier\",\n            \"quotaDimensions\": {\n              \"location\": \"global\",\n              \"model\": \"gemini-2.5-pro\"\n            },\n            \"quotaValue\": \"2\"\n          }\n        ]\n      },\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.Help\",\n        \"links\": [\n          {\n            \"description\": \"Learn more about Gemini API quotas\",\n            \"url\": \"[https://ai.google.dev/gemini-api/docs/rate-limits\](https://ai.google.dev/gemini-api/docs/rate-limits/)"\n          }\n        ]\n      },\n      {\n        \"@type\": \"type.googleapis.com/google.rpc.RetryInfo\",\n        \"retryDelay\": \"54s\"\n      }\n    ]\n  }\n}\n","code":429,"status":"Too Many Requests"}}
    at throwErrorIfNotOK (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/genai/dist/node/index.mjs:14072:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/genai/dist/node/index.mjs:13863:13
    at async Models.generateContentStream (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/genai/dist/node/index.mjs:15204:24)
    at async LoggingContentGenerator.generateContentStream (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/loggingContentGenerator.js:57:22)
    at async retryWithBackoff (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/utils/retry.js:62:20)
    at async GeminiChat.makeApiCallAndProcessStream (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:266:32)
    at async file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/geminiChat.js:214:40
    at async Turn.run (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/turn.js:59:30)
    at async GeminiClient.sendMessageStream (file:///usr/local/lib/node_modules/@google/gemini-cli/node_modules/@google/gemini-cli-core/dist/src/core/client.js:405:26) {
  status: 429
}

cc @richjames0

Comment thread src/MaxText/convert_qwen3_dense.py Outdated
@github-actions

github-actions Bot commented Oct 2, 2025

Copy link
Copy Markdown
Contributor

🤖 Hi @RissyRan, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@RissyRan

RissyRan commented Oct 2, 2025

Copy link
Copy Markdown
Collaborator

Now, this seems strange: https://screenshot.googleplex.com/6UjKsrTvNQPHMxV :(

Comment thread src/MaxText/configs/models/qwen3-4b-thinking-2507.yml
Comment thread src/MaxText/configs/models/qwen3-4b-thinking-2507.yml Outdated

@parambole parambole left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for making these changes. Left a few comments.

@parambole parambole left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Thank you for adding this variant.

Comment thread src/MaxText/configs/models/qwen3-4b-thinking-2507.yml Outdated
Comment thread src/MaxText/configs/models/qwen3-4b-thinking-2507.yml Outdated

@RissyRan RissyRan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some minor comments. Thanks!

@Rohan-Bierneni
Rohan-Bierneni force-pushed the rbierneni-qwen3-dense-checkpoint branch 2 times, most recently from 02e427e to 36e7538 Compare October 10, 2025 22:50
@parambole
parambole force-pushed the rbierneni-qwen3-dense-checkpoint branch from c63620f to 420a9da Compare October 13, 2025 17:44
@parambole parambole changed the title Convert checkpoint for Qwen3-4B-Thinking-2507 Add support for Qwen3-4B-Thinking-2507 Oct 13, 2025
@copybara-service
copybara-service Bot merged commit 8e856f1 into main Oct 13, 2025
21 of 22 checks passed
@copybara-service
copybara-service Bot deleted the rbierneni-qwen3-dense-checkpoint branch October 13, 2025 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants