Fix CI: accept log_rewards kwarg in TBGAFN.get_scores#504
Merged
josephdviviano merged 2 commits intoApr 3, 2026
Conversation
Agent-Logs-Url: https://github.com/GFNOrg/torchgfn/sessions/1919552f-66e6-465f-9209-ebd7b2f8629a Co-authored-by: josephdviviano <4142570+josephdviviano@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CI failure in PR #503 by updating TBGAFN.get_scores implementation
Fix CI: accept Apr 3, 2026
log_rewards kwarg in TBGAFN.get_scores
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## custom-log-rewards #504 +/- ##
=====================================================
Coverage ? 72.46%
=====================================================
Files ? 55
Lines ? 8537
Branches ? 1098
=====================================================
Hits ? 6186
Misses ? 1961
Partials ? 390 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_hypergrid_gafn_smokewas failing withTypeError: TBGAFN.get_scores() got an unexpected keyword argument 'log_rewards'because the method signature intutorials/examples/train_hypergrid_gafn.pydidn't expose that parameter.Changes
tutorials/examples/train_hypergrid_gafn.py: Addedlog_rewards: torch.Tensor | None = NonetoTBGAFN.get_scores(). Falls back totrajectories.log_rewardswhen not supplied, preserving existing behavior.Original prompt
Fix CI failure in PR #503:
tutorials/examples/test_scripts.py::test_hypergrid_gafn_smokefails withTypeError: TBGAFN.get_scores() got an unexpected keyword argument 'log_rewards'(Actions run 23931526330, job 69799350648).Update the caller-side implementation of
TBGAFN.get_scoresintutorials/examples/train_hypergrid_gafn.pyto accept alog_rewardskeyword argument with defaultNone, and ifNonefall back totrajectories.log_rewards. Preserve existing behavior and ensure type hints/imports are correct.Repository: GFNOrg/torchgfn
Base branch: custom-log-rewards
Reference commit for context: 9630594
Acceptance:
pytest -xpasses, specifically the GAFN smoke test.log_rewardsis not passed.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
Assistant: The failing CI job is caused by an API mismatch:
tutorials/examples/test_scripts.py::test_hypergrid_gafn_smoke(lines 569–580 intutorials/examples/test_scripts.pyat ref9630594bd43b47e5008ba704da9d9c1d294971e0)9630594bd43b47e5008ba704da9d9c1d294971e0):TypeError: TBGAFN.get_scores() got an unexpected keyword argument 'log_rewards'That means some caller (very likely the Hypergrid GAFN training example invoked by
train_hypergrid_gafn_main) is calling:but the implementation of
TBGAFN.get_scores()no longer acceptslog_rewards(or never did).Fix (recommended): make
TBGAFN.get_scoresbackward-compatibleUpdate
TBGAFN.get_scores()to acceptlog_rewardsas an optional alias, so older tutorial/example code still runs.In
torchgfn/algorithms/tb_gafn.py(or whereverclass TBGAFNis defined), change the signature to includelog_rewards=Noneand map it to whatever the method currently expects (oftenrewards,log_r, etc.). Example patch:Notes:
rewards = log_rewards.exp()(or rename the internal variable appropriately). The key is: accept the keyword and convert it as needed.**kwargsis fine, but you still must explicitly listlog_rewardsif you want to accept it without error.Alternative fix: update the caller (tutorial script)
If you prefer to enforce the new API, change the call site in the Hypergrid GAFN training example (the function imported as
train_hypergrid_gafn_mainintutorials/examples/test_scripts.pyline 45). Replacelog_rewards=...with the new expected argument name.However, given this is a tutorial/example smoke test, the compatibility fix in
TBGAFN.get_scores()is usually the safest and least disruptive: it preserves older scripts and avoids breaking downstream user code.Why this will unblock CI
The workflow runs
pytest -x(see.github/workflows/ci.ymlat ref9630594bd43b47e5008ba704da9d9c1d294971e0, lines 30–36), and the run stopped at the first failure. Fixing this one signature mismatch should let the suite continue (and it was otherwise very healthy:1641 passed, 700 skipped).User: can you update the TBGAFN.get_scores() caller with default value of None?
Assistant: Update the caller-side
TBGAFN.get_scores()signature to acceptlog_rewardswith a default ofNone, so any existing code path that passeslog_rewards=...won’t crash, while keeping current behavior unchanged when it’s not provided.The CI failure was:
tutorials/examples/test_scripts.py::test_hypergrid_gafn_smokeTypeError: TBGAFN.get_scores() got an unexpected keyword argument 'log_rewards'(job logs at ref9630594bd43b47e5008ba704da9d9c1d294971e0)Concrete code change
In
tutorials/examples/train_hypergrid_gafn.py, modifyTBGAFN.get_scoresto acceptlog_rewards: torch.Tensor | None = Noneand fall back totrajectories.log_rewardswhenlog_rewardsisn’t provided: