Skip to content

Fix compat tinker and update doc#73

Merged
Yunnglin merged 5 commits intomainfrom
fix/compat_tinker
Feb 25, 2026
Merged

Fix compat tinker and update doc#73
Yunnglin merged 5 commits intomainfrom
fix/compat_tinker

Conversation

@Yunnglin
Copy link
Copy Markdown
Collaborator

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

Write the detail information belongs to this PR.

Experiment results

Paste your experiment result here(if needed).

Copilot AI review requested due to automatic review settings February 25, 2026 09:55
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Yunnglin, 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 focuses on improving the compatibility and ease of use of the Tinker client within the Twinkle ecosystem. It updates the client initialization process, streamlines code examples, and refines documentation to provide a more consistent and user-friendly experience. Additionally, it removes an unnecessary option from the server CLI, simplifying server management.

Highlights

  • Tinker Client Integration: Replaced init_tinker_compat_client with init_tinker_client and direct ServiceClient usage from the tinker library, streamlining the Tinker client initialization process.
  • Documentation Updates: Updated documentation to reflect the changes in client initialization and usage, providing clearer guidance for developers using the Tinker client with Twinkle.
  • Code Modernization: Removed the --no-wait option from the server CLI, simplifying server launching and management.

🧠 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.

Changelog
  • README.md
    • Replaced init_tinker_compat_client with init_tinker_client.
  • README_ZH.md
    • Replaced init_tinker_compat_client with init_tinker_client in the Chinese README.
  • cookbook/client/tinker/lora.py
    • Updated the LoRA training example to use init_tinker_client and direct ServiceClient import.
  • cookbook/client/tinker/megatron/server_config_7b.yaml
    • Added Qwen/Qwen2.5-7B-Instruct to the supported models.
  • cookbook/client/tinker/sample.py
    • Updated the sampling example to use init_tinker_client and direct ServiceClient import.
  • cookbook/client/tinker/self_congnition.py
    • Updated the self-cognition example to use init_tinker_client and direct ServiceClient import.
  • cookbook/client/tinker/short_math_grpo.py
    • Updated the short math GRPO example to use init_tinker_client and direct ServiceClient import.
  • docs/source_en/Usage Guide/Server and Client/Overview.md
    • Renamed 'Server and Client' to 'Overview' and updated client initialization instructions.
  • docs/source_en/Usage Guide/Server and Client/Server.md
    • Removed the --no-wait option from the server CLI documentation.
  • docs/source_en/Usage Guide/Server and Client/Tinker-Compatible-Client.md
    • Renamed 'Tinker Compatible Client' to 'Tinker Client' and updated initialization instructions.
  • docs/source_zh/使用指引/服务端和客户端/Tinker兼容客户端.md
    • Renamed 'Tinker 兼容客户端' to 'Tinker 客户端' and updated initialization instructions in the Chinese documentation.
  • docs/source_zh/使用指引/服务端和客户端/服务端.md
    • Removed the --no-wait option from the server CLI documentation in Chinese.
  • docs/source_zh/使用指引/服务端和客户端/概述.md
    • Renamed '服务端和客户端' to '概述' and updated client initialization instructions in the Chinese documentation.
  • src/twinkle/server/main.py
    • Removed the --no-wait argument and related comments.
  • src/twinkle/server/launcher.py
    • Removed the wait argument from the launch method and simplified the launching process.
  • src/twinkle/server/tinker/common/compat_base.py
    • Removed unused imports and added a local import for selective_log_softmax.
  • src/twinkle/server/tinker/server.py
    • Improved the normalization of supported models to handle string-based model names.
  • src/twinkle_client/init.py
    • Replaced init_tinker_compat_client with init_tinker_client and updated documentation.
  • src/twinkle_client/utils/patch_tinker.py
    • Added a patch to inject Twinkle-specific headers into Tinker's _get_default_headers.
  • tests/DeviceMesh/test_device_mesh.py
    • Updated import statements to reflect the new module structure.
Activity
  • The pull request includes bug fixes, new features, and document updates.
  • The primary focus is on improving the Tinker client integration and simplifying the server launching process.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the Tinker-compatible client initialization API. The init_tinker_compat_client function, which both patched the tinker library and created a client, is replaced by a new two-step pattern: init_tinker_client() is called once to apply patches, and then users can instantiate tinker.ServiceClient directly. This is a cleaner, less "magical" API design. The changes are applied consistently across all documentation and example code. The PR also includes several other fixes, such as correcting a bug in an example script where a client was used without being assigned, and removing the --no-wait server option to simplify launch logic. My main feedback concerns a potential issue with how the API key is handled in the new patching mechanism, which could lead to authentication failures if the key is not provided via an environment variable.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates Twinkle’s Tinker-compatibility layer by shifting client usage toward a “patch then use tinker.ServiceClient directly” flow, and aligns examples/docs/configs accordingly.

Changes:

  • Replace init_tinker_compat_client with init_tinker_client() (patch-only initialization) and update docs/cookbook examples to construct tinker.ServiceClient directly.
  • Extend the Tinker patching logic to inject Twinkle-specific headers by patching Tinker’s internal default-header builder.
  • Adjust server/client compatibility details (supported model normalization, launcher blocking behavior, and a few import cleanups).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/DeviceMesh/test_device_mesh.py Switches to importing DeviceMesh/Platform from Twinkle’s top-level lazy API.
src/twinkle_client/utils/patch_tinker.py Adds a patch to inject Twinkle-required headers into Tinker requests.
src/twinkle_client/init.py Replaces init_tinker_compat_client with init_tinker_client() and updates public exports.
src/twinkle/server/tinker/server.py Tweaks supported model normalization (now expecting model_name).
src/twinkle/server/tinker/common/compat_base.py Moves selective_log_softmax import into method and switches DeviceMesh import to top-level.
src/twinkle/server/launcher.py Removes the optional non-blocking launch mode; launcher now blocks unconditionally.
src/twinkle/server/main.py Removes --no-wait CLI option and related docs.
cookbook/client/tinker/short_math_grpo.py Updates client initialization to init_tinker_client() + direct ServiceClient.
cookbook/client/tinker/self_congnition.py Updates to init_tinker_client() + direct ServiceClient; updates example defaults.
cookbook/client/tinker/sample.py Updates to init_tinker_client() + direct ServiceClient; small example fixes.
cookbook/client/tinker/megatron/server_config_7b.yaml Adds supported_models to config for the 7B setup.
cookbook/client/tinker/lora.py Updates to init_tinker_client() + direct ServiceClient; renumbers steps.
README.md Updates Tinker client usage snippet to the new init + direct ServiceClient flow.
README_ZH.md Same as README.md for the Chinese doc.

@Yunnglin Yunnglin merged commit 58cca7c into main Feb 25, 2026
2 of 4 checks passed
@Yunnglin Yunnglin deleted the fix/compat_tinker branch February 25, 2026 10:35
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