Open toilaluan opened 2 weeks ago
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
Run Validator on this PR https://github.com/NicheTensor/NicheImage/pull/75
/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'
No response
Linux Ubuntu
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
weight_utils.convert_weights_and_uids_for_emit
@ibraheem-opentensor thanks, i gonna try it
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 https://github.com/NicheTensor/NicheImage/pull/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