[Experimental] Add a MultiStepPadding Operator#511
[Experimental] Add a MultiStepPadding Operator#511hiyuchang wants to merge 1 commit intoagentscope-ai:mainfrom
Conversation
Summary of ChangesHello @hiyuchang, 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 introduces an experimental Highlights
Changelog
Activity
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 introduces an experimental MultiStepPadding operator, designed to pad experience rollouts to a fixed length with placeholder experiences. The implementation is well-structured, including updates to the Experience data structures to handle these placeholders and utility functions to process them. The code is generally of high quality for an experimental feature. I've included a couple of suggestions to enhance code clarity and maintainability.
| rewards = [exp.reward for exp in exps_same_run if exp.reward is not None] | ||
| avg_reward = sum(rewards) / len(rewards) |
There was a problem hiding this comment.
The if exp.reward is not None check within the list comprehension is redundant. The assert on lines 68-70 already ensures that exp.reward is not None for all experiences in exps_same_run. Removing this redundant check will improve code clarity.
| rewards = [exp.reward for exp in exps_same_run if exp.reward is not None] | |
| avg_reward = sum(rewards) / len(rewards) | |
| rewards = [exp.reward for exp in exps_same_run] | |
| avg_reward = sum(rewards) / len(rewards) |
| def gather_statuses(experiences) -> Tensor: | ||
| statuses = [] | ||
| for exp in experiences: | ||
| if exp.info.get("status", None) == "placeholder": | ||
| statuses.append(0) | ||
| else: | ||
| statuses.append(1) | ||
| return torch.tensor(statuses, dtype=torch.bool) |
There was a problem hiding this comment.
For improved readability and type safety, consider adding a type hint for the experiences argument. Additionally, the function's body can be refactored into a more concise list comprehension.
def gather_statuses(experiences: List[Experience]) -> Tensor:
statuses = [0 if exp.info.get("status", None) == "placeholder" else 1 for exp in experiences]
return torch.tensor(statuses, dtype=torch.bool)
Description
As the title says.
Still testing the effect. Do NOT merge this PR directly.
TODO: only works with
token-mean.Checklist
Please check the following items before code is ready to be reviewed.