Skip to content

fix(ir): correct model analysis and parser surfaces - #123

Merged
zhen8838 merged 10 commits into
tile-ai:mainfrom
zhen8838:fix/timeline-cross-scope-predecessor
Aug 26, 2026
Merged

fix(ir): correct model analysis and parser surfaces#123
zhen8838 merged 10 commits into
tile-ai:mainfrom
zhen8838:fix/timeline-cross-scope-predecessor

Conversation

@zhen8838

@zhen8838 zhen8838 commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

Why

What

  • Correct MatMul work accounting and add explicit MK/KM and KN/NK operand layouts.
  • Normalize integer scalar HIR expressions; fix parser sequences, slices, and generated spec sections.

Contract

  • MatMul defaults remain MK/KN; access relations and cost share one logical-axis mapping.

Risk

…meline

A producer hosted below a scope was represented by the node one level down
that holds it, without checking that the scope actually schedules that node.
For a block of layers in an inner loop followed by one more at the block
level -- the shape every layered model has -- the representative named a node
from a deeper chain and the scope-local lookup raised KeyError.

Such a producer needs no representative: it ended before the scope's origin,
which is what the scope is laid out from. Return None for it, and guard the
readiness fold so a predecessor the scope does not hold cannot fail the lookup.
The flop count read `batch * m * k * n` off the local types, where sharding an
axis has replaced it with `(units, per-unit)`. Split the result's last axis and
the new axis lands at -2, so `prod(shape[:-2])` counts the rows a second time
and the unit divisor never appears: per-unit work came out `global / 2` whatever
the grid was, and `performance` -- issued against that column -- read 14x apart
for two spellings of one gemm.

Count the result's elements times the contraction instead. Same arithmetic, and
it does not care where the axis went, so the two spellings now agree on the work
and on the predicted time.
A body-local name for a constant expression -- `width = A + B` -- is an IR
Binary and stays one, so 4096 + 4096 was not 8192 to a shard layout's
divisibility check and the program was refused for a dimension nothing had left
open. The same arithmetic at module level is folded by Python before it reaches
the IR, and inline in a layout it is folded here, so one spelling of one extent
behaved differently from the other two.

Fold it in `static_dim_value`, which is what everything asks. And name a dim
the way it was written when the refusal does stand: `repr` of an expression is
a node dump, and a reader cannot find their own program in it.
Two spellings the grammar refused for no reason of its own, each with a message
that named the matcher and not the cause.

A docstring is a no-op statement carrying no work, so it had no statement
pattern and `expression.attribute: pattern did not match (role 'statement_value')`
pointed at a string literal. Drop a leading one where a body is wrapped.

`tf.concat([a, b], axis=1)` is how torch, numpy, jax and tvm spell the call, so
it is the first thing an author writes, and only the varargs form parsed. A
variadic op now also takes its inputs as one sequence; no tensor is ever a list
literal, so unwrapping one is unambiguous.
Comment thread docs/spec/core-ir.md Outdated
Comment thread docs/spec/hir.md Outdated
Comment thread docs/spec/parser.md Outdated
Comment thread src/tilefoundry/analysis/timeline.py Outdated
Comment thread src/tilefoundry/ir/types/shard/shard_layout.py Outdated
Comment thread src/tilefoundry/ir/types/shape_helpers.py Outdated
Comment thread src/tilefoundry/parser/grammar_render.py Outdated
@zhen8838 zhen8838 changed the title fix(analysis): four defects a whole-model HIR turned up fix(ir): correct model analysis and parser surfaces Aug 26, 2026
Comment thread docs/spec/parser.md Outdated
Comment thread src/tilefoundry/visitor_registry/op_cost.py Outdated
Comment thread tests/analysis/test_isl_utility.py Outdated
Comment thread tests/models/qwen3_5_35b_a3b/model.py
Comment thread tests/parser/test_spec.py Outdated
@zhen8838
zhen8838 merged commit 9ea3e94 into tile-ai:main Aug 26, 2026
1 check passed
@zhen8838
zhen8838 deleted the fix/timeline-cross-scope-predecessor branch August 26, 2026 05:59
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