Skip to content

Samsung Exynos AI LiteCore- Add quantpass testsuite - #22725

Merged
psiddh merged 7 commits into
mainfrom
add-quantpass-testsuite
Sep 14, 2026
Merged

psiddh merged 7 commits into
mainfrom
add-quantpass-testsuite

Conversation

@Jiseong-oh

@Jiseong-oh Jiseong-oh commented Sep 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Introduces EnnPassManager to centralize the Samsung backend's export-time passes and adds op builder support for flip, pad, prelu, and silu, plus einsum/glu decomposition needed by the newly added test-suite models. Also fixes MobileBERT QAT quantization-annotation regressions where shared quant params were dropped across matmul/bmm reshape chains, and removes

Test plan

pytest backends/samsung/test/models/test_mobilebert_qat.py -v
pytest backends/samsung/test/models/test_mobilebert_finetuning.py -v
pytest backends/samsung/test/ops -m backend_samsung -v

cc @SS-JIA @digantdesai @kimishpatel

@pytorch-bot

pytorch-bot Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22725

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 5cc1251 with merge base 9918b00 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 11, 2026
@Jiseong-oh Jiseong-oh added partner: samsung For backend delegation, kernels, demo, etc. from the 3rd-party partner, Samsung module: samsung labels Sep 11, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found several correctness issues in the new graph rewrites and op mappings. Detailed findings are attached inline.

AI reviewer note: This review was generated by Codex, an AI reviewer.

len(node.args) == 3
), f"Expecting {node.name} to have 3 arguments."
val = node.args[2]
if node.args[2] > torch.finfo(torch.float16).max:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aten.masked_fill.Tensor has an FX Node as its third argument, so this comparison raises TypeError for every use of that overload. I reproduced it by invoking this pass on a graph containing masked_fill.Tensor: '>' not supported between instances of 'Node' and 'float'. Please restrict these scalar comparisons to the Scalar overload, or resolve a constant tensor value safely before comparing it.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

for shift, dim in zip(self.shifts, self.dims):
x = torch.cat(
(
x[(slice(None),) * dim + (slice(-shift, None),)],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative dimensions are valid for torch.roll, but multiplying a tuple by a negative dim produces an empty tuple, so this slice targets axis 0 while cat(..., dim=dim) still uses the negative axis. With a 2x3 input, torch.roll(x, 1, -1) should return [[2,0,1],[5,3,4]]; the transformed graph returns a different shape/value. Normalize each dimension (for example, dim %= x.dim()) before constructing the index.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

x = torch.flatten(x)
self.dim = 0

x = torch.pow(x, self.exp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch.linalg.vector_norm raises the absolute values to ord; this replacement raises the signed inputs directly. For ord=1, [[-1,2],[-3,-4]] should produce [3,7], but the transformed graph produces [1,-7]. Please apply abs() before pow and either implement or explicitly reject the special ord cases (0, +/-inf, etc.) matched by this generic pass.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Comment thread backends/samsung/builders/op_cat.py Outdated
@register_node_visitor
class CatVisitor(NodeVisitor):
target = "aten.cat.default"
target = ["aten.cat.default", "aten.stack.default"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aten.stack cannot use the concat visitor unchanged: stack inserts a new dimension, while this visitor sends the original-rank tensors directly to CONCAT. For two (2,3) inputs, stack(..., dim=0) is (2,2,3), whereas concat is (4,3). Since the partitioner now preserves stack, please use a separate visitor that inserts/represents the new axis, or allow stack to decompose.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@register_node_visitor
class ReshapeVisitor(NodeVisitor):
target = "aten.view_copy.default"
target = ["aten.view_copy.default", "aten.copy.default"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aten.copy.default(self, src) is not a reshape: its result contains src converted/broadcast into the shape of self. ReshapeVisitor reads only node.args[0], so this mapping discards the source value entirely and serializes the destination data instead. Please implement copy semantics separately or do not advertise this op as supported.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Comment thread backends/samsung/builders/op_pad.py Outdated
]

mode = "constant"
constant_value = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The aten.pad schema's fourth argument is the constant fill value, but this visitor never reads it. Thus float pad(..., mode="constant", value=5) is serialized with constant_value=0; for quantized tensors, the zero point likewise represents real zero rather than the requested value. Please encode node.args[3] (including quantization) or reject nonzero constant padding.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

# Get the finetune model
mobilebert_finetune = MobileBertFinetune(metric, args)
model, tokenized_datasets = mobilebert_finetune.get_finetune_mobilebert(
self.artifact

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.artifact is never defined on this test case. The path created just above is args.artifact, so the test raises AttributeError here before it reaches fine-tuning or QAT. Please pass args.artifact (or initialize the instance attribute in setUp).

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread backends/samsung/_passes/__init__.py Outdated
__all__ = [
AnnotateQparamsPass,
AnnotateScalarParametersPass,
RecomposeRmsNorm,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entries in __all__ must be strings, not the imported class objects. I reproduced from ..._passes import * failing with TypeError: Item in ...__all__ must be str, not ABCMeta. Please quote these exported names or omit __all__.

AI reviewer note: This comment was generated by Codex, an AI reviewer.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@psiddh psiddh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review of the ENN pass-manager refactor + MobileBERT QAT work.

The EnnPassManager consolidation is a clear improvement over the inline pass list, and the .cpu() / partition_tags / conv1d buffer fixes all look right. Seven correctness issues below, though:

  • test_mobilebert_qat.py uses self.artifact, which does not exist — CI runs this file via unittest discover, so test-samsung-models-linux fails deterministically.
  • decompose_roll and decompose_linalg_vector_norm both regressed against the Qualcomm passes they were ported from (torch.tensor(shape) instead of torch.empty(shape); missing abs() and ±inf handling). Diffing against backends/qualcomm/_passes/ should make both quick fixes.
  • aten.copy.default → RESHAPE reads the destination argument, dropping the source data.
  • aten.pad.default's value argument is ignored.
  • _add_dq_after(graph_module, q_node) can be handed None.

Two structural notes: transform_for_export_pass is wired into the test harness but not into to_edge_transform_and_lower_to_enn, so the tested pipeline is not the shipped one; and for a PR titled "Add quantpass testsuite", test/ops/ gains no tests for any of the six new builders or four new decompositions.

Full write-up with the walkthrough and the lower-severity items is in the inline comments below.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

# Get the finetune model
mobilebert_finetune = MobileBertFinetune(metric, args)
model, tokenized_datasets = mobilebert_finetune.get_finetune_mobilebert(
self.artifact

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.artifact does not exist — this test cannot pass.

model, tokenized_datasets = mobilebert_finetune.get_finetune_mobilebert(
    self.artifact
)

TestMilestoneMobileBertQAT never defines artifact, so this raises AttributeError. CI runs this file — .github/workflows/pull.yml:1612 does python -m unittest discover -s backends/samsung/test/models -p "test_*.py" — so test-samsung-models-linux fails deterministically.

Fix: args.artifact (or mobilebert_finetune.artifact).


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

super().__init__()
self.val_shape = eval_shape(val_shape)
if dims[0] is None:
self.shifts = [shifts[0] % torch.numel(torch.tensor(self.val_shape))]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Element count is computed as the rank — regression vs. the Qualcomm source this is ported from.

self.shifts = [shifts[0] % torch.numel(torch.tensor(self.val_shape))]

torch.tensor([2,3,4]).numel() is 3, not 24. backends/qualcomm/_passes/decompose_roll.py uses torch.numel(torch.empty(val_shape)). So flat torch.roll(x, shifts) (dims=None) shifts by shifts % ndim.

self.shifts = [shifts[0] % torch.numel(torch.empty(self.val_shape))]

This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

x = torch.flatten(x)
self.dim = 0

x = torch.pow(x, self.exp)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch.abs() and the ±inf ord handling were dropped in the port.

backends/qualcomm/_passes/decompose_linalg_vector_norm.py has, before this line:

x = torch.abs(x)
if self.exp == float("inf"):
    return torch.amax(x, dim=self.dim, keepdim=self.keepdim)
if self.exp == float("-inf"):
    return torch.amin(x, dim=self.dim, keepdim=self.keepdim)

Without abs, ord=1 computes sum(x) instead of sum(|x|) and every odd p is wrong; ord=±inf falls through to pow(x, inf). Please port those three lines over.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@register_node_visitor
class ReshapeVisitor(NodeVisitor):
target = "aten.view_copy.default"
target = ["aten.view_copy.default", "aten.copy.default"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping aten.copy.default onto RESHAPE reads the wrong argument.

target = ["aten.view_copy.default", "aten.copy.default"]

copy.default(self, src) returns src cast/broadcast to self's shape. define_node uses node.args[0] (self, the destination) as the RESHAPE input and never touches args[1] (src), so the actual data is silently discarded and the destination is passed through instead.

Input should be node.args[1], or copy.default should be handled by its own visitor.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

for shift, dim in zip(self.shifts, self.dims):
x = torch.cat(
(
x[(slice(None),) * dim + (slice(-shift, None),)],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A zero shift produces the wrong tensor instead of the identity.

When shift % dim_size == 0, slice(-shift, None) becomes slice(0, None) (the whole tensor) and slice(0, -shift) becomes slice(0, 0) (empty), so cat yields a duplicated / wrong-shaped result for what should be a no-op roll. Skip dims whose normalized shift is 0.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated



@register_annotator([operator.getitem])
def annotate_getitem(node: Node, quant_config: QuantizationConfig) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotate_getitem no-ops for everything except chunk, and has a dead assignment.

out_act_quantization_spec = quant_config.output_activation   # never read
if node.args[0].target == torch.ops.aten.chunk.default:
    out_act_quantization_spec = SharedQuantizationSpec(node.args[0])
    ...

The first assignment is overwritten inside the only branch that uses it. And since operator.getitem is now a registered annotator, every non-chunk getitem goes through this and gets no annotation at all — was that intended, or should the non-chunk path share qparams with its producer too?


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

@@ -385,14 +402,14 @@ def annotate_add_ops_with_SharedQuant(
# CASE 3-1: Single input + Single Out case without Shared Quant

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three annotator behaviors removed without a note in the summary. Could you confirm each is intentional?

  1. torch.ops.aten.ceil.default dropped from this 1in1out list.
  2. annotate_index_put (old CASE 5, covering index_put / index_put_) deleted — that is the KV-cache write path for LLM-shaped models.
  3. if input.target in ADD_OPS and _is_annotated([input]): del input.meta["quantization_annotation"] removed from annotate_1in1out_with_SharedQuant_for_FP.

If they are fixes, a line in the PR description would help; if they are collateral from the rebase, they are silent quantization regressions.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Comment thread backends/samsung/builders/op_cat.py Outdated
@register_node_visitor
class CatVisitor(NodeVisitor):
target = "aten.cat.default"
target = ["aten.cat.default", "aten.stack.default"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aten.stack.default routed to CONCAT with no unsqueeze.

stack inserts a new axis. define_node feeds the rank-N inputs straight into CONCAT while axis is taken modulo len(get_shape(node)), i.e. the rank-(N+1) output shape. If the ENN compiler tolerates the rank mismatch, a one-line comment saying so would help; either way, stack was just added to ops_not_to_decompose and there is no backends/samsung/test/ops/test_stack.py covering it.

More generally: this PR adds builders for flip, pad, prelu, silu, stack and copy plus four decomposition passes, and test/ops/ gains zero tests for any of them.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated


def __enter__(self):
constant_prop_module._DEFAULT_SKIP_TARGETS = set()
constant_prop_module._DEFAULT_SKIP_TARGETS_NO_QUANT = {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_DEFAULT_SKIP_TARGETS_NO_QUANT is a set upstream (exir/passes/constant_prop_pass.py:33); {} installs a dict. Harmless for in checks, but it should be set() to match.


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

from .replace_inf_values import ReplaceInfValues
from .replace_scalar_ops import ReplaceOpsWithScalar

__all__ = [

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__all__ should hold strings, not the objects themselves — from ... import * raises TypeError: Item in __all__ must be str. (builders/__init__.py has the same pre-existing pattern, so feel free to leave it if you'd rather stay consistent.)


This comment was generated by an AI reviewer (Claude Opus 5, via Claude Code). Please verify before acting on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Jiseong-oh and others added 6 commits September 14, 2026 06:33
- Add "transform_for_annotation" in EnnQuantizer and
  Add passes to decompose sdpa, glu, einsum before annotation.
- should't decompose silu and add silu builder.
- annotate Add which is before Softmax.

Signed-off-by: Jiseong Oh <jiseong.oh@samsung.com>
Co-authored-by: Jingya Zhang <jingya.zhang@samsung.com>
- If all users of placeholder are not in OP_ANNOTATOR, don't annotate
it.
- Unsqueeze weight shape when conv1d to conv2d and weight is buffer.
- It doesn't need to decompose pad before partition, and add pad builder.
  and split leaky_relu and prelu.
- It need to remove useless annotator.
- Add const and getitem annotator and concat and flip annoatator in annotate_1in1out_with_SharedQuant
- Add flip op builder

Signed-off-by: Jiseong Oh <jiseong.oh@samsung.com>
Co-authored-by: Jingya Zhang <jingya.zhang@samsung.com>
- Replace inf to 255
- Support quant split

Signed-off-by: Jiseong Oh <jiseong.oh@samsung.com>
Co-authored-by: Yue Li <y123.li@samsung.com>
- Update params_qdtype for some ops and add enn_pass_manager
  to let all passes calling in one file
- return op supported if sub-graph can be fold
- remove eltwise sharing quant param in annotator

Signed-off-by: Jiseong Oh <jiseong.oh@samsung.com>
Co-authored-by: Jingya Zhang <jingya.zhang@samsung.com>
- Add mobilebert QAT model in supported models
  it needs the datasets 5.0.0

Signed-off-by: Jiseong Oh <jiseong.oh@samsung.com>
Co-authored-by: Xiongzhan Linghu <xz.linghu@samsung.com>
Signed-off-by: jiseong.oh <jiseong.oh@samsung.com>
if self.exp == float("-inf"):
return torch.amin(x, dim=self.dim, keepdim=self.keepdim)
x = torch.pow(x, self.exp)
x = torch.sum(x, dim=self.dim, keepdim=self.keepdim)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the absolute-value and ±infinity cases. One valid case remains: ord=0 , means counting nonzero elements, but it reaches 1.0 / self.exp and raises ZeroDivisionError during torch.export.

Should we implement the exp == 0 case, for example using (x != 0).sum(...).to(x.dtype), or explicitly reject/skip this decomposition. Wdyt ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated.

Comment thread backends/samsung/builders/op_reshape.py Outdated
input = node.args[0]
# aten.copy(dst, src) yields src's values in dst's shape, so the data
# source is args[1]. view_copy reshapes args[0] itself.
input = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again Thx for switching the data source to args[1].

This still misses aten.copy broadcasting. For example, copying a (3,) tensor into a (2,3) tensor is valid, but reshaping (3,) to (2,3) fails. We should implement broadcasting or reject inputs with different shapes. Wdyt ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments. I updated codes.

- Handle ord=0 in the linalg_vector_norm decomposition
- Reject aten.copy delegation when src needs broadcasting into dst's shape

Signed-off-by: jiseong.oh <jiseong.oh@samsung.com>
@psiddh
psiddh merged commit 914cf7e into main Sep 14, 2026
232 checks passed
@psiddh
psiddh deleted the add-quantpass-testsuite branch September 14, 2026 16:15
@psiddh

psiddh commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

@Jiseong-oh An internal performance check flagged several redundant CPU-to-device copies in the new MobileBERT code. These are one-time export inputs, so the performance impact is likely small, but it would still be cleaner to create them directly on the target device.

Could you send a follow-up PR replacing torch.randint(...).to(device) and torch.zeros(...).to(device) with creation calls that pass device=device directly?

Affected files:

  • backends/samsung/test/models/test_mobilebert_qat.py
  • examples/samsung/scripts/mobilebert_finetune_QAT.py

JakeStevens pushed a commit that referenced this pull request Oct 14, 2026
…, and Samsung conv1d (#22373)

### Summary

Error-guard sites that construct a failure which cannot actually fire.
This PR inserts the missing `raise` (or replaces an always-true `assert`
with the file's existing `check_or_raise`) so the documented failure
mode is the one callers see.

Updated for `main` at 5e21c13: the two `ExportSession` guards were fixed
upstream in the meantime by #21748, so the only code change left in
`export/export.py` is the message typo. The regression tests for those
two guards are kept, since nothing else covers them.

| File | What happens on `main` today | Reachability |
| --- | --- | --- |
| `export/export.py` `ExportSession.print_delegation_info` | Both guards
already `raise` (#21748). Remaining here: the message says "atleast",
and no test pins either guard. | **Reachable.** `ExportSession` is in
`executorch.export.__all__` and is `@experimental`. A pipeline with no
lowering stage, or one that lists `TO_EDGE_TRANSFORM_AND_LOWER` /
`TO_BACKEND` without having run it, reaches each guard. This PR fixes
the wording and adds `export/tests/test_print_delegation_info.py` for
both. |
| `backends/xnnpack/operators/node_visitor.py` per-channel axis `else` |
`assert f"Unsupported weight per channel quantization axis ..."`: the
f-string is always truthy, so the assertion never fires. An `assert`
would also disappear under `python -O`. | **Not reachable on a normal
export.** The only call that passes `swap_in_out_for_weights=True` is
`backends/xnnpack/operators/op_conv2d.py:102`, and that visitor already
`check_or_raise`s the axis to `0` (depthwise) or `1` (transpose) before
`define_tensor`. This change restores a guard that can actually raise if
that `else` is ever entered; it does not fix a mis-serialized `.pte` on
the current conv2d path. |
| `backends/samsung/_passes/conv1d_to_conv2d.py` `update_kernel` `else`
| `RuntimeError("Weight of 1d conv should be constant tensor or
Parameter obj")` is built and discarded; `weight_node.meta["val"]` is
still unsqueezed. | **Not reachable on a normal Parameter /
lifted-constant / buffer conv1d export.** Those cases are handled by the
preceding branches (the buffer branch was added on `main` by #22725).
The `else` is the leftover for a weight that is none of those. This
change only makes that documented `RuntimeError` actually raise if the
branch is entered. |

### Test plan

Tests cover only the two reachable `ExportSession` guards. There is
intentionally no test for the XNNPACK `else` and none for the Samsung
`else`: both are unreachable on a normal export, and a test that injects
that state would exercise a situation the production callers do not
produce.

`export/tests` is already in `pytest.ini` `testpaths`:

```
pytest export/tests/test_print_delegation_info.py
```

Measured on 89cf698 (merge of `main` 5e21c13), CPython 3.12, torch
2.15.0.dev20261004+cpu:

- `export/tests/test_print_delegation_info.py`: 2 passed.
- Negative control, after `git checkout origin/main --
export/export.py`, same run: `AssertionError: 'at least one of the
lowering stages' not found in 'No delegation info available, atleast one
of the lowering stages should be present'`, 1 failed / 1 passed.
- `pytest export/tests --ignore=export/tests/test_target_recipes.py`: 8
failed / 172 passed on this branch, and the same 8 failed / 170 passed
on `main` alone. The 8 are a local-environment gap
(`exir/_serialize/program.fbs` is copied in by the build, which this
checkout has not run), not a regression. `test_target_recipes.py` does
not collect locally (no `coremltools`).

### CI

Merged `main` into the branch. The conflict in `export/export.py` was
resolved in favour of `main`'s `_raise_if_released` call, keeping the
typo fix. The six reds triaged earlier on 12c3858 came from the merge
base and their upstream fixes (#22802, #22754) are now in this branch.

Two checks are still red on 89cf698, neither of them from this change:

- `pull / android / run-emulator`: the emulator boots
(`sys.boot_completed` returns 1), and
`reactivecircus/android-emulator-runner` then fails on its own post-boot
`adb shell input keyevent 82` with `cmd: Failure calling service input:
Broken pipe (32)`, exit code 224. That step runs before the job script,
and the log carries no output from `scripts/run_android_emulator.sh`.
The same job also failed on `main` at efc7f2e when checked on
2026-10-06, and passed on the seven `main` runs before it.
- `MLTEC_elastic - GitHubPOC` (NXP Bamboo): outside this repository's
workflows, and red on other PRs too, not just this one: of eight open
PRs untouched since 2026-10-05, two carry this status and both are red.
Here the status went `pending` at 2026-10-05T07:01:25Z and `failure` one
second later, which reads as a trigger-side failure rather than anything
built from this branch, but the build log is on an internal host so I
cannot confirm that from here.

This change touches three Python files and adds one test.

cc @nil-is-all @digantdesai

Co-authored-by: Axel.Cffrd.Dnty <AxelNoun@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>

This branch was previously deployed

1 inactive deployment
cadence — 5cc1251e Deployed Sep 14, 2026 by Jiseong-oh via hifi-op-test / hifi4 #27648
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: samsung partner: samsung For backend delegation, kernels, demo, etc. from the 3rd-party partner, Samsung

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants