frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: I implemented a neural network in SQL

https://github.com/xqlsystems/xarray-sql/blob/claude/xarray-sql-mnist-demo/benchmarks/nn.py
38•alxmrs•2h ago
Two weeks ago I was on my babymoon in Corfu, Greece. While in transit, I was overseeing a GSoC intern submit an important feature to my array database library, Xarray-SQL. He added `to_dataset()`, which completed the roundtrip between thinking of array data in a tabular model simultaneously as gridded rasters (the premise of the project is that every Nd array can be mapped to 2d, where orthogonal dims of the Nd array are just primary keys of a tabular representation). We discussed in chat, now that this feature existed, what demos could we make that would prove this data model works?

With down time on a warm beach during a heatwave, cool salty water giving me fresh ideas, I had an idea: what if we used Coiled's Geospatial benchmark discussion as a comprehensive overview of geo and climate queries. Are all of these common operations secretly relational, just with the wrong data model? Using Claude Code on the beach, I can confirm that this seemed to be the case: Claude and I publish a benchmark that illustrated how every common operation in geo and climate sciences (at the 100 TB range) were actually secretly relational operations: https://github.com/xqlsystems/xarray-sql/blob/main/docs/geos....

Most surprisingly of all, from these examples was that a core operation, regridding, was just a sparse matrix-vector product. Claude had pointed out to me that in this data model, matmul was just a `SUM(val * val) ... JOIN .. GROUP BY`. This has a direct parallel to einsum notation, but can be expressed in (arguably) elegant SQL syntax! This capability seemed to be greater than the sum of it's parts.

Back in the cool water of the Ionian, I thought about the implications of this more deeply. I reflected that, all of the Coiled benchmarks did, deep down, was _post process_ simulations that happen in numerical/array code. Why couldn't these physics calculations be push down into the database also, if we could so matmul in SQL? Then it hit me: maybe they could, if in addition to linear algebra, if SQL could do calculus! https://bsky.app/profile/al.merose.com/post/3mpbods7wts2y

Later on, I implemented autograd on top of DataFusion's visitor pattern based on JAX's implementation. In my simplified array model, it turns out that we only care about partial differentiation on the diagonal of the Jacobian, meaning that `grad()`, `jvp` and `vjp` are just row-wise operations! I then implemented a common physics calculation from the coiled benchmark that required gradients. From here, I realized if I can autograd in the database, why can't I create a neural network?

As I came back home, I created some slides, and presented this work to DataFusion's inaugural showcase: https://www.youtube.com/watch?t=1511&v=5o-4hL8vGPw&feature=y... I realized in this synthesis that SQL is not necessarily a toy language for writing neural networks, but in fact, may be highly desirable in the future due to the fundamental principles of relational databases: the logical layer should be independent from the physical layer. If that property holds, and a neural network is a series of relations, could we create a SOTA distributed system for training more easily? For example, if we had one global logical plan of dataflow, could we better distribute work on 1000+ GPUs?

Several scientists and engineers and I are working together to explore this weird world of relational arrays at https://xql.systems (discord link at the bottom if you want to get involved).

Comments

tommica•2h ago
I'm just going to go back to making my CRUD endpoints...

Jokes aside, sounds really impressive, though I only understood about 10% :D

0xnyn•1h ago
initially rolled my eyes at "neural networks in SQL," but after reading the code I came away impressed

basically it comes down to using relational algebra as the IR, letting a database optimizer reason about tensor programs

alxmrs•1h ago
I would have had the same gut reaction as you lol.

You’re spot on. I think that SQL, as a data oriented and logic PL, might be ideal for writing tensor programs.

HPsquared•1h ago
Somewhat more reliable than implementing SQL in neural networks.
iqbal1980•1h ago
Why? lol
alxmrs•41m ago
https://bsky.app/profile/al.merose.com/post/3mpz4njpcvk2o
soupspaces•41m ago
Neat! Feels analogous to "X runs Doom" demos (but NN).
alxmrs•39m ago
Totally. I can’t wait to take this to https://hytradboi.com

Israel's Operation to Cultivate Ahmadinejad

https://www.nytimes.com/2026/07/13/us/politics/israel-mahmoud-ahmadinejad-iran.html
1•u1hcw9nx•51s ago•0 comments

Manifest Man

https://www.thenewcritic.com/p/manifest-man
2•ekluger•3m ago•0 comments

Lobste.rs is now running on SQLite

https://lobste.rs/s/ko1ji1
6•abetusk•8m ago•0 comments

Forgein – portable context layer for AI tools, native MCP server (MIT CLI)

https://app.forgein.ai
2•shadowmodder•9m ago•0 comments

Which Professional Credentials Actually Matter?

https://corvi.careers/blog/which-certifications-matter-by-job-family/
4•sp1982•13m ago•0 comments

What your dog's vet bill says about America's health care system (2016)

https://www.cbsnews.com/news/what-your-dogs-vet-bill-says-about-americas-healthcare/
2•paulpauper•14m ago•0 comments

The American suburbs are better than you think

https://www.noahpinion.blog/p/the-american-suburbs-are-better-than
3•paulpauper•15m ago•0 comments

California rocked by another earthquake that will unleash the Big One

https://www.dailymail.com/sciencetech/article-15973745/california-earthquake-unlocks-san-andreas-...
3•Bender•17m ago•2 comments

Ask HN: How do you troubleshoot desktop Linux crashes/freezes?

2•Curiositry•18m ago•0 comments

Wyoming's 'Explosive Diarrhea' Cases Double, Linked to Travel Outside of U.S.

https://cowboystatedaily.com/2026/07/13/wyomings-explosive-diarrhea-cases-double-linked-to-travel...
3•Bender•19m ago•1 comments

Show HN: Nihonpost – I parsed Japan Post's KEN_ALL.CSV so you don't have to

https://github.com/Thiya11/nihonpost
3•kitsunechaos•24m ago•0 comments

Ask HN: AI Agent and harness containerization/security recommendations

2•dv35z•24m ago•0 comments

Why 'Asia's cleanest village' bans tourists on Sundays

https://www.bbc.com/travel/article/20260625-why-asias-cleanest-village-bans-tourists-on-sundays
2•gmays•25m ago•0 comments

Trump Shrinks Grand Staircase-Escalante and Bears Ears National Monuments

https://www.sltrib.com/news/environment/2026/07/13/president-trump-shrinks-bears-ears/
3•almog•25m ago•0 comments

Four awful new privacy-eroding features from Meta in a month

https://manualdousuario.net/en/meta-instagram-ai-facial-recognition/
4•rpgbr•28m ago•0 comments

Show HN: I built a one-prompt hackathon platform, free entry, sponsored prizes

https://1shotchallenge.ai
4•lucasmartinic•30m ago•0 comments

" We care deeply about your privacy and respect customer choice"

https://twitter.com/spacexai/status/2076692402442846289
3•telotortium•31m ago•0 comments

Show HN: A reproducible harness for catching agent-eval cheating

https://github.com/sebuzdugan/agent-eval-harness
2•sebuzdugan•32m ago•0 comments

Show HN: Raftig – Plant Breeding X Naval Combat Roguelike

https://raftig.seldoncortex.com/
2•EstanislaoStan•33m ago•0 comments

Karios AI Agent Carzy

https://github.com/adnqcr7-code/kairosv2
2•kairos_agent•39m ago•0 comments

Claude is just Mr. Meeseeks

https://github.com/thephw/claude-meseeks
3•patrickwiseman•40m ago•0 comments

Soofi – Sovereign Open Source Foundation Models

https://www.soofi.info/
2•karussell•41m ago•1 comments

NYC Launches "Public Interest Technology (Pit) Crew" to Build Digital Solutions

https://www.nyc.gov/mayors-office/news/2026/07/mayor-mamdani-launches--public-interest-technology...
2•ChrisArchitect•43m ago•1 comments

How does an LLM feel about you?

https://sackfield.substack.com/p/how-does-an-llm-feel-about-you
2•sackfield•43m ago•0 comments

Economists are coming around to the idea that AI really is killing jobs

https://qz.com/economists-ai-job-displacement-industrial-revolution-statement-071326
4•pseudolus•45m ago•2 comments

The Estranged Worlds of J. G. Ballard

https://lareviewofbooks.org/article/jg-ballard-illuminated-man-christopher-priest-nina-allan/
2•Caiero•46m ago•0 comments

A Large-Scale Empirical Study of AI-Generated Code in Real-World Repositories

https://arxiv.org/abs/2603.27130
2•softwaredoug•47m ago•0 comments

$65K to work at Anthropic? Debate ensues amid IPO wave

https://missionlocal.org/2026/07/anthropic-sf-affordability-ipo-housing-evictions-rent/
10•gcheong•47m ago•0 comments

Primate 0.40: Route pages, store enums, async schemas and events

https://primate.run/blog/primate-040
5•terrablue•47m ago•0 comments

DOOMQL – what if SQLite were the game engine?

https://github.com/petergpt/doomql
2•simonw•49m ago•1 comments