Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 81 additions & 16 deletions test/end2end/test_end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,44 @@ def test_ft_cond_basic(self):
),
)(self)

@skipUnless(RUN_SKIPPED, "Emitter is not ready yet")
def test_ft_map_basic(self):
maketest(
FTMapBasic,
capture_config=exir.CaptureConfig(
enable_dynamic_shape=True,
enable_functionalization=False, # TODO enable functionalization
),
)(self)
"""Test FTMapBasic model through the modern torch.export API."""
from executorch.exir import EdgeCompileConfig, to_edge
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The import statement from executorch.exir import EdgeCompileConfig, to_edge is redundant since EdgeCompileConfig is already imported at the module level (line 26). Consider using the existing module-level import and only importing to_edge locally, or move both imports to the top of the file for consistency with other imports in this test file.

Suggested change
from executorch.exir import EdgeCompileConfig, to_edge
from executorch.exir import to_edge

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The import statement from executorch.exir import EdgeCompileConfig, to_edge is redundant since EdgeCompileConfig is already imported at the module level (line 26). Consider using the existing module-level import and only importing to_edge locally, or move both imports to the top of the file for consistency with other imports in this test file.

Suggested change
from executorch.exir import EdgeCompileConfig, to_edge
from executorch.exir import to_edge

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

EdgeCompileConfig is already imported at the module level (line 26). Only to_edge needs to be imported here since it's not available at the module level.

Suggested change
from executorch.exir import EdgeCompileConfig, to_edge
from executorch.exir import to_edge

Copilot uses AI. Check for mistakes.

# Create model and get inputs
model = FTMapBasic()
inputs = model.get_random_inputs()

# Export the model
exported_program = torch.export.export(
model,
inputs,
)

# Convert to edge program
edge_program = to_edge(
exported_program,
compile_config=EdgeCompileConfig(_check_ir_validity=False),
)

# Convert to executorch
executorch_program = edge_program.to_executorch()

# Load and run
executorch_module = _load_for_executorch_from_buffer(executorch_program.buffer)

# Test execution matches eager mode
eager_output = model(*inputs)
et_output = executorch_module.forward(list(inputs))[0]

# Compare outputs
torch.testing.assert_close(
et_output,
eager_output,
rtol=1e-5,
atol=1e-8,
msg="ExecuTorch output doesn't match eager output",
)
Comment on lines +732 to +743
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

This test only validates a single execution with one set of inputs. The previous maketest approach ran 10 iterations with different random inputs (niter=10) to catch edge cases and ensure consistent behavior. Consider adding a loop to test multiple random input sets for more robust validation.

Copilot uses AI. Check for mistakes.

@skipUnless(RUN_SKIPPED, "TODO(larryliu0820) Fix this in both fbcode and oss")
def test_ft_cond_dynshape(self):
Expand All @@ -723,15 +752,51 @@ def test_ft_cond_dynshape(self):
),
)(self)

@skipUnless(RUN_SKIPPED, "Emitter is not ready yet")
def test_ft_map_dynshape(self):
maketest(
FTMapDynShape,
capture_config=exir.CaptureConfig(
enable_dynamic_shape=True,
enable_functionalization=False, # TODO enable functionalization
),
)(self)
"""Test FTMapDynShape model through the modern torch.export API.

Note: The higher-order map operation specializes on the iteration dimension
at export time, so varying batch sizes are not supported. This test verifies
that the map-based model can be exported and executed correctly through the
ExecuTorch pipeline using the modern torch.export.export() API.
"""
from executorch.exir import EdgeCompileConfig, to_edge
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

EdgeCompileConfig is already imported at the module level (line 26). Only to_edge needs to be imported here since it's not available at the module level.

Copilot uses AI. Check for mistakes.

# Create model and get inputs
model = FTMapDynShape()
# Use upper bound inputs since map specializes on the iteration dimension
inputs = model.get_upper_bound_inputs()

# Export the model
exported_program = torch.export.export(
model,
inputs,
)

# Convert to edge program
edge_program = to_edge(
exported_program,
compile_config=EdgeCompileConfig(_check_ir_validity=False),
)

# Convert to executorch
executorch_program = edge_program.to_executorch()

# Load and run
executorch_module = _load_for_executorch_from_buffer(executorch_program.buffer)

# Test execution matches eager mode
eager_output = model(*inputs)
et_output = executorch_module.forward(list(inputs))[0]

# Compare outputs
torch.testing.assert_close(
et_output,
eager_output,
rtol=1e-5,
atol=1e-8,
msg="ExecuTorch output doesn't match eager output",
)
Comment on lines +788 to +799
Copy link

Copilot AI Jan 17, 2026

Choose a reason for hiding this comment

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

This test only validates a single execution with one set of inputs. The previous maketest approach ran 10 iterations with different random inputs (niter=10) to catch edge cases and ensure consistent behavior. Consider adding a loop to test multiple random input sets for more robust validation.

Copilot uses AI. Check for mistakes.

@skipUnless(RUN_SKIPPED, "TODO(larryliu0820) Fix this in both fbcode and oss")
def test_batch_norm(self):
Expand Down
Loading