Skip to content

fix(scalarization): Register tensor attributes as buffers - #842

Merged
ValerianRey merged 3 commits into
SimplexLab:mainfrom
SajalDevX:fix/register-scalarizer-tensors-as-buffers
Nov 5, 2026
Merged

ValerianRey merged 3 commits into
SimplexLab:mainfrom
SajalDevX:fix/register-scalarizer-tensors-as-buffers

Conversation

@SajalDevX

Copy link
Copy Markdown
Contributor

Follow-up to #839, as suggested there: same change for the scalarizers.

Constant, STCH, PBI and COSMOS stored their weights and reference tensors as plain attributes, so .to() on the scalarizer did not move them. They are now registered as non-persistent buffers, so they follow the scalarizer's dtype and device and stay out of its state_dict. Attribute access (and reassigning, e.g. pbi.weights = ...) works as before.

The other scalarizers either store no tensors or already use parameters/buffers (FAMO, UW, IMTLL). I left DWA alone since its tensors are running state computed from the losses, not user inputs.

Testing: added a test_to_moves_* test for each of the 4 classes. They fail on main and pass with the change. uv run pytest tests/unit/scalarization, ruff and ty pass.

@ValerianRey ValerianRey added cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: scalarization labels Nov 5, 2026
@ValerianRey

Copy link
Copy Markdown
Member

LGTM, tyvm.

I also fixed an inconsistency: FAMO already had a user-provided buffer that was persistent. I just made it non-persistent like the others.

@ValerianRey
ValerianRey merged commit 4a66f67 into SimplexLab:main Nov 5, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: scalarization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants