Repository navigation
Conversation
CI performance trends
Krackan - OperatorsOperators dropped: Benchmarks that moved by at least 5% and by more than 2x the spread the runs measured:
Krackan - ApplicationsOperators dropped: |
There was a problem hiding this comment.
π‘ Changes recommended
Vision profiles are omitted from distributions, and concurrent external-image downloads can race on a shared temporary file.
2 open findings
What changed in this PR
This PR completes the transition to graph-based language models and declared operators, updates supporting CI/toolchain infrastructure, and pins the merged mlir-aie softmax-block dependency.
Changes:
- Adds graph-oriented model, operator, profile, and hardware-validation coverage.
- Removes legacy Torch-based operators, references, compilation infrastructure, and tests.
- Updates packaging, dependencies, CI caching, and benchmark reporting.
| File | Description |
|---|---|
REUSE.toml |
Updates data-file licensing. |
requirements.txt |
Updates mlir-aie toolchain pins. |
requirements_stream.txt |
Revises stream dependencies. |
requirements_examples.txt |
Simplifies model dependencies. |
pyproject.toml |
Adds package data configuration. |
iron/βtests/βtoolchain/βtools.py |
Adds shared toolchain-test utilities. |
iron/βtests/βtoolchain/βinline_kernel.py |
Tests inline kernel lowering. |
iron/βtests/βtoolchain/βconftest.py |
Parameterizes toolchain devices. |
iron/βtests/βstream/βkernel_layouts.py |
Updates stream module paths. |
iron/βtests/βoperators/βswiglu_prefill_no_padding.py |
Removes legacy SwiGLU test. |
iron/βtests/βoperators/βresample_reference_raster.py |
Tests raster preservation. |
iron/βtests/βoperators/βresample_patch_rows.py |
Tests padded patch rows. |
iron/βtests/βoperators/βmha_buffer_shapes.py |
Tests MHA buffer shapes. |
iron/βtests/βoperators/βgemm_bounded_rows.py |
Tests bounded GEMM rows. |
iron/βtests/βoperators/βcopy_channels.py |
Tests multichannel copies. |
iron/βtests/βoperators/βcopy_bounded_view.py |
Tests bounded copy views. |
iron/βtests/βoperators/βcatalog.py |
Adds centralized operator tests. |
iron/βtests/βoperators/βaxpy_reference.py |
Removes Torch reference tests. |
iron/βtests/βinfrastructure/βtracing.py |
Migrates tracing to graphs. |
iron/βtests/βinfrastructure/βswiglu_no_padding.py |
Tests graph SwiGLU alignment. |
iron/βtests/βinfrastructure/βsequence_output_sync.py |
Tests repeated output synchronization. |
iron/βtests/βinfrastructure/βprobe_standalone.py |
Tests standalone tuner probes. |
iron/βtests/βinfrastructure/βconftest_lazy_device.py |
Tests NPU-less skipping. |
iron/βtests/βinfrastructure/βcompilable_design_contract.py |
Tests compilation cache identity. |
iron/βtests/βinfrastructure/βcarried_values.py |
Tests graph-carried values. |
iron/βtests/βconftest.py |
Refines custom test collection. |
iron/βtests/βcompilation/βrelative_build_dir.py |
Removes legacy compilation test. |
iron/βtests/βcompilation/βfactory_kernel_object.py |
Removes legacy kernel-object test. |
iron/βtests/βcommon/βoperators_declared.py |
Validates exported declarations. |
iron/βtests/βcommon/βllama_small_profile.json |
Adds small Llama tuning profile. |
iron/βtests/βcommon/βllama_model.py |
Adds reusable test Llama model. |
iron/βtests/βcommon/βconv2d_graph.py |
Tests Conv2d graph behavior. |
iron/βtests/βcommon/βbounded_graphs.py |
Adds shared bounded graphs. |
iron/βoperators/βtranspose/βreference.py |
Removes Torch reference. |
iron/βoperators/βtanh/βtest.py |
Removes legacy test. |
iron/βoperators/βtanh/βreference.py |
Removes Torch reference. |
iron/βoperators/βtanh/βop.py |
Removes legacy implementation. |
iron/βoperators/βtanh.py |
Adds declared Tanh operator. |
iron/βoperators/βswiglu_prefill_stream/βstream/βmapping.py |
Updates relocated imports. |
iron/βoperators/βswiglu_prefill_stream/βstream/βhardware.py |
Updates documentation. |
iron/βoperators/βswiglu_prefill_stream/βstream/β__init__.py |
Updates stream package documentation. |
iron/βoperators/βswiglu_prefill_stream/βlayout.py |
Updates imports and documentation. |
iron/βoperators/βswiglu_decode/βreference.py |
Removes legacy reference. |
iron/βoperators/βswiglu_decode/βop.py |
Removes legacy sequence. |
iron/βoperators/βstrided_copy/βop.py |
Removes legacy copy operator. |
iron/βoperators/βsplit3.py |
Adds inline split kernel. |
iron/βoperators/βsoftmax/βtest.py |
Removes legacy test. |
iron/βoperators/βsoftmax/βreference.py |
Removes Torch reference. |
iron/βoperators/βsoftmax/βop.py |
Removes legacy implementation. |
iron/βoperators/βsilu/βtest.py |
Removes legacy test. |
iron/βoperators/βsilu/βreference.py |
Removes Torch reference. |
iron/βoperators/βsilu/βop.py |
Removes legacy implementation. |
iron/βoperators/βsilu.py |
Adds declared SiLU operator. |
iron/βoperators/βsigmoid/βtest.py |
Removes legacy test. |
iron/βoperators/βsigmoid/βreference.py |
Removes Torch reference. |
iron/βoperators/βsigmoid/βop.py |
Removes legacy implementation. |
iron/βoperators/βsigmoid.py |
Adds declared Sigmoid operator. |
iron/βoperators/βrope/βtest.py |
Removes legacy test. |
iron/βoperators/βrope/βREADME.md |
Removes obsolete documentation. |
iron/βoperators/βrope/βop.py |
Removes legacy implementation. |
iron/βoperators/βrms_norm/βreference.py |
Removes Torch reference. |
iron/βoperators/βrepeat/βtest.py |
Removes legacy test. |
iron/βoperators/βrepeat/βreference.py |
Removes Torch reference. |
iron/βoperators/βrepeat/βop.py |
Removes legacy implementation. |
iron/βoperators/βrelu/βtest.py |
Removes legacy test. |
iron/βoperators/βrelu/βreference.py |
Removes Torch reference. |
iron/βoperators/βrelu/βop.py |
Removes legacy implementation. |
iron/βoperators/βrelu.py |
Adds declared ReLU operator. |
iron/βoperators/βmem_copy/βtest.py |
Removes legacy test. |
iron/βoperators/βmem_copy/βreference.py |
Removes Torch reference. |
iron/βoperators/βmem_copy/βop.py |
Removes legacy implementation. |
iron/βoperators/βlog_mel/βtest.py |
Adds LogMel device tests. |
iron/βoperators/βleaky_relu/βtest.py |
Removes legacy test. |
iron/βoperators/βleaky_relu/βreference.py |
Removes Torch reference. |
iron/βoperators/βleaky_relu/βop.py |
Removes legacy implementation. |
iron/βoperators/βleaky_relu.py |
Adds declared LeakyReLU operator. |
iron/βoperators/βlayer_norm/βtest.py |
Removes legacy test. |
iron/βoperators/βlayer_norm/βreference.py |
Removes Torch reference. |
iron/βoperators/βlayer_norm/βop.py |
Removes legacy implementation. |
iron/βoperators/βlayer_norm.py |
Adds declared LayerNorm operator. |
iron/βoperators/βimage_patches/βtest.py |
Adds image-patch device tests. |
iron/βoperators/βgemv/βreference.py |
Removes Torch reference helpers. |
iron/βoperators/βgemm/βreference.py |
Removes Torch reference helpers. |
iron/βoperators/βgelu/βtest.py |
Removes legacy test. |
iron/βoperators/βgelu/βreference.py |
Removes Torch reference. |
iron/βoperators/βgelu/βop.py |
Removes legacy implementation. |
iron/βoperators/βgelu.py |
Adds declared GELU operator. |
iron/βoperators/βflm/βtesting.py |
Removes legacy FLM test helpers. |
iron/βoperators/βflm/βprefill_attn/βreference.py |
Updates reference documentation. |
iron/βoperators/βflm/βprefill_attn/βREADME.md |
Documents OperatorImage usage. |
iron/βoperators/βflm/βmm_prebuilt/βREADME.md |
Removes obsolete shipped-overlay docs. |
iron/βoperators/βflm/βlm_head/βreference.py |
Updates reference documentation. |
iron/βoperators/βflm/βlm_head/βREADME.md |
Documents OperatorImage usage. |
iron/βoperators/βflm/βlm_head/βdesign.py |
Simplifies validation and TAPs. |
iron/βoperators/βflm/βlayer/βREADME.md |
Updates layer dispatch documentation. |
iron/βoperators/βflm/βdequant/βREADME.md |
Updates dequant usage. |
iron/βoperators/βflm/βdataflow.py |
Removes obsolete grid helper. |
iron/βoperators/βflm/β__init__.py |
Updates lazy FLM exports. |
iron/βoperators/βelementwise_mul/βtest.py |
Removes legacy test. |
iron/βoperators/βelementwise_mul/βreference.py |
Removes Torch reference. |
iron/βoperators/βelementwise_mul/βop.py |
Removes legacy implementation. |
iron/βoperators/βelementwise_mul.py |
Adds declared multiplication operators. |
iron/βoperators/βelementwise_add/βtest.py |
Removes legacy test. |
iron/βoperators/βelementwise_add/βreference.py |
Removes Torch reference. |
iron/βoperators/βelementwise_add/βop.py |
Removes legacy implementation. |
iron/βoperators/βelementwise_add.py |
Adds declared addition operator. |
iron/βoperators/βdequant/βtest.py |
Removes legacy test. |
iron/βoperators/βdequant/βop.py |
Removes legacy implementation. |
iron/βoperators/βdequant.py |
Adds declared dequantization operator. |
iron/βoperators/βconv2d/βtest.py |
Adds Conv2d device tests. |
iron/βoperators/βaxpy/βtest.py |
Removes legacy test. |
iron/βoperators/βaxpy/βreference.py |
Removes Torch reference. |
iron/βoperators/βaxpy/βop.py |
Removes legacy implementation. |
iron/βoperators/βaxpy.py |
Adds declared AXPY operator. |
iron/βoperators/β_trace.py |
Removes legacy tracing helper. |
iron/βlm/βencoder.py |
Adds graph-based encoder support. |
iron/βcommon/βutils.py |
Removes superseded utilities. |
iron/βcommon/βimage/β__init__.py |
Exports image infrastructure. |
iron/βcommon/βgraph/β__init__.py |
Exports graph infrastructure. |
iron/βcommon/βdevice_utils.py |
Removes legacy device helpers. |
iron/βcommon/βdesign/βtarget.py |
Adds operator build targets. |
iron/βcommon/βdesign/β__init__.py |
Exports design infrastructure. |
iron/βcommon/βdeclare/βxclbin.py |
Adds external-image fetching. |
iron/βcommon/βdeclare/β__init__.py |
Exports declaration vocabulary. |
iron/βcommon/βcontext.py |
Removes legacy build context. |
iron/βcommon/βcompilation/β__init__.py |
Removes legacy compilation exports. |
iron/βcommon/β__init__.py |
Exposes declared operator APIs. |
iron/βapplications/βllama3/βtune.py |
Adds Llama tuning entry point. |
iron/βapplications/βllama3/βprofiles/βnpu2.json |
Adds NPU2 Llama profile. |
iron/βapplications/βllama3/βprofiles/βnpu1.json |
Adds NPU1 Llama profile. |
iron/βapplications/βllama3/β__init__.py |
Adds Llama application package. |
iron/βapplications/βllama_3.2_1b/βREADME.md |
Removes obsolete application docs. |
iron/βapplications/βgemma4_flm/βtest.py |
Updates model gating and metrics. |
iron/βapplications/βgemma4_flm/βREADME.md |
Documents JIT cache outputs. |
iron/βapplications/βgemma4_flm/βpli_weights.py |
Replaces Torch packing with NumPy. |
iron/βapplications/βgemma4_flm/βMakefile |
Configures cached operator builds. |
iron/βapplications/βembeddinggemma2/βvision/βtune.py |
Adds vision tuning entry point. |
iron/βapplications/βembeddinggemma2/βvision/βprofiles/βnpu2.json |
Adds NPU2 vision profile. |
iron/βapplications/βembeddinggemma2/βvision/βprofiles/βnpu1.json |
Adds NPU1 vision profile. |
iron/βapplications/βembeddinggemma2/βvision/β__init__.py |
Adds vision package. |
iron/βapplications/βembeddinggemma2/βaudio/βtune.py |
Adds audio tuning entry point. |
iron/βapplications/βembeddinggemma2/βaudio/β__init__.py |
Adds audio package. |
iron/βapplications/βembeddinggemma2/β__init__.py |
Adds EmbeddingGemma package. |
iron/βapplications/β__init__.py |
Adds applications package. |
iron/β__init__.py |
Adds lazy public graph API. |
ci/βscripts/βpretty_trends.py |
Handles catalog benchmark names. |
ci/βscripts/βpretty_common.py |
Normalizes renamed benchmark paths. |
ci/βscripts/βmerge_all.py |
Merges normalized benchmark keys. |
ci/βscripts/βbuild_pages.py |
Groups catalog benchmark results. |
.github/βworkflows/βphoenix-test-examples.yml |
Adds isolated compile caching. |
.github/βworkflows/βkrackan-examples.yml |
Updates model environment and caching. |
.github/βactions/βtest/βaction.yaml |
Includes shared tests in operator CI. |
.github/βactions/βprereqs/βaction.yaml |
Installs example dependencies centrally. |
π§ Review effort: Balanced
π‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
hunhoffe
left a comment
There was a problem hiding this comment.
initial feedback.
Every fetch of one image wrote the same `<file>.part` beside the target and renamed it into place, so two processes fetching at once could hash or rename a file the other had just truncated or moved (Copilot's review of PR #222). The download is now verified in memory, written to a NamedTemporaryFile in the target's directory and renamed over the target with os.replace, so no fetch shares a path with another and none sees a partial target. The file is made 0644, as the plain write made it under the default umask. The new test fetches flm.gemm.Shipped's real image from eight threads into one directory. Against the previous fetch it failed 4 of 5 runs (FileNotFoundError on the .part, a failed rename, and once an empty file's digest); with this change it passed 8 of 8. Verified: pytest iron/tests/common/build.py: 18 passed. Co-Authored-By: Claude <noreply@anthropic.com>
An operator called outside a graph's body now compiles its own image once and runs it: `op(*tensors, **dispatch_values)`, one device tensor per declared buffer, as `OperatorImage(op)(...)` did; `op.compile()` builds it and returns its `Artifacts`. The image is the one OperatorImage built, which stays as the internal class behind those two calls, kept per instance. A call with anything but one device tensor per buffer is refused before anything is compiled. `SwiGLUPrefillStream`, which subclassed OperatorSequence and was driven through `get_callable()/get_buffer()`, is an `iron.Graph` over its stream-dse groups, compiled and called like any graph (inputs `input`, `w_gate`, `w_up`, `w_down`; it returns `output`). Removes from the user surface: `OperatorImage`, `OperatorSequence` and its hand-written `'buf[a:b]'` runlists (neither is exported from `iron.common.image` any more), and `get_callable`/`get_buffer` as the way a caller runs several operators; a graph is the one composition API. The tests that exercise the sequence internals themselves (layout, fusion, co-residence, feedback, compare mode) import it from `iron.common.image.sequence`. Callers: harness.run_test, gemma4_flm/build.py, flm's gemm benchmark and the flm dequant/gemm/layer/lm_head/prefill_attn tests and READMEs, swiglu_prefill_stream op/test/README, dispatch_params, jit_compile_path (plus one new device-free test: an operator keeps the image it built, an equal one builds its own from the cache), copy_channels, lowering_graph, xclbin, graph.py's refusal test, AGENTS.md. Not done here: `probe.Standalone` drawing through `vectors` (S7's last item). It changes the tuner's measured inputs, and the tuner steps moved out of #222 (Erika, Wed 10-14 13:30), so it goes with them. Diff (git diff --shortstat HEAD~1): library 10 files +76 -68, tests 23 files +101 -109, applications 1 file +22 -25, docs 7 files +31 -31; total 41 files +230 -233. Verified (plan v5.1: collect-only per step, the tip is debugged once): pytest --collect-only 2273 ids, 0 errors (S4's 2272 plus the new test); pytest -n 4 iron/tests/common iron/tests/operators/rejected_shapes.py: 447 passed, 4 skipped; pytest -m "not supported_devices and not extensive" over iron/tests/{infrastructure,operators,stream,lm}, iron/operators and tests/: 349 passed, 27 skipped; black clean. Not run: the device tests (flm, swiglu_prefill_stream, gemma4_flm, copy_channels); the swiglu_prefill_stream test skips at module level (stream-dse does not parse against the pinned mlir-aie, and stream is not installed here). Co-Authored-By: Claude <noreply@anthropic.com>
Removes pytest's own copies of the CLI flags (--random-weights, --max-seq-len) and Runner.from_arguments beside the fixtures' own parsing. Runner.FLAGS is the tuple of flag strings and add_argument keywords both argparse's CLI (add_arguments, now a classmethod so it can also place --size there, dropping main()'s own copy of that logic) and pytest's conftest.py (pytest_addoption) read: one list, so the two cannot drift again as they had (conftest.py's --random-weights/ --max-seq-len were already identical in spirit to main()'s). The new Runner.from_options(args, parser=None) serves both: given an already-parsed argparse.Namespace (main()'s own, its further generation-only flags already read) it only resolves the config (--size or the checkpoint's own config.json, --max-seq-len's override) and calls from_arguments; given option strings (or none, meaning sys.argv[1:]) it first builds a fresh parser from add_arguments and parses them. main() now calls it instead of carrying its own copy of the config-resolution block. The llama application test's runner fixture now builds its option strings from pytest's own --random-weights/ --max-seq-len and calls the same from_options, so the CLI and the test fixture build a runner through identical code, which is what this step's gate asks to prove. (EmbeddingGemma 2's own CLI and tests do not use iron.lm.Runner's flag parsing at all, today or before this step, so nothing there needed matching treatment.) This also caught a real bug while testing: Model.load's first attempt kept its own self.versions list, which collides with CompiledGraph's existing self.versions property (every compiled version, by shape, in compile order) -- iron.Graph already tracks this, which is exactly what Model.load needed, so CausalLM.load now reads self.versions.values() instead of keeping a parallel list. Verified: pytest --collect-only -q, 2858 collected (was 2853: 5 new tests), no errors. New iron/tests/common/runner_options.py builds a runner both ways (from_options's own parser, and a direct Runner(...) call) and checks they agree, for --random-weights and, now that this host's llama3.2-1b checkpoint has grown a config.json since S19/S21's commits, a real tokenizer too (previously would have skipped); also checks add_arguments' two FLAGS parse as conftest.py's pytest options do, and that a runner refuses neither or both of a tokenizer and --random-weights. All the config.json-gated tests that skipped under S19-S22 for lacking that file now run for real and still pass (64 passed, 3 skipped -- qwen3's checkpoint, unrelated, and an empty costs_*.json glob, S17's tuner work, deferred out of #222). black --check and reuse lint: clean. Verified device-free up through compilation only (not the actual device upload): a standalone compile of both of Llama SMALL's versions populates self.versions in order with the feeds chaining Model.load now does generically. The actual CausalLM.load()/.npu() device path (weight upload, Llama accuracy and device loop, EG2 multimodal) needs a real NPU run, which under the no-per-step-gating regime belongs to the end-of-PR device run, not a step gate. Co-Authored-By: Claude <noreply@anthropic.com> (cherry picked from commit 87396efa42e214f60c15d527e9a3ed00f56c2d8e)
#222 conflicted with devel after #244 (a focused GEMM/dequant FastFlowLM engine override example), so its pull_request CI stopped running. Conflicts: - requirements_examples.txt: iron-next's list, plus #244's matplotlib and seaborn (plot_prefill.py). - gemma4_flm/Makefile: #244's FastFlowLM v1.0.8 and $(PYTHON), with iron-next's build.py flags and cache directory. #244's new code ported to iron-next: - build_gemm_dequant.py: no AIEContext; op.compile() returns the artifacts it stages (image, insts); named --engine-xclbins/--out flags. - dequantize.py: iron-next's pack_b is numpy (IRON needs no torch). - The device test moves to tests/applications/gemma4_flm/gemm_dequant/, with the build's flags, and records TTFT through record_property (iron-next has no metrics marker). Verified: collect-only 1816; the new file's host tests pass 5 of 6, the sixth needs matplotlib, which this venv lacks and CI's examples install has; black and reuse clean. The FastFlowLM device test runs on Krackan. Co-Authored-By: Claude <noreply@anthropic.com>
|
LGTM |
Fixes from the step 15 review: - PK-1: a design built for an xclbin that takes a per-call value is a dispatch parameter, and a pack's one sequence does not carry it. unvalued() refuses it, naming the value. fits() refuses it, so AdjacentPacking declines it, and PerStep refuses an explicit group that holds it. AdjacentPacking.pack now logs each decline for both paths; the full ELF dropped its declines the same way. Decode's designs carry per-call values, so decode does not pack on NPU1 yet. Passing values through as dispatch parameters would be its own change. - PK-2: aiecc binds at most 16 host buffer objects to a kernel (kMaxHostBOs), and a merged sequence takes every step's buffers. A run is cut before it would pass more (PerStep.HOST_BUFFERS), and a piece of one step runs alone. Cutting keeps each step's arguments as they are. Merging duplicate arguments would have to alias views within one sequence. - PK-3: tests now cover the merged sequence's order (rtp writes and fifo moves per step), a pack whose members meet once, the cut, a pinned design whose pin the run declares once, and link() plus the callable with the chain and NPUKernel stubbed: one kernel per run over every step's buffers, and a member that also runs alone builds its own. Each of the review's mutations fails one of them: reversed order, skipped declare, one-step runs, the alone member skipping its own build, and only the first step's buffers. - Nits: the artifacts record each run as a design and label its steps with it, so a member that runs both alone and in a run shows both. The check=True refusal says to pass check=False or drop coresident. MergedRuntime.merge loses its redundant assert. Correction to 86ff0a7's message: the task-group fix landed in PR #50 at 2e2f85418, an ancestor of eac7fd99c, not in eac7fd99c itself. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
aiecc refuses more than kMaxHostBOs (16), not 16 itself; the cut test stopped at 15 + 3, so a >= cut passed it. Review nit on PK-2. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
Model.bos and Model.eos already mean the prompt's first token and the stop tokens; the embedder's own appended end-of-text token gets its own name. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018BbsWH2HBE9S4MDeH7Qt7Z
_interval and _rounded have had no library caller since operator fusion went; only test_judging writing an output just past a tolerance used them (audit SUB-5). They move to iron/tests/support/judging.py, and their own self-test goes with them, a test helper needing none. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
RMSNorm and LayerNorm refused more than one axis and LayerNorm another eps at construction, and F.rms_norm and F.layer_norm refuse both again at record, with the module's check the weaker (audit SUB-9). F's checks stay, F being the public functional API; the modules keep only normalized_shape as torch's norms take it, and their duplicate test goes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
AdjacentPacking's max_members and time_shape's fit_cache had no caller, tests included (audit SUB-10). A pack now grows while the placer takes it, and time_shape asks refusal under its default FIT_CACHE. refusal keeps its fit_cache, which its own test passes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
Weights were filled two ways: Checkpoint.tree("random"/"unread"),
which every model and golden uses, and Graph.draw/unread, which only
tests called (audit SUB-6/API-2; Erika's D1, reword the plan). The
graph's fills go; the tests that used them to have weights load a
Checkpoint.tree fill or tensors of their own, and the two that tested
only draw and unread go.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
Precision could be set per call, per layer, on the graph, at record and at compile; only the first two had a production caller (audit SUB-3 and API-10; Erika's D2, delete the floor). Graph.precision, record(precision=), compile(precision=), the recorder's raising of each step and its id cache, Operator.at_precision with ProjectionGEMM's hand over to GEMM, and Precision.at_least go. F.linear(precision=HIGHEST) already runs GEMM itself. The tests of the floor go; the encoder test's config carries HIGHEST as a model's does. Snapshots (models, ports, encoders, npu1 and npu2): every default precision recording, layout and MLIR is identical; the highest ones are recorded through the removed record(precision=) and no longer exist. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
held() counted every ndarray a graph holds as a weight, while the plan says only params are (audit API-3; Erika's D5, use param). The walker now takes a param, an iron.weight table or a state, and nothing else. iron.param(array) holds an array itself as a param, as torch's nn.Parameter(tensor); load_state_dict binds through it, and a Checkpoint.tree()'s tensors are params, so a model holding its tree keeps naming each weight by the tree's path. iron.weight keeps a param's class, so a table gathered through it keeps its path too. What models derive from their params as they load (Granite's embedding scale and folded norm, LFM2's, Qwen3.5's and Granite-H's taps and heads, Qwen3-MoE's stacked experts, Gemma's norms and per-layer table, PleLayer's scale, EmbeddingGemma 2's tables, the CNNs' folded convolutions, Conv1d's, Conv2d's, LogMel's and MaxPool2d's matrices) is wrapped in iron.param. Snapshots (models, ports, encoders, EmbeddingGemma 2's toy and ResNet's, npu1 and npu2): steps, weights and their names, layouts, MLIR and reference outputs identical. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016EEEuzitXS9tBPsonthWGK
self._runs is list[FullELFRun] | None since start() now builds it lazily; steps() always runs after start(), but pyright has no way to know that, and flagged three reportOptionalSubscript errors. Narrow with the same assert idiom causal.py's loop() already uses for the same shape of fact. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
β¦ry from the ctrlcode heap Krackan's examples fail CREATE_BO with ENOSPC (Gemma 4 E2B, EmbeddingGemma 2, Llama 3.2 3B) while the same three pass on Strix Halo at the 9 GiB budget. Shrinking every decoder's caches separates the two candidates: if the failures clear, the host's pinned memory is the limit; if they stay, the device heap's control code is. Co-Authored-By: Claude <noreply@anthropic.com>
β¦ned memory from the ctrlcode heap" This reverts commit dd868b1. Its one run answered the question: the same seven tests fail CREATE_BO with ENOSPC at 4096 positions, on a runner with 93 GiB of RAM and unlimited locked memory, each in pyxrt.run's control code, so the limit is the device heap, not pinned host memory. Co-Authored-By: Claude <noreply@anthropic.com>
β¦th copies bfd9771 freed first's run after it runs so body's depth copies need not share the device heap with it. start() still made every body copy before first ran, and its first_run local kept first's pyxrt runs alive past release(), so the heap held first plus depth body copies at once either way. Now start() makes body's first copy (first's Emit feeds it), runs first, drops every reference to first's run, then makes the rest. On Strix Halo (512 MiB heap) Gemma 4 E2B's loop, first 89.8 MiB of ctrlcode and body 20.9 MiB, ran to depth 20 and failed at 21; it now runs to 24, failing at 25, where body's copies alone fill the heap. Co-Authored-By: Claude <noreply@anthropic.com>
β¦weight floor" This reverts commit fc6e922. It sized Krackan's pinned host memory, but 29f679d's run showed Krackan's CREATE_BO failures are the device heap's control code, not pinned memory, so the 9 GiB cap and the device loop depth knob it added both answer a limit that is not there. Co-Authored-By: Claude <noreply@anthropic.com>
410c4f6 and 6f432c1 capped Krackan's arena (12, then 8 GiB) through IRON_MEMORY_BUDGET_GIB, taking its CREATE_BO failures for pinned host memory. 29f679d's run showed otherwise: at 4096 positions, on a runner with 93 GiB of RAM and unlimited locked memory, the same tests fail in pyxrt.run's control code, so the device heap is the limit. The cap only shortened Krackan's contexts, and at 8 GiB refused Gemma 4 E2B's 8.6 GiB of weights in Model.fit before it reached the device; it goes, and with it IRON_MEMORY_BUDGET_GIB, which nothing else sets. Co-Authored-By: Claude <noreply@anthropic.com>
29f679d's run showed Krackan's amdxdna device heap holds less control code than Gemma 4 E2B's and EmbeddingGemma 2's full ELFs need: each fails CREATE_BO with ENOSPC in pyxrt.run, whatever the context. Strix Halo runs the same tests. Krackan's Examples and Nightly jobs set IRON_XFAIL_DEVICE_HEAP, and conftest.py reports a test failing with that error, in setup or call, as xfail. Any other failure on Krackan still fails, and every other runner is unchanged. Dropping the flag from Krackan's matrix entry restores the tests once the runner is fixed. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
π΅ Needs a closer look
The cross-cutting graph/image migration requires human confirmation of NPU1/NPU2 hardware-suite and golden-reference results to establish runtime correctness and model accuracy beyond source-only review.
No open issues π
1 resolved since last review
Review effort: Balanced
Restores the decoders and long_context coverage Qwen3, Qwen3-Embedding, Qwen3-Reranker and Qwen3-MoE already have their own device tests for: every other model's checkpoint is held to its whole context, and every full-elf decoder but Gemma 4 is run in the decoders suite's accuracy and determinism checks. - Qwen3-MoE's 30B joins decoders (nightly, its toy test already runs per PR) and long_context, staged=False as its checkpoint isn't on every runner. Its p90 bound is 0.1 (bf16 transformers itself reaches 0.065 on its steps, near-tie experts); the figure is carried from before #222's numeric fixes and not yet re-measured here, so it's not asserted as current. test_determinism skips it: test_host_steps already holds a host step's calls exact, and a full redo is 15 minutes at this scale. - long_context's loaded fixture checked a form by device_loop, which a full ELF with a host step (Qwen3-MoE's paged experts) doesn't have; it now checks the decode step's packaging instead, what the form actually is. - Qwen3 0.6B/1.7B, Qwen3-Embedding and Qwen3-Reranker join long_context. Qwen3-Embedding's row is its final hidden state, held by its cosine to the reference, not KL (check_deep_decode/check_deep_prompt gain cosine=); Application gains deep_cosine and staged. Measured on npu2 (Strix Halo), native context (32768), teacher-forced: Qwen3 0.6B decode KL 0.0020, prompt chunk 0.0021 (39.9s); Qwen3 1.7B (full ELF and each-step alike) decode KL 0.0385, prompt chunk 0.0565 (40.2-40.9s); Qwen3-Embedding decode cosine 0.98611, prompt chunk cosine 0.99859 (31.8s), against its 0.97 bound (twice the decode's distance from 1); Qwen3-Reranker decode KL 0.0212, prompt chunk KL 0.0038 (39.9s), well under DEEP_KL. All ten cases pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Granite and Qwen3's family went first after the eighteen applications moved out of #222 to their own pull requests. This ports Qwen 2.5's model, profiles, README and device-free tests back in, unchanged, against today's iron.lm, and registers it in long_context. Real hardware already validated its accuracy (mean KL 0.0058) once the MHA running-max bug behind its earlier NaN-past-891-tokens failure was fixed upstream; its device test (shortest call, sampling, accuracy, determinism) is unchanged from that run and ready for the same gate as every other model in the stack. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Ports Phi-4-mini's model, profiles, README and device-free tests back in, against today's iron.lm: fused qkv/gate-up projections, partial rotary and LongRoPE are unchanged, since Rope.rows()/ table_start(), Linear.split() and CausalLM.rotary() all still take the shapes this port already built on. Linear is now precision= keyword-only with no default, so Phi4Attention's qkv_proj and Phi4MLP's gate_up_proj now pass config.precision explicitly, same as every other projection already did; Phi4Config states it as Precision.HIGH, as Llama does from 3B's width up. Registers it in long_context. Real hardware already passed its device sampling check and its 10-step accuracy (KL 0.00039-0.0224, every top-1 matching); its device test is unchanged from that run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Ports LFM2's model, profiles, README and device-free tests back in, against today's iron.lm: ten of its sixteen layers skip DecoderLayer's attention entirely for a gated short causal conv (ShortConv), built directly (not through super().__init__()) since DecoderLayer itself is unchanged between the two trees. CausalConv1d's own Checkpoints state already carries a conv layer's window across calls, the same mechanism granite_hybrid's Mamba mixer now uses, so the layer-dispatch design needed no change either. Linear is now precision= keyword-only with no default, so ShortConv's in_proj and out_proj now pass config.precision explicitly; Lfm2Config states it as Precision.MEDIUM, LFM2's own hidden_size being under 3B's threshold. Registers it in long_context. Real hardware already passed its device-loop generation and a full 1024-32640 context sweep (KL mean 0.0057, p90 0.0068, max 0.0071); its device test is unchanged from that run. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* Scaffold a programming guide for iron's operator and graph API iron/operators and iron.Graph have no user guide: PR amd#222 moved IRON onto declared operators and recorded graphs, but the only worked examples live in tests and AGENTS.md's prose. Start a programming_guide/, mirroring mlir-aie's own (numbered sections, each a README walking a small runnable example), and link it from the top-level README. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add guide sections 1-3: an operator alone, a first graph, per-call bounds Section 1 calls AXPY on its own, no graph: outside a graph, a call takes one device tensor per declared buffer, in order, including the output. Section 2 composes ReLU and AXPY into one iron.Graph, walking body(), handles, .step(), compile() and calling it. Section 3 adds a per-call bound (x[:n]) so one compile serves any extent, the pattern amd#222's description used for its own example, and notes that a device call's own output is always the compiled shape, not n's - graph.reference(...) is what trims to n. Every comparison goes through aie.utils.verify.compare and an operator's own tolerance() - the operator actually built, read off the compiled graph's recording, never a number picked by hand. iron/tests/docs/test_programming_guide.py checks each example the same way, device-free through graph.reference(), and end to end through a device-marked test. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add guide sections 4-5: weights and state, carried values and device loops Section 4 introduces iron.param (a held weight) and iron.state (device-resident state read and written across calls), on top of Section 3's per-call bounds. Section 5 adds Carried[T] per-call values and iron.carry(...), both from the host one call at a time and looped entirely on the device with iron.CarriedLoop, the mechanism iron/tests/infrastructure/test_carried_loop.py exercises at scale. Each check uses the one operator in the chain that actually rounds (Copy and ReLU are exact; ElementwiseMul and ElementwiseAdd are not), its tolerance read off the compiled graph's own recording. The device loop's own walk is recorded in a public state, `trail`, the same `iron.state` Section 4 introduced, indexed by the carried step count the way `Accumulate` indexed by a scratchpad one; it is read back and checked exactly against the numpy walk. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add guide sections 6-7: the host reference and check mode, profiles Section 6 chains two operators that each round (SiLU then ElementwiseMul), where no single step's tolerance covers the whole output: graph.reference() is checked exactly against the same two operators' own reference() chained by hand (no device involved either way), and compile(check=True) is what verifies the device run, each step against its own operator's reference() and tolerance(), rather than one number invented for the whole chain. Section 7 shows a Profile setting an operator's tunables by shape, and the precedence between a call's own keyword, the profile, and Operator.resolve(dev) - the mechanism iron/applications/llama/profiles/ relies on at model scale. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add guide section 8: from graphs to a language model A toy, one-layer Llama with random weights (a sparse .safetensors file and Checkpoint.tree("random", seed), the same mechanism tests/applications/llama/reference/test.py and iron/tests/support/llama_model.py build toy-sized decoders with) runs the actual Llama class: recording CausalLM.body, compiling its two versions (the decode step and the prompt chunk, feeds= chaining the second's Emit to the first on NPU2), and running a prompt plus a few decode steps on the device. It is checked two ways, both already this guide's own: the drawn tokens against graph.reference()'s (greedy sampling is deterministic, so a correct run draws the same ones, no tolerance needed), and compile(check=True) over the whole decoder, each step checked against its own operator's tolerance - the same mechanism Section 6 introduced, at model scale, including why a per-call-bounded step (most of a prompt chunk's) logs as skipped rather than checked. The prose reads CausalLM.body and the real Llama class in the guide's own vocabulary (body, handles, per-call bounds, carried values, state), tied line for line to what the example just ran. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add a MkDocs-based project website Models on mlir-aie's site: Material theme, a short landing page with quick-nav cards, and the installation guide, Models and Contributing pages reusing README.md, CONTRIBUTING.md and AGENTS.md in place via symlinks rather than forked copies. The Programming Guide section wires in programming_guide/ the same way mlir-aie's docs do: a symlink created at build time, since that tree lives on a separate branch right now. A build-time hook drops the nav section (and the landing page's card for it) when the symlink isn't there, so `mkdocs build --strict` keeps passing either way. A second hook ports mlir-aie's relative-link rewriting so links that escape the doc tree into repo source resolve on the deployed site instead of 404ing, and so links back to a repo-root file land on that file's own doc page instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Deploy the MkDocs site alongside the benchmark charts One Pages deployment from devel now holds both: publish-pages.yml builds the MkDocs site first, then writes ci/scripts/build_pages.py's self-contained chart page into site/benchmarks/charts/, next to the MkDocs-rendered Benchmarks page that links to it. Permissions, environment and concurrency are unchanged; only the build steps grew and the push trigger now also fires on devel itself, so doc-only changes publish without waiting on a benchmark workflow to complete. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Link the website from the README, and point Discord at ROCm's server Also swap the README's Discord invite (discord.gg/cW99Ds85e8) for the ROCm Discord's #ROCm-NPU channel, matching mlir-aie's README and the new site's social links; flagged for Erika to confirm, since IRON's own invite may still be the one meant for IRON users specifically. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Fix installation logo links and guide subtraction exercise Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> * Clarify graph compile lifecycle and complete GELU exercise Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> * Clarify Section 3 parameter terminology and remove agent-doc link Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
* Restore Granite 4.2 3B from 46a5d87, as its own follow-on to amd#222 a0162c7 moved eighteen applications out of amd#222 to their own pull requests, each with its checkpoints, goldens and the library code only it exercises. Granite goes first: this ports 46a5d87's model, profiles, README and device-free tests back in, unchanged, against today's iron.lm. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Bring Granite back into the README's model list and the shared checks Granite's GraniteConfig covers test_config.py's key-mapping check alongside LlamaConfig's, and long_context's APPLICATIONS holds it to the same one-compile, any-context guarantee as Llama and Gemma 4; its deep_kl figures are 46a5d87's own, measured at 4095 positions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Free Granite's device buffers when its tests finish 8c25885 gave every model test fixture a model.release() after the module's (and TestEachStep's) tests, so the next model's CREATE_BO doesn't meet a full heap behind a reference cycle still awaiting GC. Granite's fixtures, restored from before that commit, didn't have it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Trim Granite's docstrings to say what each piece is 754e3ae cut iron/lm's and the three amd#222 applications' docstrings to what a caller relies on, the rationale left for the commits that made it. Granite's, restored from before that commit, kept the longer form; this brings its module and Granite class docstrings to the same register. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Add Granite 4.2 3B's row to the driver-timeout table 74f7004's table (cut from b1e224c6 to amd#222's models) left out Granite's row when it moved out in a0162c7. Restored at its measured figure (86.5 s on this host today, against b1e224c6's 86.5 s): its deepest prompt chunk, at its native 131072 context, as one command. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Hold Granite to long_context's per-step form too, like Llama and Gemma 4 bd6c053, d23627e and fdaaab1 widened long_context's five context sizes to the per-step form (an xclbin a step, the host starting each on the token the last one drew) on npu1 and npu2; Granite's entry, restored from before that work, was still full-ELF only. Granite has an npu1 profile (empty, every operator's device defaults), so it joins at each_step=("npu1", "npu2") like Llama's and Gemma 4's. Both forms measured on this host's npu2, 4096 to the whole 131072 context: decode deep in the cache KL 0.0010 to 0.0022, its deepest prompt chunk 1.7e-8 to 1.4e-4, top-1 agreeing throughout. npu1 is still unmeasured on this host. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Restore Granite 4.0-H 1B from 46a5d87, as its own follow-on to amd#222 Granite 4.0-H 1B joins Granite 4.2 3B as a follow-on to amd#222 (a0162c7, 0f0a540): the dense 1B this ports, its README, profile and device-free tests, unchanged, against today's iron.lm. Its library dependencies (selective_scan, CausalConv1d, Checkpoints) and the two later fixes follow in their own commits. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Refresh Granite 4.0-H 1B's figures for prompts that begin without BOS Granite's tokenizer adds no BOS, so since prompts begin as its post-processor begins them, the accuracy checks see 292 and 3261 tokens where they saw 293 and 3262, and the golden rows, KL figures, README and bounds were for the old prompts. The golden is re-recorded device-free (transformers in float32) and the figures re-measured on xcoradaie220. Measured on Strix Halo (npu2), one compile at the native 131072 positions, projections at HIGH as before: - KL over 40 steps after 292 tokens: mean 0.0024, p90 0.0048, max 0.0063 (2 top-1 swaps); two chunks and two decode steps: mean 0.0027, max 0.0049. The chat turn is bit for bit the run from scratch; determinism 0 differing runs. - TTFT 2.9 s after 13 characters, 3.6 s after 292 tokens, 8.0 s after 2048; 6.7 tokens/s. MAX_KL was about twice the old figures; it is again about twice the new ones (mean 0.006, p90 0.012, max 0.015). The README's Precision table is left to the precision pass, which has these numbers. Net: tests +4/-3, docs +9/-8. Checked: pytest tests/applications/granite_hybrid/test.py on the NPU (8 passed, at the old bounds; the new bounds hold the same deterministic figures). collect-only, black, reuse. Co-Authored-By: Claude <noreply@anthropic.com> * Hold Granite 4.0-H 1B to its native context in long_context granite_hybrid was listed as unheld because Experts streams every expert's weights for each row. That is true of the MoE sizes, but the dense 1B the package ships runs no Experts. The 1B now joins APPLICATIONS, and long_context holds it to its native 131072 positions like the other decoders: nothing grows with the context but a row per position, and the deepest decode step and prompt chunk match the graph's reference. The MoE sizes have no checkpoint or test here. Measured on Strix Halo (npu2), full ELF at 131072 positions: - decode at 131071: KL 0.0035 against the graph's reference, same top-1. - the deepest prompt chunk: KL 4.1e-5, 14.8 s. - TTFT 32.8 s at 8192 tokens, 732 s at the whole 131072. Net: tests +7/-2. Checked: pytest tests/applications/long_context/test.py -k granite_4.0_h_1b: test_nothing_grows_with_the_context, decode and prompt, passes device-free; the 4 extensive device tests pass. test_every_decoder_application_is_held_to_its_context fails before and after this change, because qwen3_embedding is a CausalLM missing from both lists. collect-only, black, reuse. Co-Authored-By: Claude <noreply@anthropic.com> * Restore Granite 4.0-H 1B's shared library pieces 0f0a540 left SelectiveScan, its shared state_slices, iron.lm.Checkpoints and (a0162c7) CausalConv1d with the applications that exercised them, to come back with whichever follow-on pull request needed them again. Granite 4.0-H 1B's Mamba2 mixer needs all four: the scan over its state, the short causal convolution ahead of it (F.causal_conv1d, ConvState), and the per-chunk checkpointed state both carry between calls. iron.lm.testing's _fill_caches, used by long_context's deep checks, regains the Checkpoints branch it had before 0f0a540 trimmed it to KVCache alone, so a deep check sees the chunk-boundary state a prompt left, not an empty one. selective_scan.py drops one case, "granite_small_prefill": the Case it marked (lower=True, run=False) relied on a run field Case removed, and the case was for a different checkpoint (Granite 4.0-H Small) out of scope here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Ship Granite 4.0-H 1B dense only, refusing a checkpoint with experts The package 46a5d87 shipped built GraniteMoE for any config with num_local_experts: Router, then Experts over the checkpoint's stacked expert weights. a0162c7 and 0f0a540 moved Experts and TopKRouter out with Qwen3-MoE, untested at any shape that runs at a usable rate (an unrelated follow-up); restoring them here only to exercise an MoE size this package stages no checkpoint or test for would be restoring code nothing checks. The shipped 1B is dense: GraniteHybridLayer no longer builds a GraniteMoE, and GraniteHybridConfig refuses a checkpoint with experts outright, rather than silently ignoring num_local_experts. The device-free reference test held an MoE toy alongside the dense one (goldens/toy.npz), checking the graph's reference against Hugging Face's GraniteMoeHybrid at a toy MoE shape. It depends on the same GraniteMoE this drops, so it goes with it, replaced by a test that the config refuses experts; the dense toy's own class and golden are what the shipped 1B is checked against. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Free Granite 4.0-H 1B's device buffers when its tests finish 8c25885 gave every model test fixture a model.release() after the module's tests, so the next model's CREATE_BO doesn't meet a full heap behind a reference cycle still awaiting GC. Granite 4.0-H 1B's fixture, restored from before that commit, didn't have it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Bring Granite 4.0-H 1B into the README's model list Its row names the real checkpoint (granite-4.0-h-1b) now staged, in place of the "reference only"/"none yet" row from before it existed. Its own README drops the mixture-of-experts section, which measured Experts at an MoE size this package no longer builds (27870ec0), and its intro and reference/ mentions follow the dense-only package. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Count every token a device loop drew in generate's rate generate reads a device loop's draws once the last is drawn: the loop always draws max_tokens, and generate stops at the first eos among them. Its rate counted only the tokens through eos, over the time the loop took to draw all of them. Granite 4.0-H 1B draws eos 8th after the benched 13-character prompt, so its TPS read 1.21 where the device draws 6.7 tokens a second. The nightly trend check would have compared that figure. A Model now says whether generate's draws come at once (draws_at_once: a CausalLM's device loop, a Multimodal's text model's; False otherwise, OnHost too). Where they do, generate counts every token drawn in the time it measures, and keeps returning only those through eos. stream, which reads each token as it is drawn, and draws stepped from the host still stop at eos, so no step runs that otherwise wouldn't. Net: library +31/-5, tests +21. Checked: a new device test, test_granite_4_0_h_1b_rate_counts_the_draws_past_eos, compares generate's rate with stream's over the same early-eos draw: 6.68 vs 6.67 tokens/s (generate read 1.21 before the change, measured with a per-token probe and in the module run). The benched 13-character case reads 6.69 TPS. tests/applications/granite_hybrid/test.py: all 8 other tests pass. Device-free pytest -m "not supported_devices and not extensive" iron/tests/common/test_llama_reference.py iron/tests/common/test_multimodal.py iron/tests/lm iron/tests/infrastructure/test_lm_host.py: 155 passed. collect-only, black, reuse. Co-Authored-By: Claude <noreply@anthropic.com> * Record Granite 4.0-H 1B's long_context figures and timeout-table row Measured on npu2 (xcoradaie220), full ELF, five context sizes 4096 to the whole 131072: decode deep in the cache KL 0.0007 to 0.0069, its deepest prompt chunk 4.1e-5 to 0.0052, top-1 agreeing throughout; npu1 still unmeasured. The deepest prompt chunk at the native context, one command: 14.8 s, matching cbf21694's recorded figure, added to the driver-timeout table between Llama 3.2 1B and EmbeddingGemma 2. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Hold Granite 4.0-H 1B to npu1 too, like Granite 4.2 3B Erika's decision: the dense 1B must run on npu1 (Phoenix), not npu2 alone. 7c34b69 brought Granite 4.2 3B to npu1 the same way: an empty profile (every operator's device defaults), a TestEachStep class (npu1, npu2) holding the per-step generation cases plus a shallower accuracy and determinism check, and long_context's each_step=("npu1", "npu2") so its five-size sweep covers the per-step form too. CI's Phoenix runner covers the real npu1 run; this host is npu2 only. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Fix Granite hybrid recurrent invalidation, scan blocks, CLI, and EOS test Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> * Reject causal convolution chunks shorter than their history Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> * Stop generation before decode when the first token is EOS Co-authored-by: hunhoffe <54562339+hunhoffe@users.noreply.github.com> * Tighten the programming guide and say what runs where Rewrite the guide's prose as a plain tutorial and check each claim against the code. Weights upload on the first call or load(), not on compile; buffers is op.buffers; load reads tree("read"); the device loop already runs in Session; and several cross-references now point at the section that covers them. docs/models.md lists what each model runs on the host (tokenizing, image decode, audio padding, the sampler's random rows, NPU1's per-step dispatch) beside what runs on the NPU, and docs/benchmarks.md says model figures come from CI and where the history lives. The section 4 subtraction exercise is now tested on a real subclass through record() and reference() instead of patching Graph. Co-Authored-By: Claude <noreply@anthropic.com> * Test golden, declare and layer on real objects test_golden records a one-layer toy Llama run on the host instead of a lambda standing in for a model; test_declare sets active_runtime to a real OperatorRuntime for another operator; test_layer records a graph whose body calls the norm on a real handle. Co-Authored-By: Claude <noreply@anthropic.com> * Refuse SelectiveScan shapes its cores cannot hold A state_size that is not whole SLICE vectors made the B/C gather read past the state, and an explicit block skipped the core-memory check the resolver applies, so an oversized block silently overflowed L1. validate() now rejects the first, and compatible() runs the resolver's own capacity check (state_slices.fits) on every block. Co-Authored-By: Claude <noreply@anthropic.com> * Keep Granite's READMEs to what the tests hold Timings move to CI's published figures, so the Granite 4.0-H README drops its TTFT/TPS table, the timing paragraph and the host it ran on, and keeps the HIGH-vs-MEDIUM comparison qualitative rather than repeat KL figures that disagreed with each other and with test.py. HIGH is GraniteConfig's default, not the checkpoint's; the README now also says what the tests check and that NPU1 is enabled but not yet run. Granite 4.2's README and both models' comments no longer point at applications and documents that are not in the repo. Co-Authored-By: Claude <noreply@anthropic.com> * Show each model's NPU1 and NPU2 support, and correct the model docs The README's and the site's model tables gain NPU1 and NPU2 columns, filled from what each model's tests run. Beside them: - requirements.txt pins a nightly mlir-aie, not the last release, and llvm-aie is pinned beside it (AGENTS.md pointed at a file that does not exist); the long-context test is test_nothing_grows_with_the_context. - Model tests record TTFT and TPS for CI rather than check them; the nightly trend gate does. - Llama 3B's HIGH precision comes from LlamaConfig.from_json on both NPUs, not its profile; its cost figure moves to CI. - Gemma 4: its precisions are the configs' defaults, clips past 30 s are cut, its shared tests live in decoders/, and the towers are NPU2-only. - EmbeddingGemma 2: NPU1 refuses the widest images and its passage audio case lands under the NPU2-set bound. - The FastFlowLM engine's README says what FastFlowLM itself still runs. - overrides.hpp holds dispatch hooks, not kernels. Co-Authored-By: Claude <noreply@anthropic.com> * Test generation's EOS exits on a real device loop test_generation ran generate against stand-in loops with a patched clock. It now loads a small Llama on drawn weights, with its eos named by generation_config.json, and checks what the device loop returns: generate counts every token the loop drew past eos, stream stops at it, and a first-token eos leaves the device's drawn rows untouched. Stats records the drawn count so the tests assert on it rather than on wall-clock rates. Granite 4.0-H's rate test is benched so the nightly publishes its TPS. Co-Authored-By: Claude <noreply@anthropic.com> * Publish what a CI run got through when its process dies Both nightlies so far died partway (an abort on Krackan, an OOM kill on Phoenix) and published nothing: the suite was one pytest process, and the results CSV was written only at session end, so the format step found no file and the upload, trend check and publish had nothing to work on. conftest.py now rewrites the CSV as each test starts, counting the running test a failed check until it ends, so a process that dies keeps every result before it and names the test it died in. The applications suite runs each tests/applications/<name>/ in its own process and merges their CSVs, so a crash ends only that model's tests and frees its memory before the next model loads. Cost: one write is 14 ms at 1400 rows and the file grows from empty, so the small suite pays about 10 s over its run. test_ci_results aborts a real session mid-run; under the previous conftest that session left no CSV. Co-Authored-By: Claude <noreply@anthropic.com> * Leave a tunable given as None to the profile Profile.make merged the call's keywords over the profile's tunables, so a tunable passed explicitly as None (mlir-aie's 'not given') overwrote the profile's value with None, and resolve() then chose its own. Both Profile.make and the graph recorder, which constructs every step through it, now drop None keywords first, as Operator construction does. Co-Authored-By: Claude <noreply@anthropic.com> * Run every declared case on NPU1, its columns the device's GEMV, GEMM, DepthwiseConv1d, Limbs and Magnitude declared cases at 8 columns, which NPU1 (4 columns) refuses, so 15 of its 165 default cases skipped there: every decode-sized GEMV among them, and GEMV, DepthwiseConv1d, Limbs and Magnitude had no bench case on Phoenix for the trends to track. A case of 8 columns now takes all of a narrower device. On NPU2 every case and label is unchanged, so the benchmark history keeps its rows. test_npu1_runs_every_case_of_an_operator_it_runs holds the rule: an operator NPU1 runs at all resolves every case there. All 15 cases compile for npu1 on xcoradaie211; none has run on a Phoenix device yet. Co-Authored-By: Claude <noreply@anthropic.com> * Refuse --check-determinism under two rounds before loading Zero rounds is falsy, so the command line sampled instead of checking; one round compared nothing and printed a zero denominator. Both now stop at the parser, before the checkpoint loads. Co-Authored-By: Claude <noreply@anthropic.com> * Fail the FastFlowLM server fixture when the server never answers It polled for 120 s and then yielded either way, so a server that died or never came up surfaced later as a refused request. It now raises when the server exits early or stays silent, and stops a group that outlived it. Co-Authored-By: Claude <noreply@anthropic.com> * Drop stale comments, a dead guard and an unread variable run_test's comment named IRON_RUNTIME, which mlir-aie reads as NPU_RUNTIME, and its docstring a call_reference that is _call_reference's reference; Profile.load's Enum comment was garbled; kernel_cycles guarded on ExternalFunction.recipe_key, which every pinned mlir-aie has; and the heap-exhaustion test set IRON_XFAIL_DEVICE_HEAP, read by nothing since 169ae38. Co-Authored-By: Claude <noreply@anthropic.com> * Fail the pre-push hook on Python black would reformat The black check's verdict was grep's, which matched black's own 'Oh no!' line once the two filters had removed the rest, so the hook passed a file black refused. It now reads black's exit status. Co-Authored-By: Claude <noreply@anthropic.com> * Write a config's nested dataclass back with dataclasses.asdict Config.to_json asked each field's value whether it had a to_json, for Llama3RopeScaling's, which existed only to put back the rope_type its from_dict dropped. rope_type is now a field (always llama3, which from_dict still checks), so dataclasses.asdict is the exact inverse; a nested Config still writes its own to_json. Co-Authored-By: Claude <noreply@anthropic.com> * Say when a Golden records, and bind a device for its tests Golden read IRON_RECORD_GOLDENS at construction, so its tests set and cleared the variable with monkeypatch. It now takes record=, None reading the variable as before (pytest --record-goldens is unchanged), and the tests say which they mean. Two of them ran a model's graph reference with no device bound, so they failed on a host without an NPU, which AGENTS.md lists iron/tests/common as needing none; they take the npu2 fixture. The checkpoint test that needs recording off skips under --record-goldens instead. Co-Authored-By: Claude <noreply@anthropic.com> * Read declared types and instance fields rather than probing attributes Each hasattr and getattr-with-a-default now states what reaches it: Operand re-raises its own property by looking in vars(Operand); Handle's reflected operators are vars(Handle)'s; a broadcast operand's or a described argument's shape is read where is_operand says it has one; a frozen parent is a dataclass's own parameter; an extent's word is an ExtentWord's; a checkpoint tree's path and file are its _Module's or _Layers'; a model's repr reads a DecoderConfig's context; the model to tune is the export whose class defines tune_calls; and a kv kernel's first entry is read from its own fields. The tests' probes follow. Co-Authored-By: Claude <noreply@anthropic.com> * Hoist the imports with no cycle, and say why each other is local Imports inside functions are now at the top of their module unless one of two reasons holds, which a comment beside it names: a cycle (the graph and iron.operators, golden and checkpoint, causal and lm.tune, testing and declare), or an optional dependency (the models extra's jinja2 and tokenizers, the examples' soundfile, and torch and transformers where only recording a golden needs them). record.py's visualize import, golden's tempfile, uuid4, pkgutil and the tests' support imports had neither. tools.shipped, a one-line wrapper kept lazy only by that import, is gone: its callers make Shipped themselves. Co-Authored-By: Claude <noreply@anthropic.com> * Build EncoderLayer through DecoderLayer's constructor EncoderLayer set each of DecoderLayer's fields again by hand. With its norm a LayerNorm (DecoderLayer.norm) and its MLP and NoCache passed in, DecoderLayer's constructor makes the same layer, in the same order. Co-Authored-By: Claude <noreply@anthropic.com> * Write every result to --csv-output under xdist Each xdist worker and the controller made its own CSVReporter over the same path, each renaming its rows over the file, and the controller, which ran no test and so held none, wrote last: pytest -n auto with --csv-output left an empty file. The reporter is now a plugin the controller (or a serial session) registers, recording from the reports every worker sends it (pytest_runtest_logreport carries the record_property figures and the bench mark); the tests running at once are a set, each counted a failed check until it ends, as before. Co-Authored-By: Claude <noreply@anthropic.com> * Inline SelectiveScan's one-line helpers Its two fifo-type lambdas served one fifo each, its slices lambda made the same pattern twice per core, now a list made once, and _slices(op) is the core_slices property. Its default cases pass on npu2 as before. Co-Authored-By: Claude <noreply@anthropic.com> * Keep CI's pyright clean over the attribute-probe changes The previous commits' isinstance checks lost pyright's narrowing in two places and named a field its stubs lack in a third: the extent word's divisor is read under its own isinstance, a nested dataclass instance (not its class) goes to asdict, and a frozen parent's dataclass parameters are read through cast(Any, ...). Co-Authored-By: Claude <noreply@anthropic.com> * Bench a prompt chunk's gather by ids each call Gather and GatherWords declare no Testing (a gather's control words name device addresses), so no gather had a row in the benchmark history. A prompt chunk's 2048 ids from EmbeddingGemma 2's table are now checked against numpy each call and timed end to end, the host's encoding of the ids included: 434 us on xcoradaie211 (npu2), 4.8 GB/s of rows. Co-Authored-By: Claude <noreply@anthropic.com> * Remove the graph's Graphviz drawing Recording.dot() had no caller outside its own test, so this drops iron/common/graph/visualize.py, Recording.dot(), the test, and the graphviz apt package the CI image installed only for its dot binary. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Document env vars by canonical home; fix SelectiveScan's ops() count NPU_RUNTIME gets its explanation in the programming guide's "Getting Set Up" alongside NPU_CACHE_HOME, with AGENTS.md trimmed to a pointer; DOCS_GITHUB_REF stays an inline comment at its one call site, matching the other CI-only vars. SelectiveScan inherited Operator.ops()'s one-op-per-output-element count, understating its bench throughput about 160x: the state update and C readout do five ops per (row, head, head_dim, state_size) element the output doesn't carry. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * Gate docs links in CI; note the models table's two copies mkdocs build --strict only ran on push to devel, so a broken doc link or anchor surfaced after merge; ci-lint.yml now runs it as a PR check. docs/models.md hand-duplicates README's models table with GitHub- absolute links in place of relative ones, since it isn't a symlink of README the way installation.md is. Each now points at the other so a new model updates both. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>


This PR moves IRON from per-operator scripts and hand-assembled runtime sequences to declared operators composed into traced graphs, with a language-model layer (
iron.lm) on top. Three applications exercise all of it: Llama 3.2 (1B and 3B), Gemma 4 E2B with its vision and audio towers, and EmbeddingGemma 2.It builds directly on what
develvalidated: the operator arrays and tilings, the kernels (now upstream in mlir-aie'saie_kernels/),llama_npu.py's fused-ELF decode, the FastFlowLM ports and the stream-dse SwiGLU. This PR ports those proven designs into one declared form and adds the graph, tuning and model layers on top.Suggested reading order:
AGENTS.md, theniron/operators/relu.pyβgemv.py,iron/tests/support/graphs.py,iron/lm/causal.py, andiron/applications/llama/model.py(a whole model in about 100 lines).The layers
aie.iron.kernelsiron/operators/param(),tunable()andper_call()fields, operands by shape, andbuild(). The library derives the runtime sequence.iron/common/graph/,iron/common/image/body()recorded once per input shape, compiled to one image (a full ELF on npu2, an xclbin per step on npu1), and called per token with per-call values patched in.iron/lm/,iron/applications/What to check as you review:
profiles/<device>.json;python -m iron.lm.tune <application>rewrites it.golden.npzlives beside its weights.Applications
iron/applications/llama/): the worked example, with npu1 and npu2 profiles.iron/applications/gemma4/): the text decoder and its vision and audio towers as oneMultimodal.iron/applications/embedding_gemma2/): anEncoderover text, with Gemma 4's audio and vision towers.Each is checked against transformers' float32 logits (KL and top-1), recorded in
golden.npz.tests/applications/long_context/holds every decoder to compiling once for any context.The other eighteen applications that were developed on this branch (Qwen3 and its MoE, embedding and reranker variants, Qwen 2.5, Qwen3.5, SmolLM2/3, Phi-4-mini, Granite, Gemma 3, LFM2, Ministral 3, SmolVLM, Whisper, ResNet-50 and YOLOX-Nano) follow in their own PRs. Each brings its checkpoints, goldens and the library code only it exercises.
Gemma 4 on FastFlowLM: what changes
The example still runs FastFlowLM's Gemma 4 E2B engine with all six of its xclbins replaced by IRON builds, through
overrides.hpp. What changes around it:iron/applications/gemma4_flm/toiron/operators/flm/gemma4_engine/, since it is flm tooling rather than aniron.lmmodel. The test stays intests/applications/gemma4_flm/.flm.GEMMis renamedProjectionGEMM, whichiron.lmalso uses for prompt chunks.MMPrebuiltbecomesShipped, a test reference only.ct_kis now a tunable.devel, IRON's greedy tokens had to equal the stock engine's exactly. Now the tokens must match up to the first difference. At that point, IRON's token must be at least as likely as the stock engine's under float32 Gemma 4.word_problem. IRON's token has p 0.841, the stock engine's p 0.157.devel's Reset Gemma 4 override state on engine reloadΒ #248 is merged in: the override state resets when the engine reloads.CI
small.ymlexamples.ymlextensive.ymlnightly.ymlHardware jobs run on Phoenix (npu1) and Krackan (npu2). A test whose checkpoint is not staged on a runner fails rather than skips, so each runner needs
llama3.2-1b,llama3.2-3b,gemma-4-e2b-itandembeddinggemma-2under/srv(IRON_EXAMPLE_WEIGHTS_DIR), each model's README says which files.On
mainanddevel,publish-results.ymlmerges each suite's results onto thecibranch. When two suites publish at once, the later one merges again onto the new tip and retries, and fails if it cannot publish.Known limits
tdr_timeout_ms=150000, as the README's installation section sets.Measured figures (speedups, accuracy fixes) are in the commit messages that made them.