Skip to content

[Feat] Yuma Consensus v3 #1593

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 57 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c2d5b15
yuma bonds scale individually
andreea-popescu-reef Jan 22, 2025
447a936
yuma bonds scale individually for sparse
andreea-popescu-reef Jan 22, 2025
ec9a1ed
refactor alpha values
andreea-popescu-reef Jan 22, 2025
8f95924
rebase fix
andreea-popescu-reef Jan 27, 2025
c5af5db
update tests
andreea-popescu-reef Jan 28, 2025
f6c062a
compute_ema_bonds param rename
andreea-popescu-reef Jan 28, 2025
b5963a9
update tests logs
andreea-popescu-reef Jan 28, 2025
d9902e8
add yuma4 scenario test
andreea-popescu-reef Feb 4, 2025
a177304
yuma bonds scale individually
andreea-popescu-reef Jan 22, 2025
2baaa98
yuma bonds scale individually for sparse
andreea-popescu-reef Jan 22, 2025
90bafb8
refactor alpha values
andreea-popescu-reef Jan 22, 2025
4752991
rebase fix
andreea-popescu-reef Jan 27, 2025
1abe9c3
compute_ema_bonds param rename
andreea-popescu-reef Jan 28, 2025
449242f
Add consensus test file
opentaco Feb 3, 2025
7e9258d
Add map_consensus.py script
opentaco Feb 3, 2025
b96368d
Update consensus.md doc
opentaco Feb 3, 2025
c5a4368
fix alpha values
andreea-popescu-reef Feb 5, 2025
e95b412
dividents fix
andreea-popescu-reef Feb 6, 2025
388afa9
update sparse computations
andreea-popescu-reef Feb 7, 2025
8cf307b
add yuma4 kappa moves tests
andreea-popescu-reef Feb 7, 2025
d1a9d33
tests cleanup
andreea-popescu-reef Feb 11, 2025
054f472
rebase
andreea-popescu-reef Feb 20, 2025
c5497be
cargo fmt
andreea-popescu-reef Mar 17, 2025
e18b9dc
liquid alpha 2 impl
andreea-popescu-reef Mar 19, 2025
875a0ff
fix yuma4 tests
andreea-popescu-reef Mar 19, 2025
197fd0b
fix math tests
andreea-popescu-reef Mar 20, 2025
37057d3
cleanup fixes
andreea-popescu-reef Mar 20, 2025
f57481f
clippy refactor
andreea-popescu-reef Mar 20, 2025
9cdef41
add alpha sigmoid steepness param
andreea-popescu-reef Mar 20, 2025
ae6d281
refactor bonds fetching
andreea-popescu-reef Mar 21, 2025
fc06c55
use sigmoid steepness param
andreea-popescu-reef Mar 21, 2025
bf6f6d7
yuma3 rename
andreea-popescu-reef Mar 25, 2025
d6c51f0
more improved tests
andreea-popescu-reef Mar 25, 2025
b5d766b
fix rebase
andreea-popescu-reef Mar 25, 2025
4cda7e2
fix rebase tests
andreea-popescu-reef Mar 25, 2025
fddbf00
Update pallets/subtensor/src/epoch/math.rs
andreea-popescu-reef Apr 1, 2025
eb53de3
Update pallets/subtensor/src/epoch/math.rs
andreea-popescu-reef Apr 1, 2025
d480c6c
simplify alphas matrix computation
andreea-popescu-reef Apr 1, 2025
7fb6555
add Yuma3 toggle
andreea-popescu-reef Apr 8, 2025
be623f0
revert original yuma
andreea-popescu-reef Apr 8, 2025
564745a
revert no liquid alpha tests
andreea-popescu-reef Apr 8, 2025
f511bbb
fix liquid_alpha disabled
andreea-popescu-reef Apr 9, 2025
24b6bfc
Merge branch 'devnet-ready' into yuma4
camfairchild Apr 21, 2025
b6b7473
cargo lock
camfairchild Apr 21, 2025
8fdee51
fmt
camfairchild Apr 21, 2025
0fbc067
Merge branch 'devnet-ready' into yuma4-update-to-upstream
camfairchild May 1, 2025
153e3da
add event for yuma3 toggle
camfairchild May 1, 2025
c28ecc6
chore: fmt
camfairchild May 5, 2025
6f49d83
reapply Cargo.lock from devnet-ready
l0r1s May 6, 2025
9e475e1
Merge branch 'devnet-ready' into feat/yuma3
l0r1s May 6, 2025
991832c
ignore test that takes CLI input
camfairchild May 6, 2025
3bebc53
fix name of storage value in evm test
camfairchild May 6, 2025
9a44538
add set yuma3 enabled to ABI
camfairchild May 6, 2025
8215998
Merge branch 'feat/yuma3' into feat/emit-event-on-yuma3-enable
l0r1s May 7, 2025
2e2bc58
Merge pull request #1605 from opentensor/feat/emit-event-on-yuma3-enable
sam0x17 May 7, 2025
89278bb
remove direct indexing
camfairchild May 7, 2025
bd8a26b
Merge branch 'devnet-ready' into feat/yuma3
camfairchild May 7, 2025
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
200 changes: 182 additions & 18 deletions docs/consensus.md

Large diffs are not rendered by default.

39 changes: 38 additions & 1 deletion evm-tests/src/contracts/subnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,43 @@ export const ISubnetABI = [
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint16",
name: "netuid",
type: "uint16",
},
],
name: "getYuma3Enabled",
outputs: [
{
internalType: "bool",
name: "",
type: "bool",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint16",
name: "netuid",
type: "uint16",
},
{
internalType: "bool",
name: "yuma3Enabled",
type: "bool",
},
],
name: "setYuma3Enabled",
outputs: [],
stateMutability: "payable",
type: "function",
},
{
inputs: [
{
Expand Down Expand Up @@ -886,4 +923,4 @@ export const ISubnetABI = [
stateMutability: "payable",
type: "function"
},
];
];
24 changes: 22 additions & 2 deletions evm-tests/test/subnet.precompile.hyperparameter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("Test the Subnet precompile contract", () => {
})


// minDifficulty hyperparameter
// minDifficulty hyperparameter
//
// disabled: only by sudo
//
Expand Down Expand Up @@ -471,6 +471,26 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, onchainValue);
})

it("Can set yuma3Enabled hyperparameter", async () =>
{
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
const netuid = totalNetwork - 1;

const newValue = true;
const tx = await contract.setYuma3Enabled(netuid, newValue);
await tx.wait();

let onchainValue = await api.query.SubtensorModule.Yuma3On.getValue(netuid)

let valueFromContract = Boolean(
await contract.getYuma3Enabled(netuid)
);
assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
})


it("Can set alphaValues parameter", async () => {
const totalNetwork = await api.query.SubtensorModule.TotalNetworks.getValue()
const contract = new ethers.Contract(ISUBNET_ADDRESS, ISubnetABI, wallet);
Expand Down Expand Up @@ -509,4 +529,4 @@ describe("Test the Subnet precompile contract", () => {
assert.equal(valueFromContract, newValue)
assert.equal(valueFromContract, onchainValue);
})
})
})
2 changes: 2 additions & 0 deletions hyperparameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ TxRateLimit: u64 = 1; // [1 @ 64,888]
### netuid 1 (text_prompting)
```rust
Rho: u16 = 10;
AlphaSigmoidSteepness: u16 = 10.0
Kappa: u16 = 32_767; // 0.5 = 65535/2
MaxAllowedUids: u16 = 1024;
Issuance: u64 = 0;
Expand Down Expand Up @@ -46,6 +47,7 @@ WeightsSetRateLimit: u64 = 100;
### netuid 3 (causallmnext)
```rust
Rho: u16 = 10;
AlphaSigmoidSteepness: u16 = 10.0
Kappa: u16 = 32_767; // 0.5 = 65535/2
MaxAllowedUids: u16 = 4096;
Issuance: u64 = 0;
Expand Down
64 changes: 64 additions & 0 deletions pallets/admin-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ pub mod pallet {
/// Indicates if the precompile operation is enabled or not.
enabled: bool,
},
/// Event emitted when the Yuma3 enable is toggled.
Yuma3EnableToggled {
/// The network identifier.
netuid: u16,
/// Indicates if the Yuma3 enable was enabled or disabled.
enabled: bool,
},
}

// Errors inform users that something went wrong.
Expand Down Expand Up @@ -1538,6 +1545,63 @@ pub mod pallet {
Ok(())
}

///
///
/// # Arguments
/// * `origin` - The origin of the call, which must be the root account.
/// * `netuid` - The unique identifier for the subnet.
/// * `steepness` - The new steepness for the alpha sigmoid function.
///
/// # Errors
/// * `BadOrigin` - If the caller is not the root account.
/// # Weight
/// Weight is handled by the `#[pallet::weight]` attribute.
#[pallet::call_index(68)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_alpha_sigmoid_steepness(
origin: OriginFor<T>,
netuid: u16,
steepness: u16,
) -> DispatchResult {
ensure_root(origin)?;
pallet_subtensor::Pallet::<T>::set_alpha_sigmoid_steepness(netuid, steepness);

log::debug!(
"AlphaSigmoidSteepnessSet( netuid: {:?}, steepness: {:?} )",
netuid,
steepness
);
Ok(())
}

/// Enables or disables Yuma3 for a given subnet.
///
/// # Parameters
/// - `origin`: The origin of the call, which must be the root account or subnet owner.
/// - `netuid`: The unique identifier for the subnet.
/// - `enabled`: A boolean flag to enable or disable Yuma3.
///
/// # Weight
/// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees.
#[pallet::call_index(69)]
#[pallet::weight((0, DispatchClass::Operational, Pays::No))]
pub fn sudo_set_yuma3_enabled(
origin: OriginFor<T>,
netuid: u16,
enabled: bool,
) -> DispatchResult {
pallet_subtensor::Pallet::<T>::ensure_subnet_owner_or_root(origin, netuid)?;
pallet_subtensor::Pallet::<T>::set_yuma3_enabled(netuid, enabled);

Self::deposit_event(Event::Yuma3EnableToggled { netuid, enabled });
log::debug!(
"Yuma3EnableToggled( netuid: {:?}, Enabled: {:?} ) ",
netuid,
enabled
);
Ok(())
}

/// Sets or updates the hotkey account associated with the owner of a specific subnet.
///
/// This function allows either the root origin or the current subnet owner to set or update
Expand Down
4 changes: 4 additions & 0 deletions pallets/admin-utils/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ parameter_types! {
pub const TransactionByteFee: Balance = 100;
pub const SDebug:u64 = 1;
pub const InitialRho: u16 = 30;
pub const InitialAlphaSigmoidSteepness: u16 = 10;
pub const InitialKappa: u16 = 32_767;
pub const InitialTempo: u16 = 0;
pub const SelfOwnership: u64 = 2;
Expand Down Expand Up @@ -129,6 +130,7 @@ parameter_types! {
pub const InitialAlphaHigh: u16 = 58982; // Represents 0.9 as per the production default
pub const InitialAlphaLow: u16 = 45875; // Represents 0.7 as per the production default
pub const InitialLiquidAlphaOn: bool = false; // Default value for LiquidAlphaOn
pub const InitialYuma3On: bool = false; // Default value for Yuma3On
// pub const InitialHotkeyEmissionTempo: u64 = 1; // (DEPRECATED)
// pub const InitialNetworkMaxStake: u64 = u64::MAX; // (DEPRECATED)
pub const InitialColdkeySwapScheduleDuration: u64 = 5 * 24 * 60 * 60 / 12; // 5 days
Expand Down Expand Up @@ -158,6 +160,7 @@ impl pallet_subtensor::Config for Test {
type InitialAdjustmentAlpha = InitialAdjustmentAlpha;
type InitialTargetRegistrationsPerInterval = InitialTargetRegistrationsPerInterval;
type InitialRho = InitialRho;
type InitialAlphaSigmoidSteepness = InitialAlphaSigmoidSteepness;
type InitialKappa = InitialKappa;
type InitialMaxAllowedUids = InitialMaxAllowedUids;
type InitialValidatorPruneLen = InitialValidatorPruneLen;
Expand Down Expand Up @@ -196,6 +199,7 @@ impl pallet_subtensor::Config for Test {
type AlphaHigh = InitialAlphaHigh;
type AlphaLow = InitialAlphaLow;
type LiquidAlphaOn = InitialLiquidAlphaOn;
type Yuma3On = InitialYuma3On;
type Preimages = ();
type InitialColdkeySwapScheduleDuration = InitialColdkeySwapScheduleDuration;
type InitialColdkeySwapRescheduleDuration = InitialColdkeySwapRescheduleDuration;
Expand Down
Loading
Loading