Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why weight value must be int in hashing weights commit? #2047

Open
toilaluan opened this issue Jun 18, 2024 · 2 comments
Open

Why weight value must be int in hashing weights commit? #2047

toilaluan opened this issue Jun 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@toilaluan
Copy link

Describe the bug

I faced a error when adding commit/reveal weights to subnet
Finally i found that weights must be a list of int, though weights should be a float list sum to 1 as before.
This function: https://github.com/opentensor/bittensor/blob/master/bittensor/utils/weight_utils.py#L372

To Reproduce

Run Validator on this PR SocialTensor/SocialTensorSubnet#75

Expected behavior

/home/ubuntu/miniconda3/envs/main/lib/python3.10/site-packages/bittensor/utils/weight_utils.py:3 │
│ 88 in │
│ │
│ 385 │ │
│ 386 │ vec_values = Vec(data=None, sub_type="U16") │
│ 387 │ vec_values.value = [ │
│ ❱ 388 │ │ U16(ScaleBytes(value.to_bytes(2, "little"))) for value in values │
│ 389 │ ] │
│ 390 │ values = ScaleBytes(vec_values.encode().data)
AttributeError: 'float' object has no attribute 'to_bytes'

Screenshots

No response

Environment

Linux Ubuntu

Additional context

No response

@toilaluan toilaluan added the bug Something isn't working label Jun 18, 2024
@toilaluan toilaluan changed the title Why weight value must be int in hashing commit? Why weight value must be int in hashing weights commit? Jun 18, 2024
@ibraheem-opentensor
Copy link
Contributor

Hello @toilaluan,
Can you use weight_utils.convert_weights_and_uids_for_emit to normalize the weights? This should convert them to int
cc: @opendansor

@toilaluan
Copy link
Author

@ibraheem-opentensor thanks, i gonna try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants