Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 18 additions & 1 deletion src/kernelbot/cogs/top_three_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@

logger = setup_logging(__name__)

BEGINNER_LEADERBOARDS = frozenset(
{
"conv2d_v2",
"grayscale_v2",
"histogram_v2",
"matmul_v2",
"prefixsum_v2",
"sort_v2",
"vectoradd_v2",
"vectorsum_v2",
}
)


class TopThreeCog(commands.Cog):
"""Announce leaderboard podium changes, including API-originated submissions."""
Expand All @@ -27,7 +40,11 @@ def _read_standings(self):
now = datetime.datetime.now(datetime.timezone.utc)
with self.bot.leaderboard_db as db:
for leaderboard in db.get_leaderboards():
if leaderboard["visibility"] != "public" or leaderboard["deadline"] <= now:
if (
leaderboard["name"] in BEGINNER_LEADERBOARDS
or leaderboard["visibility"] != "public"
or leaderboard["deadline"] <= now
):
continue
for gpu_type in leaderboard["gpu_types"]:
key = (leaderboard["name"], gpu_type)
Expand Down
36 changes: 35 additions & 1 deletion tests/test_top_three.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from kernelbot.cogs.top_three_cog import TopThreeCog
from kernelbot.cogs.top_three_cog import BEGINNER_LEADERBOARDS, TopThreeCog
from kernelbot.top_three import (
EVICTION_LINES,
detect_podium_change,
Expand Down Expand Up @@ -87,6 +87,40 @@ def test_trashtalk_has_variety():
assert len(set(EVICTION_LINES)) == len(EVICTION_LINES)


def test_watcher_does_not_read_beginner_leaderboard_standings():
deadline = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
beginner_leaderboards = [
{
"name": name,
"gpu_types": ["B200"],
"visibility": "public",
"deadline": deadline,
}
for name in BEGINNER_LEADERBOARDS
]
regular_leaderboard = {
"name": "flash_attention",
"gpu_types": ["H100", "B200"],
"visibility": "public",
"deadline": deadline,
}
db = Mock()
db.get_leaderboards.return_value = [*beginner_leaderboards, regular_leaderboard]
bot = Mock()
bot.leaderboard_db.__enter__ = Mock(return_value=db)
bot.leaderboard_db.__exit__ = Mock(return_value=False)

watcher = object.__new__(TopThreeCog)
watcher.bot = bot

standings = watcher._read_standings()

assert set(standings) == {("flash_attention", "H100"), ("flash_attention", "B200")}
assert db.get_leaderboard_submissions.call_count == 2
db.get_leaderboard_submissions.assert_any_call("flash_attention", "H100", limit=3)
db.get_leaderboard_submissions.assert_any_call("flash_attention", "B200", limit=3)


@pytest.mark.asyncio
async def test_watcher_sends_api_visible_database_change_to_submissions_channel():
before = [entry("1", "first", 1), entry("2", "second", 2), entry("3", "third", 3)]
Expand Down
Loading