vx-lang / vx-lang/Vx

Flat HIR: method calls (.exp()/.sqrt()/...) for the softmax attention corpus

Open
#217 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

codegen enhancement
Dominant language
Rust
Stars
14
Forks
2
Avg merge
12h 42m
Merged PRs (30d)
61

Description

Part of the C2 flat codegen epic (#200). Two backend-corpus programs now run through the flat path at print-output parity: `slice_reductions.vx` and `linear_attention.vx` (see the differential harness `flat_matches_ast_corpus_*`). The four softmax attention files (`full_softmax_attention.vx`, `multi_query_attention.vx`, `grouped_query_attention.vx`, `sparse_local_attention.vx`) still decline because they use `.exp()` — a method call (`(s[i][j] - mx).exp()`), and `hir/flatten.rs` has no `Expr::MethodCall` handling at all.

To run the softmax corpus through the flat path:

  • Flat HIR: handle `Expr::MethodCall` for the scalar math methods the corpus uses (`.exp()`, and likely `.sqrt()`/`.max()`/… elsewhere) — a new `Math`/unary opcode (receiver is `operand1`, the method selects the op), or route to an FFI call. Confirm how the AST lowers `MethodCallExpr` with `method_name == "exp"` (a `math.exp` op vs. a libm FFI call) and match it.
  • Emitter (`codegen/flat.rs`): emit the matching op (e.g. `math.exp`) or FFI call.

Then add `flat_matches_ast_corpus_full_softmax_attention` (etc.) via `assert_output_parity`. Independent of the rest of C2; not blocking C3 (which can flip the already-working subset with an AST fallback for functions the flat path declines).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with hir/flatten.rs to inspect how Expr::MethodCall and the scalar math methods are lowered, then compare the AST handling of MethodCallExpr with method_name == "exp". Update codegen/flat.rs to emit the matching operation or FFI call, and add flat_matches_ast_corpus_full_softmax_attention and the other softmax corpus parity tests using assert_output_parity. Done means the four named softmax attention files run through the flat path with output parity.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.