generated from opentensor/bittensor-subnet-template
-
Notifications
You must be signed in to change notification settings - Fork 64
v3.0.4 Release #808
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
Merged
Merged
v3.0.4 Release #808
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
717c178
Add wandb dependency and update uv.lock revision to 2
bkb2135 2bf92df
Add logger_wandb configuration to mainnet and testnet YAML examples
bkb2135 0f826f1
Add LoggerWandb class for asynchronous logging to Weights & Biases
bkb2135 557294f
Add generator_times to MinerGeneratorResults and generator_time to Mi…
bkb2135 5f9c6cd
Update MinerResults to include execution time; enhance query_miners f…
bkb2135 1f6161e
Refactor logging to use LoggerWandb in validator and pipeline modules
bkb2135 f0796d7
Refactor LoggerWandb initialization and logging method; update MinerS…
bkb2135 70b5773
Enhance LoggerWandb initialization with project-specific configuratio…
bkb2135 e744450
Merge branch 'release/v3.0.3' into features/wandb-logging
bkb2135 299b9e1
Regenerate Lock
bkb2135 2fc194a
Add ruff to packages
bkb2135 17d7ab3
Refactor logger_wandb module to improve imports and maintain consiste…
bkb2135 622f73c
Add timing to tests
bkb2135 feba89f
Wrap query miners instead of altering signature
bkb2135 080b89c
Enhance error handling in LoggerWandb initialization by adding a try-…
bkb2135 465c253
Update LoggerWandb initialization to accept additional configuration …
bkb2135 e7c6e8e
Add wandb/ to .gitignore to exclude W&B files from version control
bkb2135 db80808
Enhance LoggerWandb with detailed logging for W&B run initialization …
bkb2135 4674d5c
Bump Project Version
bkb2135 006c8da
Merge branch 'release/v3.0.4' into features/wandb-logging
bkb2135 a0c8650
Update uv.lock to revision 2; bump zstandard version to 0.24.0 and ad…
bkb2135 766d2ce
Change wandb log level
bkb2135 d24a1e8
Set default log level to info
bkb2135 fb6935b
Remove unused logging import from validator.py
bkb2135 823a6c2
Merge pull request #806 from macrocosm-os/features/wandb-logging
bkb2135 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,3 +117,5 @@ cython_debug/ | |
|
|
||
| # VS Code | ||
| .vscode | ||
|
|
||
| wandb/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| from collections.abc import Mapping | ||
| from typing import Any | ||
|
|
||
| import wandb | ||
| from loguru import logger | ||
|
|
||
| from apex import __version__ | ||
| from apex.common.async_chain import AsyncChain | ||
| from apex.common.models import MinerDiscriminatorResults | ||
|
|
||
|
|
||
| def approximate_tokens(text: str) -> int: | ||
| """Count the number of tokens in a text.""" | ||
| return len(text) // 4 | ||
|
|
||
|
|
||
| class LoggerWandb: | ||
| def __init__( | ||
| self, | ||
| async_chain: AsyncChain, | ||
| project: str = "apex-gan-arena", | ||
| api_key: str | None = None, | ||
| ): | ||
| self.run: Any | None = None | ||
| if project and api_key: | ||
| try: | ||
| # Authenticate with W&B, then initialize the run | ||
| wandb.login(key=api_key) | ||
| self.run = wandb.init( | ||
| entity="macrocosmos", | ||
| project=project, | ||
| config={ | ||
| "hotkey": async_chain.wallet.hotkey.ss58_address, | ||
| "netuid": async_chain.netuid, | ||
| "version": __version__, | ||
| }, | ||
| ) | ||
| logger.info(f"Initialized W&B run: {self.run.id}") | ||
| except Exception as e: | ||
| logger.error(f"Failed to initialize W&B run: {e}") | ||
| else: | ||
| logger.warning("W&B API key not provided, skipping logging to W&B") | ||
|
|
||
| async def log( | ||
| self, | ||
| reference: str | None = None, | ||
| discriminator_results: MinerDiscriminatorResults | None = None, | ||
| tool_history: list[dict[str, str]] | None = None, | ||
| ) -> None: | ||
| """Log an event to wandb.""" | ||
| if self.run: | ||
| if discriminator_results: | ||
| processed_event = self.process_event(discriminator_results.model_dump()) | ||
| processed_event["reference"] = reference | ||
| processed_event["tool_history"] = tool_history | ||
| self.run.log(processed_event) | ||
|
|
||
| def process_event(self, event: Mapping[str, Any]) -> dict[str, Any]: | ||
| """Preprocess an event before logging it.""" | ||
| reference = event.get("reference", "") | ||
| generation = event.get("generation", "") | ||
| generator_tokens = approximate_tokens(generation) | ||
| reference_tokens = approximate_tokens(reference) | ||
|
|
||
| processed_event: dict[str, Any] = dict(event) | ||
| processed_event["generator_tokens"] = generator_tokens | ||
| processed_event["reference_tokens"] = reference_tokens | ||
|
|
||
| return processed_event | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.