Skip to content

feat(cuda): every kernel timed by itself, and the time the host waits for the device - #35

Merged
Defilan merged 5 commits into
mainfrom
agent/i2-timing
Nov 25, 2026
Merged

Defilan merged 5 commits into
mainfrom
agent/i2-timing

Conversation

@defilan-agent

@defilan-agent defilan-agent Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What

Two measuring tools for the CUDA backend. Neither changes what the model computes.

  • CudaDevice::time_kernels: while on, each launch waits for the device before and after, and the time between goes to the kernel's name and grid size. examples/generate.rs kernels prints the table per token. It makes everything slower, so it is for finding out where time goes.
  • OpsStats.waiting: how long the host waits for the device, printed per token by the generation example.

What they showed on Inkling 2 Mini on the GB10: about 1,700 launches per token; the host waits for the device 31.8 of 35.5 ms per token, so the device is the limit; the largest rows are the expert jobs (about 9 ms), the stacked query product (7 ms) and the output table (4 ms).

How it was checked

  • Mac: format, lint, and the test suite with the real model (this branch only changes the CUDA crate, which is not built there).
  • GB10: format, lint, and the whole workspace's tests with the real model.
  • New tests: a kernel run timed and untimed gives the same result; counts go to the right name and grid size; starting clears what was gathered; nothing is gathered when off; the model's waits are timed.
  • Planted bugs 172 to 175, each caught on the device.

Review

Approve with nits. Taken:

  • Kernel times were keyed by the grid's first dimension only. They are now keyed by the whole grid. Every launch today is one-dimensional, so no number changes.
  • The table now says that each time includes starting the kernel and one wait for the device.
  • There were no tests. There are now (above).

Declined:

  • "The per-token figures may be divided by the wrong count." The generation call returns only the new tokens and its hook runs as each is chosen, so timing from the first hook covers the sweeps of all new tokens but the first, which is the count used.
  • "A check on every launch while timing is off." It is one flag read next to a kernel launch of several microseconds.

@Defilan
Defilan merged commit 49aae62 into main Nov 25, 2026
2 checks passed
@Defilan
Defilan deleted the agent/i2-timing branch November 25, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant