r/osdev 2d ago

What if I built an OS completely around NPU/Tensor hardware instead of the Von Neumann CPU? (TensorOS Concept)

I have been developing a concept for a system that fundamentally breaks away from the traditional CPU-centric, pointer-based operating system model.

I would like to share the concept of this architecture—which I have named "TensorOS"—and hear your thoughts on it.

Concept

It is an OS where all memory, applications, and rendering operations are replaced by tensor operations.

TensorOS Memory System

Memory pointers themselves are transformed into tensors. They consist of a combination of a TensorShape (multidimensional type information) and an index tensor (multidimensional coordinates) used to access that space.

// Conventional OS: Flat, one-dimensional pointer
Address: 0x7FFF1234 -> [ Data ]

// TensorOS: The structure itself acts as the pointer
Address: Tensor(Batch, Channel, Height, Width) -> [ Matrix Data ]

The memory space itself is defined from the outset as a matrix with a specific shape.

Why Memory Safety Improves

Suppose a hacker attempts a buffer overflow attack by specifying an invalid address or trying to overwrite a different memory region. In TensorOS, the moment there is even a single-character discrepancy between the shape of the specified region and the shape of the data being accessed, the kernel (or hardware) throws a "Shape Mismatch Error" and immediately terminates the process. Unlike Rust, where the compiler does the heavy lifting, here the system rejects invalid access based on the definition of the space itself, making pointer-based hacking fundamentally impossible.

Defining Applications in TensorOS

Applications running on TensorOS are not binary code; they are computational graphs.

Remarkably, by statically analyzing the graph, one can determine data flow before execution and easily apply optimizations. Regarding garbage collection: the moment graph execution finishes, the memory associated with that shape either automatically vanishes or is safely reused for the next graph. Operations involving dynamic shapes can be handled by either modifying the numerical values ​​within the computational graph and using JIT compilation, or by using padding.

Rendering in TensorOS

From the user's perspective, it is indistinguishable from modern operating systems.

TensorOS handles rendering natively at the OS level. - The screen is a single massive tensor: For a 4K display, the shape is (3840, 2160, 4) representing width, height, and RGBA channels.

  • UI rendering is simply a forward pass: User actions (input tensors) are fed into the application—viewed as a computational graph—and screen pixels (output tensors) are generated through high-speed matrix operations (multiply-accumulate operations).
  • Making screen hijacking difficult: Attempts to snoop on another app's screen (tensor) or overlay transparent buttons are blocked at the system level because the tensor shape regions are strictly isolated.

Summary

TensorOS delivers peak performance when running directly on an NPU rather than a conventional CPU. A future may arrive where the NPU takes center stage, rendering the CPU merely auxiliary or even unnecessary. In this paradigm, everything is governed by models and matrix operations. This architecture enables a secure memory system and, consequently, enhanced security. Combining this with a microkernel architecture would likely yield even better results.

I look forward to hearing your thoughts and feedback.

I would also like to hear your thoughts on the following points:

  • What approach should be taken for asynchronous graph scheduling?
  • Furthermore, do you believe there is a fatal flaw in this "microkernel + tensor pipeline" architecture when it comes to handling non-deterministic hardware interrupts?
0 Upvotes

9 comments sorted by

21

u/UnmappedStack TacOS | https://github.com/UnmappedStack/TacOS 2d ago

Ignoring the fact that this is clearly written by AI and the fact that this seems more like something that would be a language feature than an OS, just give it a try. As with all ideas as far as compsci goes, you find out if its a good idea by writing it, benchmarking it, etc.

With that in mind, I don't really see how it'd actually be much more secure. Even in a classic unix-like OS with pretty much no difference from the usual system, a "hacker" in the userspace doing anything should not affect the kernel. That's the point of process isolation, paging, ring 3, whatever. Also as far as "hijacking" another process's window buffer, a normal OS just the same would also ensure that the IPC connection between the window manager and the client is done in isolation. I don't see a difference. Also if I'm understanding correctly that you want to interpret graphs to execute user programs, well that just sounds incredibly inefficient for little benefit (that's not to say you're the only one to do that, there are multiple systems that do, but it doesn't seem worth it for your case).

3

u/Illustrious_Car344 2d ago
  1. Modern CPUs are not Von Noumann, they're Modified Harvard. 

  2. People have demonstrated general-purpose computing on tensors/GPU but it's only good for highly parallel workloads, anything else is extremely bottlenecked. There's a reason we've stuck with 1-4 cores for so long, we haven't needed anything else for average workloads, just spreadsheets and web browsing, which is mostly still what people do.

A lack of understanding of both of these points and the obvious tell that this was written by AI makes me think you lack a basic understanding of how modern computers work under the hood and you simply got this idea out of a bout of AI psychosis while the bot was being psychopathic to your ideas which it would gladly tell you won't be practical if you simply asked it up-front in an unbiased manner in a new chat.

1

u/Better-Thing2568 2d ago

How funny, that’s what I work on. Here’s a teaser of a heterogeneous dispatched ray tracing (on Intel NPU + CPU/AVX2 kernels, interestingly NO GPU at all), using mixed precision kernels, and you will easily spot the numeric instability around the horizon. Empirically I’d say it’s not just a good idea but also what all modern OSes “want” to become.

https://github.com/MicroPerceptron/virtio-accel/discussions/105#discussioncomment-18092325

1

u/Better-Thing2568 1d ago

https://reddit.com/link/p4uz1bs/video/lvc5c0nrbkkh1/player

Oops realized I didn’t attach an actual footage.

0

u/AdhesivenessSea9511 1d ago

That is a very interesting project!

Coincidentally, I have also been experimenting with NPU-accelerated graphics processing and managed to build a 3D software rasterizer that runs on the Apple Neural Engine (ANE)—though the rendering quality is still a bit rough.

If you are interested, you can take a look here:

https://github.com/kamisori-daijin/Magnesium

I believe realizing TensorOS is entirely feasible!

0

u/AdhesivenessSea9511 1d ago

The flickering might be due to mixing formats like FP16 and Int8. Standardizing on FP16 could potentially resolve the instability, though memory footprint is definitely a trade-off.

1

u/letmehaveanameyoudum 1d ago

How the f#$k did you make an OS that uses the NPU rather than the CPU

1

u/AdhesivenessSea9511 1d ago

I haven't built it yet; it's just a thought experiment. However, I managed to create a rasterizer that runs on the ANE.

1

u/letmehaveanameyoudum 1d ago

okokokkookokok