Skip to content

analysis: keep annotated reports aligned with authoring syntax #116

Description

@zhen8838

Problem

The annotated output emitted by tilefoundry analyze --operands is not source-aligned with the authoring model. It prints lowered/expanded IR forms for operations that the tutorial author wrote in DSL syntax, so a reader cannot reliably map the report back to the model.

Reproduction

In the tutorial source, Stage4_WeightPrepared contains:

wq_local = tf.reshard(w_q, (1, HIDDEN, HIDDEN @ cta.head), "smem")

The corresponding annotated report prints an expanded form like:

v1 = reshard(w_q, layout=ShardLayout(
        layout=Layout((1, 256, 8, 32), None),
        attrs=(S(2),),
        mesh=cta,
    ), storage=smem)

Likewise, Stage5_CachePrepared authoring uses a Python slice:

k_cache[:, base : base + BLOCK, :, :]

but the report prints a generated IR operation:

v16 = slice(k_cache, (0, v15, 0, 0), sizes=(1, 128, 2, 32), strides=(1, 1, 1, 1))

Expected behavior

Provide one of these source-aligned forms in analysis output:

  1. Preserve the original authoring expression and source location alongside each report record.
  2. Add a stable source mapping from each generated IR call/value back to the authoring expression.
  3. Clearly label the output as lowered IR and provide a source-level rendering for tutorial/agent use.

The key requirement is that reshard layouts and tensor slices must not look like syntax sugar or unrelated operations: the report should explain their relationship to the authoring model and preserve enough information for an agent to navigate back to the source.

Context

This was found while rendering docs/tutorial/authoring.ipynb into the installed tutorial Markdown. The generated report is numerically useful, but its current representation is misleading for a syntax/tutorial page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions