Benign huggingface Download

kepton0117/sn-79topstrategy main

pytest test frameworkImports Python's pickle serialization module
SHA-256c08d28f35eada030e29f7e60b43b30310c97ac8183aeddd75f23b84e0555686b

Evidence

English function-word token "the" lines 1–6
1"""Safety tests for gradient deserialization.
2
3Pins the hardened-load contract on the miner -> validator path:
4
5 - torch.load runs with weights_only=True, so a pickled __reduce__
6 payload from an untrusted bucket cannot execute
Imports Python's pickle serialization module lines 8–28
8:35, param names, dtype, shape, finite
9 values, and index range. Anything off-spec raises ValueError and
10 the caller drops the gradient.
11
12Run: pytest GenTRX/tests/test_gradient_deserialize_safety.py -v
13"""
14
15import io
16import math
17import pickle
18
19import pytest
20import torch
21
7 lines
Python test source content lines 64–81
5 lines
69 data = serialize(comp)
70 out = deserialize(data, expected_shapes=_expected_shapes())
71 assert out.metadata.window_id == 1
72 assert out.metadata.miner_uid == 42
73 assert set(out.sparse.keys()) == {"layer.weight", "layer.bias"}
74 idx, vals, shape = out.sparse["layer.weight"]
75 assert torch.equal(idx, torch.tensor([0, 5, 10], dtype=torch.int64))
76 assert torch.allclose(vals, torch.tensor([0.1, -0.2, 0.3]))
77 assert tuple(shape) == (4, 4)
78
79
80# ---------------------------------------------------------------------------
81# Code-exec via
English function-word token "that" lines 82–101
82:71-------
83
84
85class _ReducePayload:
86 """A pickle that, when loaded with weights_only=False, would invoke os.system."""
87
88 def __reduce__(self):
13 lines
JSON-like object window ID field lines 121–128
121:27tvalue(), expected_shapes=_expected_shapes())
122
123
124def test_rejects_unknown_param_name():
125 data = _raw_payload(
126 metadata={"window_id": 1, "miner_uid": 1, "steps_trained": 1,
127 "loss_before": 0.0, "loss_after": 0.0, "loss_trajectory": []},
128

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.