Demo day, before demo day. Cog*Works teams benchmark their capstones on a laptop, then on hidden tests in a sandbox.
MIT BWSI
I built CogPortal from scratch as lead TA for Cog*Works, the pre-college machine learning course at MIT’s Beaver Works Summer Institute. Teams practice locally with a pip-installable CLI, then run their capstones against hidden test labels in a network-blocked Modal evaluation sandbox. A portal on Cloudflare Workers shows each team’s chosen official result on a live leaderboard, and a Discord bot posts the results. It scored all 15 team projects across the course’s three capstones.
Four surfaces, one run
A sample run across CogPortal’s four surfaces, with the portal’s and the bot’s own words on the repo’s demo fixture. The desk and devices are drawn for this page, the count in the finding is made up, and no score is shown, as the portal shows none.
Four surfaces, one run
A team meets CogPortal in four places. Local practice uses the CLI, a hosted run can start from the portal or from Discord, and Modal does the evaluation.
The cogworks CLI, where they check and test their code on their own machine.
The Modal evaluation sandbox, where a pushed commit runs with the inputs but no secrets and no network.
The portal, whose run page leads with what the run shows, in the course’s own words, before any trace or log.
CogBot on Discord, whose private /cog command shows a team’s runs and official attempts without leaving the server.
Where it came from
On July 24, an instructor gave up a lunch break to build a demo-day benchmark by hand. He pulled captions from COCO at three levels of difficulty, randomized which ones each team got so nobody could tune to them, and ran every team live on the projector. Half of it failed, and the room treated that as normal. It was a held-out evaluation done right, and it existed only because one person improvised it. CogPortal builds that hour into software.
Three levels of trust
Local practice. cogworks check works offline after install, and test and run work offline once the public data and models they fetch on first use are cached. None of them needs an account. cogworks sync uploads one report you pick (the latest by default) with the weight files that run used, and the portal marks the result self-reported.
Hosted practice. The same code runs in a Modal evaluation sandbox that gets inputs but no secrets and no network. The hidden labels stay with a trusted controller outside it.
Official evaluation. An official run has to reuse the exact artifact from a successful practice run at the same commit, and attempts are limited.
The CLI covers the four benchmarks written for the course: song identification, face recognition, face clustering and caption-to-image search.
How each surface was built
The CLI
cogworks is a Python 3.8+ package with one command. It runs a team’s submission.py when the repository has one at its root. Otherwise it finds the team’s functions however they’re named, split or wrapped in classes, by calling them in sequence and keeping only a chain that passes the benchmark’s own test, such as naming an enrolled song back from a two-second clip. A recorded run cleared the 13-repository corpus in 36 seconds. Before profiling, one repository alone took 272 seconds.
The discovery step’s time from CogPortal’s recorded demo run. Before profiling, one repository alone took 272 seconds, and the recorded run cleared all 13 in 36.
Four of those repositories had needed an adapter written by an instructor, and discovery reproduced two of those adapters’ scores to four decimal places. The published package, 0.1.0 on TestPyPI, predates discovery.
The 13 repositories in the discovery demo, grouped by outcome rather than listed in order. Four had needed an adapter written by an instructor, and discovery matched two of those adapters’ scores to four decimal places.
The sandbox
A trusted controller runs two sandboxes: one that prepares a run, with an allowlisted network, and one that evaluates it, with no network and no secrets. The controller keeps the hidden labels, scores the predictions and signs each event.
The same code has to score the same everywhere. Song identification scored differently on macOS ARM (Python 3.11, NumPy 2.4) and on Linux x86-64 (Python 3.8.20, NumPy 1.24.4), until the audio path used exact operations and checked audio hashes. The hosted score is now 0.5375 over 282 cases.
The two machines whose audio scored differently in CogPortal’s corpus tests. Song identification scored differently on them until the audio path used exact operations and checked audio hashes, and the hosted score is now 0.5375 over 282 cases.
One team’s score moved from 0.8188 to 0.8335 across three values of PYTHONHASHSEED, so the runner pins the seed.
One team’s score across three values of PYTHONHASHSEED, from the runner’s code. Only the lowest and highest scores are known, so the bar shows just its two ends, and the runner now pins the seed.
The order of the cases could leak the answers. Trying 36 orderings of a case with two identities could recover its hidden labels, so each case now gets a permutation seed derived with an HMAC, stable across submissions and never shown.
Trying 36 orderings of one case with two identities could recover its hidden labels. Each case now gets a permutation seed derived with an HMAC, stable across submissions and never shown.
When a machine was preempted, KeyboardInterrupt slipped past an except Exception and left a claimed run with no outcome. The runner now settles interrupted runs, and replay tests hold it to that.
The portal
The portal is React and TypeScript on a Hono Worker, with D1 and a run queue. Each team gets 10 completed practice runs and 3 completed official runs per benchmark and version. Failed, cancelled and refunded runs don’t count, and a run is admitted inside one transaction.
The portal’s run quota for one team on one benchmark and version, from its run accounting. Only completed runs fill a cell, since failed, cancelled and refunded runs don’t count, and a run is admitted inside one transaction.
CogBot
CogBot is a Worker that checks Discord’s signature on every request and answers privately. It reaches the portal through a typed service binding, never the database. The portal keeps each run’s message current through a Durable Object that updates it every 2 seconds and waits as long as Retry-After says when Discord answers 429.
How a Discord request becomes a run’s live message. A Durable Object updates the message every 2 seconds, and when Discord answers 429 it waits as long as Retry-After says.
Rules the build enforces
Two rules are tests, not guidelines. A benchmark that explains its metrics in the course’s own vocabulary has to explain every metric it labels, or the build fails; older benchmarks without explanations are skipped. And the signals the portal derives from a team’s process can’t carry a per-person number, because a seventeen-year-old reads any per-person number as a grade.
I test changes on a separate staging beta with its own Modal app. I’m now working with BWSI to extend CogPortal to the institute’s other courses, starting with a connector for the Edly LMS.