Conversation
Summary of ChangesHello @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 a significant upgrade of the underlying large language model from a 3B to a 7B Qwen variant, impacting multiple training and sampling examples. It also includes a refactoring effort to reorganize client-side scripts and integrates a new experiment tracking system. Furthermore, the changes refine how training metrics are collected and reported within the server infrastructure, and introduce updated server configurations to support the new model. 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. Changelog
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 updates several sample scripts and server configurations, primarily to switch from a 3B to a 7B parameter model. It also introduces experiment tracking using SwanLab and refactors some metric calculation logic. The changes are generally positive, improving the examples and adding useful features. My review focuses on improving code robustness, removing leftover debugging code, and reducing code duplication for better maintainability.
| swanlab.login(api_key=os.environ['SWANLAB_API_KEY']) | ||
| swanlab.init(project="twinkle-gsm8k", config={ | ||
| 'model_id': BASE_MODEL, | ||
| }) |
There was a problem hiding this comment.
Accessing os.environ['SWANLAB_API_KEY'] directly will raise a KeyError if the environment variable is not set, causing the script to crash. It's safer to use os.environ.get() and handle the case where the key is missing by raising a more informative error.
api_key = os.environ.get('SWANLAB_API_KEY')
if not api_key:
raise ValueError("SWANLAB_API_KEY environment variable not set, but USE_SWANLAB is True.")
swanlab.login(api_key=api_key)
swanlab.init(project="twinkle-gsm8k", config={
'model_id': BASE_MODEL,
})| self.min_node_idx = 0 | ||
| self.nnodes = math.ceil(cpu_proc_count / ncpu_proc_per_node) | ||
|
|
||
| # breakpoint() |
src/twinkle/loss/grpo.py
Outdated
| Returns: | ||
| loss: Scalar loss value | ||
| """ | ||
| # breakpoint() |
| # Convert Datum to InputFeature | ||
| input_features = datum_to_input_feature(inputs, template) | ||
|
|
||
| # breakpoint() |
There was a problem hiding this comment.
Pull request overview
This PR updates the Tinker-compatible training flow to return training metrics from optim_step, adds server-side metric cleaning for compatibility, and refreshes cookbook examples/configs (notably moving several examples to Qwen2.5-7B-Instruct and adding GRPO demos).
Changes:
- Return
metricsin/optim_stepresponses by callingcalculate_metric()after optimizer steps. - Add
calculate_metric()wrappers in Tinker-compat model adapters and introduce metric “cleaning” for numeric logging. - Add/update cookbook client examples and server configs (Twinkle + Tinker, Transformers + Megatron).
Reviewed changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/twinkle/server/tinker/model.py | Returns metrics from optim_step by calling calculate_metric() post-step. |
| src/twinkle/server/tinker/common/transformers_model.py | Adds _clean_metrics and a calculate_metric() remote wrapper; includes a debug artifact. |
| src/twinkle/server/tinker/common/megatron_model.py | Adds _clean_metrics and a calculate_metric() remote wrapper. |
| src/twinkle/model/transformers/multi_lora_transformers.py | Exposes calculate_metric() as a remote function with adapter validation. |
| src/twinkle/loss/grpo.py | Adds a commented debug hook in GRPO loss. |
| src/twinkle/infra/_ray/resource_manager.py | Adds a commented debug hook during resource manager init. |
| cookbook/client/twinkle/self_congnition.py | New Twinkle client LoRA training example script. |
| cookbook/client/twinkle/sample.py | New Twinkle client inference/sampler example script. |
| cookbook/client/twinkle/grpo.py | New Twinkle client GRPO training example script. |
| cookbook/client/tinker/transformer/server_config.yaml | Updates transformer backend server config to Qwen2.5-7B-Instruct and related settings. |
| cookbook/client/tinker/transformer/server.py | Removes commented Ray debug env var setup. |
| cookbook/client/tinker/self_congnition.py | Updates example base model to Qwen2.5-7B-Instruct. |
| cookbook/client/tinker/sample.py | Updates example base model to Qwen2.5-7B-Instruct. |
| cookbook/client/tinker/megatron/server_config_7b.yaml | Adds a new Megatron 7B server config example. |
| cookbook/client/tinker/megatron/server_config.yaml | Changes Megatron example server port to 9000. |
| cookbook/client/tinker/lora.py | Updates example base model and commented resume path to 7B. |
| cookbook/client/tinker/gsm8k_grpo.py | Updates GSM8K GRPO example (incl. SwanLab logging and using returned optim metrics). |
| cookbook/client/tinker/grpo.py | Updates example base model to Qwen2.5-7B-Instruct. |
Comments suppressed due to low confidence (2)
cookbook/client/tinker/gsm8k_grpo.py:64
- With
USE_SWANLAB = Trueby default, this script will crash withKeyErrorifSWANLAB_API_KEYis not set. Consider defaultingUSE_SWANLABto False, or usingos.getenv+ a guard that logs a warning and disables SwanLab when the key is missing.
cookbook/client/tinker/gsm8k_grpo.py:388 - Variable fwdbwd_result is not used.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Leftover debug artifact: the commented # breakpoint() should be removed from the GRPO loss implementation before merging (it adds noise to a hot path and suggests interactive debugging in library code).
There was a problem hiding this comment.
Leftover debug artifact: the commented # breakpoint() should be removed from ResourceManager initialization; keeping debugger hooks (even commented) in infra code makes future debugging harder and can slip into production changes.
No description provided.