· via dev.to (home feed)
Open-source coresample traces neural network execution down to RISC-V pipeline stalls
A developer has open-sourced coresample, a toolchain that traces an int8 CNN from model code through a Rust simulator and an RV32IM compiler to cycle-level pipeline stalls on a custom RISC-V core.

A trace from model code to hardware
A developer has released coresample, an open-source project that tracks a neural network's execution from high-level model code down to the specific pipeline stalls it causes on a custom RISC-V processor. Writing on dev.to under the handle zalaso, the author frames the work as an answer to a deceptively simple question: where, exactly, do a network's compute cycles go when it runs on a CPU?
Why existing tools fell short
According to the post, the available options did not fit the problem. Conventional profilers generally stop at the software boundary and conceal what happens inside the processor, while hardware simulators often operate as opaque boxes that are hard to interrogate. What the author wanted was instruction-level visibility into a quantized convolutional network running on a five-stage pipeline, a view that required controlling every layer of the stack rather than instrumenting any single existing tool.
What the project contains
Coresample is built from four components that together span the full path from model to silicon:
- A model layer: a simulator for int8 convolutional neural networks written in Rust.
- A compiler: a tool that translates the network's operations into RV32IM instructions, the 32-bit RISC-V base integer set with multiplication and division extensions.
- A CPU: a RISC-V core implemented in SystemVerilog.
- An inspector: a browser-based viewer that renders the execution trace and, per the post, accounts for every single cycle.
Built around verifiability
A central design theme is that each piece can be checked independently. The dev.to post states that the processor core was verified against Spike, the reference RISC-V ISA simulator, and validated with the riscv-tests and riscv-arch-test suites. The network simulator is checked by matching its outputs against PyTorch results, and the compiler is held to the requirement that the instructions it generates map correctly onto the model's layers. As a demonstration, the author points to a complete trace of an int8 CNN running across 48 images, with the locations of pipeline stalls visible in the inspector.
Roadmap
The next step, according to the post, is a GPT-style transformer block added to the simulator, with token-level tracing through the same pipeline. The author also invites feedback from people working on computer architecture, RISC-V and hardware-software co-design, and the repository is available for anyone who wants to run the simulations themselves.
Why it matters
Most machine-learning performance work happens at one of two extremes: framework-level profiling that reports operator timings, or full chip simulation that is slow and difficult to connect back to model code. Coresample occupies the ground between them, tying a single network's arithmetic to concrete processor behaviour, down to the stall a particular instruction sequence causes. For engineers doing hardware-software co-design, especially around edge inference on small cores, establishing that linkage is often the hardest part of the job.
The project also illustrates why RISC-V's openness matters in practice. Building a custom core, verifying it against the standard Spike reference and architecture test suites, and publishing the whole chain is feasible for an individual developer, which would be far harder on a proprietary ISA. The planned transformer tracing would extend the approach to the workloads that dominate current ML systems, where attention and token processing may stress a pipeline quite differently from a convolutional network, potentially exposing an entirely new set of bottlenecks.
- #risc-v
- #machine-learning
- #open-source
- #profiling
- #hardware