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

2.1.0 Release #59

Merged
merged 68 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
d09ecbc
update validator version
p-ferreira Oct 24, 2023
c5c8eff
remove duplicated blacklist mock during setup
ifrit98 Oct 25, 2023
71098ad
consistent use of mock reward model
ifrit98 Oct 25, 2023
f6b8882
run black
ifrit98 Oct 25, 2023
4d5e989
import and mock attr fixes
ifrit98 Oct 26, 2023
9595671
remove deprecated PoW reregister on miner startup
ifrit98 Oct 26, 2023
b868941
change doc ref to register, wording tweak
ifrit98 Oct 26, 2023
b6847d3
Merge pull request #50 from opentensor/mock-reward-dedup
ifrit98 Oct 26, 2023
0ea3f43
Merge branch 'staging' into no-reregister-wallet
ifrit98 Oct 26, 2023
b3c508c
adds initial scratch for task and criteria work
p-ferreira Oct 26, 2023
47b5da7
Merge branch 'staging' into features/penalty_rewards
p-ferreira Oct 26, 2023
fbdf4cf
Merge remote-tracking branch 'origin/staging' into features/penalty_r…
p-ferreira Oct 26, 2023
b957ad0
integrates task flow with forward step
p-ferreira Oct 26, 2023
fa24bff
adds to new fields to wandb event
p-ferreira Oct 26, 2023
49a21be
split criteria and tasks in different files
p-ferreira Oct 27, 2023
8160e43
drop task doc class (to do it later)
p-ferreira Oct 27, 2023
b3d5ee6
adds keyword penalty model
p-ferreira Oct 27, 2023
a3556e6
yield tokens according to chunksize
ifrit98 Oct 27, 2023
8b01469
remove unhelpful/outdated usage
ifrit98 Oct 27, 2023
edb801b
refactor including team considerations
p-ferreira Oct 27, 2023
f3d15c6
update penalty calculations
p-ferreira Oct 27, 2023
6c428ca
adjusts wandb event
p-ferreira Oct 27, 2023
7980025
runs black on latest changes
p-ferreira Oct 30, 2023
e531c87
removes redundant key from event log
p-ferreira Oct 30, 2023
4da916c
adds license texts on new files
p-ferreira Oct 30, 2023
7aad7e0
adjust sentence match penaly model
p-ferreira Oct 31, 2023
886e50b
change round of conversations to 3
p-ferreira Oct 31, 2023
20c166d
lower diversity boundary to 0.2
p-ferreira Nov 1, 2023
c39e875
Merge branch 'staging' into features/update-diversity-threshold
p-ferreira Nov 1, 2023
e624b36
adds text separation patterns to keyword match
p-ferreira Nov 1, 2023
9563614
upgrades sentence match
p-ferreira Nov 1, 2023
69f9937
change penalty implementation to use nclip
p-ferreira Nov 1, 2023
e95ff01
updates criteria regex
p-ferreira Nov 1, 2023
5653030
removes redundant keyword penalty fn
p-ferreira Nov 1, 2023
f54f7f6
updates sentence match to content match
p-ferreira Nov 1, 2023
7124353
sample just one criteria
p-ferreira Nov 1, 2023
4eb34ab
update penalty scale factor calculation
p-ferreira Nov 1, 2023
d29ca2b
change reward evaluation to use task base text
p-ferreira Nov 1, 2023
8df514e
updates question generation criteria
p-ferreira Nov 1, 2023
f8dddfc
Merge pull request #56 from opentensor/features/update-diversity-thre…
p-ferreira Nov 1, 2023
7dbea51
Merge branch 'staging' into stream-prompting-fix
p-ferreira Nov 1, 2023
b9682d1
run black in repo
p-ferreira Nov 1, 2023
e2b3f0c
Merge pull request #53 from opentensor/stream-prompting-fix
p-ferreira Nov 1, 2023
f816d19
update reward config
p-ferreira Nov 1, 2023
42f4ad7
update docs typo
p-ferreira Nov 1, 2023
dbbdd8a
Merge branch 'staging' into no-reregister-wallet
p-ferreira Nov 1, 2023
2a70d8d
update match len criteria with count sentences fn
p-ferreira Nov 1, 2023
437b2a3
adds pm2 config file to gitignore
p-ferreira Nov 1, 2023
a932e9b
update git ignore with pm2 config file
p-ferreira Nov 1, 2023
3595ea1
Merge branch 'staging' into features/penalty_rewards
p-ferreira Nov 1, 2023
85bf11f
format criteria file with black
p-ferreira Nov 1, 2023
971d20d
Merge branch 'features/penalty_rewards' of https://github.com/openten…
p-ferreira Nov 1, 2023
0d29685
Merge pull request #51 from opentensor/no-reregister-wallet
p-ferreira Nov 1, 2023
8e9abc8
Merge branch 'staging' into features/update-reward-config
p-ferreira Nov 1, 2023
c39cdab
Merge branch 'staging' into features/penalty_rewards
p-ferreira Nov 1, 2023
58917a7
updating validators version to 2.1.0
p-ferreira Nov 1, 2023
84525c1
Merge branch 'features/penalty_rewards' of https://github.com/openten…
p-ferreira Nov 1, 2023
82691ec
update penalty scale factor
p-ferreira Nov 1, 2023
d4e95a3
updates _count_sentences regex pattern
p-ferreira Nov 1, 2023
aea679a
fix pattern definition on criteria
p-ferreira Nov 1, 2023
59df1c8
print correct subtensor
ifrit98 Nov 2, 2023
ca0352b
print correct subtensor arguments to logger
ifrit98 Nov 2, 2023
3f21ca0
Merge pull request #52 from opentensor/features/penalty_rewards
p-ferreira Nov 2, 2023
dba3115
Merge branch 'staging' into features/update-reward-config
p-ferreira Nov 2, 2023
0b8ff50
Merge branch 'staging' into print-subtensor
p-ferreira Nov 2, 2023
13ee6bf
Merge pull request #57 from opentensor/features/update-reward-config
p-ferreira Nov 2, 2023
5c7e633
Merge branch 'staging' into print-subtensor
p-ferreira Nov 2, 2023
3be91a8
Merge pull request #58 from opentensor/print-subtensor
p-ferreira Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,7 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

localtesting/
localtesting/

# pm2 config file
app.config.js
2 changes: 1 addition & 1 deletion docs/running_a_validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ btcli wallet faucet --wallet.name validator --subtensor.network test
Register your UID on the test network:

```sh
btcli wallet recycle_register --subtensor.network test
btcli subnets register --subtensor.network test
```

## 5. Start the Process
Expand Down
3 changes: 1 addition & 2 deletions neurons/miners/bittensorLM/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ usage: miner.py [-h] [--axon.port AXON.PORT] [--subtensor.network SUBTENSOR.NETW
[--miner.blacklist.force_validator_permit] [--miner.blacklist.allow_non_registered] [--miner.blacklist.minimum_stake_requirement MINER.BLACKLIST.MINIMUM_STAKE_REQUIREMENT]
[--miner.blacklist.prompt_cache_block_span MINER.BLACKLIST.PROMPT_CACHE_BLOCK_SPAN] [--miner.blacklist.use_prompt_cache] [--miner.blacklist.min_request_period MINER.BLACKLIST.MIN_REQUEST_PERIOD]
[--miner.priority.default MINER.PRIORITY.DEFAULT] [--miner.priority.time_stake_multiplicate MINER.PRIORITY.TIME_STAKE_MULTIPLICATE]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.no_register] [--miner.mock_subtensor] [--wandb.on]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.mock_subtensor] [--wandb.on]
[--wandb.project_name WANDB.PROJECT_NAME] [--wandb.entity WANDB.ENTITY] [--logging.debug] [--logging.trace] [--logging.record_log] [--logging.logging_dir LOGGING.LOGGING_DIR] [--wallet.name WALLET.NAME]
[--wallet.hotkey WALLET.HOTKEY] [--wallet.path WALLET.PATH] [--config CONFIG] [--strict] [--no_version_checking] [--no_prompt]

Expand Down Expand Up @@ -60,7 +60,6 @@ options:
--miner.no_serve If True, the miner doesnt serve the axon.
--miner.no_start_axon
If True, the miner doesnt start the axon.
--miner.no_register If True, the miner doesnt register its wallet.
--miner.mock_subtensor
If True, the miner will allow non-registered hotkeys to mine.
--wandb.on Turn on wandb.
Expand Down
3 changes: 1 addition & 2 deletions neurons/miners/openai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ usage: miner.py [-h] [--axon.port AXON.PORT] [--subtensor.network SUBTENSOR.NETW
[--miner.blacklist.force_validator_permit] [--miner.blacklist.allow_non_registered] [--miner.blacklist.minimum_stake_requirement MINER.BLACKLIST.MINIMUM_STAKE_REQUIREMENT]
[--miner.blacklist.prompt_cache_block_span MINER.BLACKLIST.PROMPT_CACHE_BLOCK_SPAN] [--miner.blacklist.use_prompt_cache] [--miner.blacklist.min_request_period MINER.BLACKLIST.MIN_REQUEST_PERIOD]
[--miner.priority.default MINER.PRIORITY.DEFAULT] [--miner.priority.time_stake_multiplicate MINER.PRIORITY.TIME_STAKE_MULTIPLICATE]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.no_register] [--miner.mock_subtensor] [--wandb.on]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.mock_subtensor] [--wandb.on]
[--wandb.project_name WANDB.PROJECT_NAME] [--wandb.entity WANDB.ENTITY] [--logging.debug] [--logging.trace] [--logging.record_log] [--logging.logging_dir LOGGING.LOGGING_DIR] [--wallet.name WALLET.NAME]
[--wallet.hotkey WALLET.HOTKEY] [--wallet.path WALLET.PATH] [--config CONFIG] [--strict] [--no_version_checking] [--no_prompt]

Expand Down Expand Up @@ -84,7 +84,6 @@ options:
--miner.no_serve If True, the miner doesnt serve the axon.
--miner.no_start_axon
If True, the miner doesnt start the axon.
--miner.no_register If True, the miner doesnt register its wallet.
--miner.mock_subtensor
If True, the miner will allow non-registered hotkeys to mine.
--wandb.on Turn on wandb.
Expand Down
3 changes: 1 addition & 2 deletions neurons/miners/vicuna/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ usage: miner.py [-h] [--axon.port AXON.PORT] [--subtensor.network SUBTENSOR.NETW
[--miner.blacklist.force_validator_permit] [--miner.blacklist.allow_non_registered] [--miner.blacklist.minimum_stake_requirement MINER.BLACKLIST.MINIMUM_STAKE_REQUIREMENT]
[--miner.blacklist.prompt_cache_block_span MINER.BLACKLIST.PROMPT_CACHE_BLOCK_SPAN] [--miner.blacklist.use_prompt_cache] [--miner.blacklist.min_request_period MINER.BLACKLIST.MIN_REQUEST_PERIOD]
[--miner.priority.default MINER.PRIORITY.DEFAULT] [--miner.priority.time_stake_multiplicate MINER.PRIORITY.TIME_STAKE_MULTIPLICATE]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.no_register] [--miner.mock_subtensor] [--wandb.on]
[--miner.priority.len_request_timestamps MINER.PRIORITY.LEN_REQUEST_TIMESTAMPS] [--miner.no_set_weights] [--miner.no_serve] [--miner.no_start_axon] [--miner.mock_subtensor] [--wandb.on]
[--wandb.project_name WANDB.PROJECT_NAME] [--wandb.entity WANDB.ENTITY] [--logging.debug] [--logging.trace] [--logging.record_log] [--logging.logging_dir LOGGING.LOGGING_DIR] [--wallet.name WALLET.NAME]
[--wallet.hotkey WALLET.HOTKEY] [--wallet.path WALLET.PATH] [--config CONFIG] [--strict] [--no_version_checking] [--no_prompt]

Expand Down Expand Up @@ -115,7 +115,6 @@ options:
--miner.no_serve If True, the miner doesnt serve the axon.
--miner.no_start_axon
If True, the miner doesnt start the axon.
--miner.no_register If True, the miner doesnt register its wallet.
--miner.mock_subtensor
If True, the miner will allow non-registered hotkeys to mine.
--wandb.on Turn on wandb.
Expand Down
28 changes: 19 additions & 9 deletions neurons/validators/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,23 @@
# Load gating models
from prompting.validators.reward import (
Blacklist,
TaskValidator,
NSFWRewardModel,
DirectPreferenceRewardModel,
OpenAssistantRewardModel,
ReciprocateRewardModel,
RelevanceRewardModel,
MockRewardModel,
DahoasRewardModel,
DiversityRewardModel,
PromptRewardModel,
RewardModelType,
)

from prompting.validators.penalty import (
TaskValidationPenaltyModel,
KeywordMatchPenaltyModel,
ContentMatchPenaltyModel,
)


class neuron:
@classmethod
Expand Down Expand Up @@ -189,8 +193,12 @@ def __init__(self):
self.blacklist,
MockRewardModel(RewardModelType.nsfw.value),
]
self.penalty_functions = [
TaskValidationPenaltyModel(max_penalty=0.1),
ContentMatchPenaltyModel(max_penalty=0.1),
KeywordMatchPenaltyModel(max_penalty=1),
]
bt.logging.debug(str(self.reward_functions))
self.blacklist = MockRewardModel(RewardModelType.blacklist.value)
else:
self.reward_weights = torch.tensor(
[
Expand Down Expand Up @@ -245,11 +253,6 @@ def __init__(self):
if not self.config.neuron.blacklist_off
else MockRewardModel(RewardModelType.blacklist.value)
)
task_validator = (
TaskValidator()
if not self.config.neuron.task_validator_off
else MockRewardModel(RewardModelType.task_validator.value)
)
relevance_model = (
RelevanceRewardModel(device=self.device)
if not self.config.neuron.relevance_off
Expand All @@ -268,13 +271,20 @@ def __init__(self):

self.masking_functions = [
self.blacklist,
task_validator,
relevance_model,
self.diversity_model,
nsfw_model,
]

self.penalty_functions = [
TaskValidationPenaltyModel(max_penalty=0.1),
ContentMatchPenaltyModel(max_penalty=0.1),
KeywordMatchPenaltyModel(max_penalty=1),
]

bt.logging.debug(str(self.reward_functions))
bt.logging.debug(str(self.masking_functions))
bt.logging.debug(str(self.penalty_functions))

# Init the event loop.
self.loop = asyncio.get_event_loop()
Expand Down
6 changes: 0 additions & 6 deletions prompting/baseminer/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,6 @@ def get_config() -> "bt.Config":
help="If True, the miner doesnt start the axon.",
default=False,
)
parser.add_argument(
"--miner.no_register",
action="store_true",
help="If True, the miner doesnt register its wallet.",
default=False,
)

# Mocks.
parser.add_argument(
Expand Down
8 changes: 4 additions & 4 deletions prompting/baseminer/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):

# Activating Bittensor's logging with the set configurations.
bt.logging(config=self.config, logging_dir=self.config.full_path)
bt.logging.info(
f"Running miner for subnet: {self.config.netuid} on network: {self.config.subtensor.chain_endpoint} with config:"
)

if not self.config.miner.blacklist.force_validator_permit:
bt.logging.warning(
Expand All @@ -89,7 +86,10 @@ def __init__(self, config=None, axon=None, wallet=None, subtensor=None):

# subtensor manages the blockchain connection, facilitating interaction with the Bittensor blockchain.
self.subtensor = subtensor or bt.subtensor(config=self.config)
bt.logging.info(f"Subtensor: {subtensor}")
bt.logging.info(f"Subtensor: {self.subtensor}")
bt.logging.info(
f"Running miner for subnet: {self.config.netuid} on network: {self.subtensor.chain_endpoint} with config:"
)

# metagraph provides the network's current state, holding state about other participants in a subnet.
self.metagraph = self.subtensor.metagraph(self.config.netuid)
Expand Down
16 changes: 10 additions & 6 deletions prompting/baseminer/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def run(self):
Initiates and manages the main loop for the miner on the Bittensor network.

This function performs the following primary tasks:
1. Optionally registers the miner's wallet with the network.
1. Check for registration on the Bittensor network.
2. Attaches the miner's forward, blacklist, and priority functions to its axon.
3. Starts the miner's axon, making it active on the network.
4. Regularly updates the metagraph with the latest network state.
Expand All @@ -48,12 +48,16 @@ def run(self):
KeyboardInterrupt: If the miner is stopped by a manual interruption.
Exception: For unforeseen errors during the miner's operation, which are logged for diagnosis.
"""
# --- Optionally register the wallet.
if not self.config.miner.no_register:
bt.logging.info(
f"Registering wallet: {self.wallet} on netuid {self.config.netuid}"
# --- Check for registration.
if not self.subtensor.is_hotkey_registered(
netuid=self.config.netuid,
hotkey=self.wallet.hotkey.ss58_address,
):
bt.logging.error(
f"Wallet: {self.wallet} is not registered on netuid {self.config.netuid}"
f"Please register the hotkey using `btcli subnets register` before trying again"
)
self.subtensor.register(netuid=self.config.netuid, wallet=self.wallet)
exit()

# Serve passes the axon information to the network + netuid we are hosting on.
# This will auto-update if the axon port of external ip have changed.
Expand Down
37 changes: 1 addition & 36 deletions prompting/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,17 +160,6 @@ class StreamPrompting(bt.StreamingSynapse):
- `extract_response_json`: Extracts relevant JSON data from the response, useful for gaining insights on the response's
metadata or for debugging purposes.

Example usage:
```python
stream_prompter = StreamPrompting(roles=["role1", "role2"], messages=["message1", "message2"])
# Process a streaming response...
stream_prompter.process_streaming_response(response)
# Access the result
result = stream_prompter.deserialize()
# Extract response metadata
json_info = stream_prompter.extract_response_json(response)
```

Note: While you can directly use the `StreamPrompting` class, it's designed to be extensible. Thus, you can create
subclasses to further customize behavior for specific prompting scenarios or requirements.
"""
Expand Down Expand Up @@ -215,18 +204,6 @@ async def process_streaming_response(self, response: StreamingResponse):
Args:
response: The streaming response object containing the content chunks to be processed. Each chunk in this
response is expected to be a set of tokens that can be decoded and split into individual messages or prompts.

Usage:
Generally, this method is called when there's an incoming streaming response to be processed.

```python
stream_prompter = StreamPrompting(roles=["role1", "role2"], messages=["message1", "message2"])
await stream_prompter.process_streaming_response(response)
```

Note:
It's important to remember that this method is asynchronous. Ensure it's called within an appropriate
asynchronous context.
"""
if self.completion is None:
self.completion = ""
Expand All @@ -235,6 +212,7 @@ async def process_streaming_response(self, response: StreamingResponse):
for token in tokens:
if token:
self.completion += token
yield tokens

def deserialize(self) -> str:
"""
Expand Down Expand Up @@ -266,19 +244,6 @@ def extract_response_json(self, response: StreamingResponse) -> dict:
- Dendrite and Axon related information extracted from headers.
- Roles and Messages pertaining to the current StreamPrompting instance.
- The accumulated completion.

Usage:
This method can be used after processing a response to gather detailed metadata:

```python
stream_prompter = StreamPrompting(roles=["role1", "role2"], messages=["message1", "message2"])
# After processing the response...
json_info = stream_prompter.extract_response_json(response)
```

Note:
While the primary output is the structured dictionary, understanding this output can be instrumental in
troubleshooting or in extracting specific insights about the interaction with the Bittensor network.
"""
headers = {
k.decode("utf-8"): v.decode("utf-8")
Expand Down
2 changes: 1 addition & 1 deletion prompting/validators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from . import event
from . import dataset

__version__ = "2.0.2"
__version__ = "2.1.0"
version_split = __version__.split(".")
__spec_version__ = (
(1000 * int(version_split[0]))
Expand Down
2 changes: 1 addition & 1 deletion prompting/validators/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def add_args(cls, parser):
"--neuron.num_followup_steps",
type=int,
help="How many followup steps to take.",
default=4,
default=3,
)

parser.add_argument(
Expand Down
Loading