-
Notifications
You must be signed in to change notification settings - Fork 873
Expand file tree
/
Copy pathexport.py
More file actions
696 lines (592 loc) · 26.5 KB
/
export.py
File metadata and controls
696 lines (592 loc) · 26.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2025 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import logging
import time
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union
import torch
from executorch.exir import EdgeProgramManager
from executorch.exir._warnings import experimental
from executorch.exir.program import ExecutorchProgramManager
from executorch.exir.schema import Program
from executorch.extension.export_util.utils import save_pte_program
from tabulate import tabulate
from torch import nn
from torch.export import ExportedProgram
from torch.fx import GraphModule
from .recipe import ExportRecipe, LoweringRecipe, QuantizationRecipe
from .stages import (
EdgeProgramManagerTransformStage,
EdgeTransformAndLowerStage,
ExecutorchStage,
PipelineArtifact,
QuantizeStage,
SourceTransformStage,
Stage,
ToBackendStage,
ToEdgeStage,
TorchExportStage,
)
from .types import StageType
@experimental(
"This API and all of its related functionality such as ExportSession and ExportRecipe are experimental."
)
def export(
model: Union[
nn.Module,
Dict[str, nn.Module],
GraphModule,
Dict[str, GraphModule],
ExportedProgram,
Dict[str, ExportedProgram],
str,
],
example_inputs: Optional[
Union[
List[tuple[torch.Tensor, ...]],
Dict[str, List[tuple[torch.Tensor, ...]]],
]
] = None,
export_recipe: ExportRecipe = None,
name: Optional[str] = None,
dynamic_shapes: Optional[Union[Any, Dict[str, Any]]] = None,
constant_methods: Optional[Union[Dict[str, Callable]]] = None,
artifact_dir: Optional[str] = None,
generate_etrecord: bool = False,
) -> "ExportSession":
"""
Create and configure an ExportSession with the given parameters.
This function provides a convenient way to create an ExportSession and
optionally run the export process in one step.
Args:
model: The PyTorch model(s) to export. Can be:
- nn.Module or Dict[str, nn.Module]: Eager PyTorch model(s)
- GraphModule or Dict[str, GraphModule]: Quantized model(s) (e.g., from prepare/convert)
- ExportedProgram or Dict[str, ExportedProgram]: Already exported model(s)
- str: Path to load an ExportedProgram from disk
example_inputs: Example inputs for the model(s), either a list of input tuples
or a dictionary mapping method names to lists of input tuples.
First sample (index 0) is used for torch.export.export() to export the model.
All samples are used as calibration dataset in PT2E Quantize stage.
Optional when model is ExportedProgram (not needed).
export_recipe: Contains the configuration for the export process
name: Optional name for the export
dynamic_shapes: Optional dynamic shape specifications
constant_methods: Optional dictionary of constant methods
artifact_dir: Optional directory to store artifacts
generate_etrecord: Optional flag to generate an etrecord
Returns:
A configured ExportSession instance with the export process completed if requested
"""
session = ExportSession(
model=model,
example_inputs=example_inputs,
export_recipe=export_recipe,
name=name,
dynamic_shapes=dynamic_shapes,
constant_methods=constant_methods,
artifact_dir=artifact_dir,
generate_etrecord=generate_etrecord,
)
session.export()
return session
@experimental(
"This API and all of its related functionality such as ExportSession and ExportRecipe are experimental."
)
class ExportSession:
"""
Manages the export process for ExecuTorch models.
This class handles the export process through a pipeline of stages:
1. (Optional) Quantize - Apply post-training quantization to the model
2. Export - Export PyTorch model to ExportedProgram
3. EdgeTransformAndLower - Transform and lower to EdgeProgramManager
4. Executorch - Convert to ExecutorchProgramManager for final execution
"""
def __init__(
self,
model: Union[
nn.Module,
Dict[str, nn.Module],
GraphModule,
Dict[str, GraphModule],
ExportedProgram,
Dict[str, ExportedProgram],
str,
],
example_inputs: Optional[
Union[
List[tuple[torch.Tensor, ...]],
Dict[str, List[tuple[torch.Tensor, ...]]],
]
] = None,
export_recipe: ExportRecipe = None,
name: Optional[str] = None,
dynamic_shapes: Optional[Union[Any, Dict[str, Any]]] = None,
constant_methods: Optional[Union[Dict[str, Callable]]] = None,
artifact_dir: Optional[str] = None,
generate_etrecord: Optional[bool] = False,
) -> None:
"""
Initialize the ExportSession with model, inputs, and recipe.
Args:
model: The PyTorch model(s) to export. Can be:
- nn.Module or Dict[str, nn.Module]: Eager PyTorch model(s)
- GraphModule or Dict[str, GraphModule]: Quantized model(s)
- ExportedProgram or Dict[str, ExportedProgram]: Already exported model(s)
- str: Path to load an ExportedProgram from disk
example_inputs: Example inputs for the model(s), either a list of input tuples
or a dictionary mapping method names to lists of input tuples.
First sample (index 0) is used for torch.export.export() to export the model.
All samples are used as calibration dataset in PT2E Quantize stage,
Optional when model is ExportedProgram (not needed).
export_recipe: Contains the configuration for the export process
name: Optional name for the export
dynamic_shapes: Optional dynamic shape specifications
constant_methods: Optional dictionary of constant methods
artifact_dir: Optional directory to store artifacts
generate_etrecord: Optional flag to generate an etrecord
"""
# Load model from file if string path provided
if isinstance(model, str):
model = torch.export.load(model)
logging.info(f"Loaded ExportedProgram from {model}")
# Detect input model type to determine which stages to skip
self._input_model_type = self._detect_model_type(model)
# Standardize model to dictionary format
self._model = model if isinstance(model, dict) else {"forward": model}
# Validate and standardize example_inputs to dictionary format
# example_inputs not required for ExportedProgram input
if self._input_model_type == "ExportedProgram":
self._example_inputs = example_inputs or {}
if isinstance(self._example_inputs, list):
self._example_inputs = {"forward": self._example_inputs}
else:
# For nn.Module and GraphModule, example_inputs are required
if example_inputs is None:
raise ValueError(
f"example_inputs are required when model is {self._input_model_type}. "
f"Only ExportedProgram inputs can omit example_inputs."
)
self._example_inputs = (
example_inputs
if isinstance(example_inputs, dict)
else {"forward": example_inputs}
)
# Standardize dynamic_shapes to dictionary format
self._dynamic_shapes = {}
if dynamic_shapes is not None:
if isinstance(dynamic_shapes, dict):
self._dynamic_shapes = dynamic_shapes
else:
self._dynamic_shapes = {"forward": dynamic_shapes}
self._export_recipe = export_recipe
self._quant_recipe: Optional[QuantizationRecipe] = (
self._export_recipe.quantization_recipe
)
self._lowering_recipe: Optional[LoweringRecipe] = (
self._export_recipe.lowering_recipe
)
# Stages to run
self._pipeline_stages = (
self._export_recipe.pipeline_stages or self._get_default_pipeline()
)
# Stage registry: map of StageType to Stage instances
self._stage_registry: Dict[StageType, Stage] = self._build_stages(
self._pipeline_stages
)
# Intialize run context
self._run_context: Dict[str, Any] = {
"example_inputs": self._example_inputs,
"dynamic_shapes": self._dynamic_shapes,
"constant_methods": constant_methods,
"export_recipe": self._export_recipe,
"session_name": name,
"artifact_dir": artifact_dir,
"generate_etrecord": generate_etrecord,
}
self._stage_to_artifacts: Dict[StageType, PipelineArtifact] = {}
def _detect_model_type(
self, model: Union[nn.Module, GraphModule, ExportedProgram, Dict]
) -> str:
"""
Detect the type of input model.
Args:
model: Input model in various formats
Returns:
String indicating the model type: "nn.Module", "GraphModule", or "ExportedProgram"
"""
# Handle dict (multi-method) - check first value
if isinstance(model, dict):
first_value = next(iter(model.values()))
return self._detect_model_type(first_value)
# Detect single model type
if isinstance(model, ExportedProgram):
return "ExportedProgram"
elif isinstance(model, GraphModule):
return "GraphModule"
elif isinstance(model, nn.Module):
return "nn.Module"
else:
raise TypeError(f"Unsupported model type: {type(model)}")
def _get_default_pipeline(self) -> List[StageType]:
"""
Get default pipeline stages based on input model type.
Returns:
List of stages appropriate for the input model type
"""
stages = []
# Add quantization stages only for eager nn.Module
if self._input_model_type == "nn.Module":
stages.extend(
[
StageType.SOURCE_TRANSFORM, # Optional stage, returns original model if quant recipe is invalid
StageType.QUANTIZE, # Optional stage, returns original model if quant recipe is invalid
]
)
# Add torch export stage if not already exported
if self._input_model_type != "ExportedProgram":
stages.append(StageType.TORCH_EXPORT)
# Always include edge and executorch stages
stages.extend(
[
StageType.TO_EDGE_TRANSFORM_AND_LOWER,
StageType.TO_EXECUTORCH,
]
)
return stages
def _build_stages(self, stages: List[StageType]) -> Dict[StageType, Stage]:
"""Build the stage registry from the given stages."""
stage_registry: Dict[StageType, Stage] = {}
stage = None
for stage_type in stages or self._get_default_pipeline():
if stage_type == StageType.SOURCE_TRANSFORM:
stage = SourceTransformStage(self._quant_recipe)
elif stage_type == StageType.QUANTIZE:
stage = QuantizeStage(self._quant_recipe)
elif stage_type == StageType.TORCH_EXPORT:
aten_transform_passes = None
if self._export_recipe.aten_transform_passes is not None:
aten_transform_passes = list(
self._export_recipe.aten_transform_passes
)
stage = TorchExportStage(
aten_transform_passes, strict=self._export_recipe.strict
)
elif stage_type == StageType.TO_EDGE_TRANSFORM_AND_LOWER:
stage = EdgeTransformAndLowerStage.from_recipe(self._lowering_recipe)
elif stage_type == StageType.TO_EDGE:
stage = ToEdgeStage.from_recipe(self._lowering_recipe)
elif stage_type == StageType.EDGE_PROGRAM_MANAGER_TRANSFORM:
stage = EdgeProgramManagerTransformStage.from_recipe(
self._lowering_recipe
)
elif stage_type == StageType.TO_BACKEND:
stage = ToBackendStage.from_recipe(self._lowering_recipe)
elif stage_type == StageType.TO_EXECUTORCH:
stage = ExecutorchStage(self._export_recipe.executorch_backend_config)
else:
logging.info(
f"{stage_type} is unknown, you have to register it before executing export()"
)
if stage:
stage_registry[stage_type] = stage
return stage_registry
def register_stage(self, stage_type: StageType, stage: Stage) -> None:
"""
Register a new stage or override an existing stage implementation.
Args:
stage_type: The type of stage to register
stage: The stage instance to register
"""
self._stage_registry[stage_type] = stage
def get_registered_stage(self, stage_type: StageType) -> Optional[Stage]:
"""
Get a registered stage by its type.
Args:
stage_type: The type of stage to retrieve
Returns:
The registered stage instance, or None if not found
"""
return self._stage_registry.get(stage_type)
def get_all_registered_stages(self) -> Dict[StageType, Stage]:
"""
Get all registered stages.
Returns:
Dictionary mapping stage types to stage instances
"""
return self._stage_registry
def _validate_pipeline_sequence(
self,
stages: List[StageType],
) -> None:
if not stages:
raise ValueError("Pipeline stages cannot be empty")
# Validate pipeline compatibility with input model type
if self._input_model_type == "GraphModule":
# GraphModule input should not run quantization stages
incompatible_stages = {StageType.SOURCE_TRANSFORM, StageType.QUANTIZE}
found_incompatible = set(stages) & incompatible_stages
if found_incompatible:
stage_names = ", ".join(s.name for s in found_incompatible)
raise ValueError(
f"Cannot run {stage_names} stage(s) with GraphModule input. "
f"GraphModule is already quantized. "
f"Remove {stage_names} from pipeline_stages or use nn.Module input."
)
elif self._input_model_type == "ExportedProgram":
# ExportedProgram input should not run quantization or torch export stages
incompatible_stages = {
StageType.SOURCE_TRANSFORM,
StageType.QUANTIZE,
StageType.TORCH_EXPORT,
}
found_incompatible = set(stages) & incompatible_stages
if found_incompatible:
stage_names = ", ".join(s.name for s in found_incompatible)
raise ValueError(
f"Cannot run {stage_names} stage(s) with ExportedProgram input. "
f"ExportedProgram is already exported. "
f"Remove {stage_names} from pipeline_stages or use nn.Module/GraphModule input."
)
# Validate that the first stage can start a pipeline
first_stage = stages[0]
first_stage_instance = self._stage_registry.get(first_stage)
if first_stage_instance is None:
raise ValueError(
f"Stage {first_stage} not found in registry, register it using session.register_stage()"
)
if not first_stage_instance.can_start_pipeline:
raise ValueError(f"Stage {first_stage} cannot start a pipeline. ")
# Validate stage transitions
for i in range(1, len(stages)):
current_stage = stages[i]
previous_stage = stages[i - 1]
# Get the stage instance to check its valid predecessors
stage_instance = self._stage_registry.get(current_stage)
if stage_instance is None:
raise ValueError(
f"Stage {current_stage} not found in registry, , register it using session.register_stage()"
)
valid_predecessors = stage_instance.valid_predecessor_stages
# Check if the previous stage is valid for the current stage
if valid_predecessors and previous_stage not in valid_predecessors:
raise ValueError(
f"Invalid transition from {previous_stage} to {current_stage}. "
f"Valid predecessors for {current_stage}: {valid_predecessors}"
)
def _run_pipeline(self) -> None:
# Validate if given stage sequence is valid
self._validate_pipeline_sequence(
stages=self._pipeline_stages,
)
current_artifact = PipelineArtifact(data=self._model, context=self._run_context)
# Execute stages from registry in the order specified by pipeline_stages
for stage_type in self._pipeline_stages:
stage = self._stage_registry.get(stage_type)
if stage is None:
raise ValueError(f"Stage {stage_type} not found in registry")
logging.info(f"Executing stage: {stage_type}")
start = time.perf_counter()
stage.run(current_artifact)
elapsed = (time.perf_counter() - start) * 1000
current_artifact = stage.get_artifacts()
current_artifact.add_context("duration_ms", int(elapsed))
logging.info(f"Stage {stage_type} execution done")
self._stage_to_artifacts[stage_type] = current_artifact
def export(self) -> None:
"""
Execute the full export process.
This method orchestrates the export process with optional quantization:
1. (Optional) Apply quantization to the model
2. Export the PyTorch model to ExportedProgram
3. Transform and lower to EdgeProgramManager
4. Convert to ExecutorchProgramManager
"""
# Run the pipeline from the beginning
self._run_pipeline()
def get_stage_artifacts(self) -> Dict[StageType, PipelineArtifact]:
return self._stage_to_artifacts
def get_exported_program(self, method_name: str = "forward") -> ExportedProgram:
"""
Get the ExportedProgram for a specific method after torch export.
Args:
method_name: Name of the method to get exported program for, defaults to "forward"
Returns:
The ExportedProgram for the specified method
Raises:
RuntimeError: If torch export stage has not been run
KeyError: If the method name is not found in exported programs
"""
artifact = self._stage_to_artifacts.get(StageType.TORCH_EXPORT)
if artifact is None or artifact.data is None:
raise RuntimeError(
"Exported program is not available. Run Torch Export Stage first."
)
exported_programs = artifact.data
if method_name not in exported_programs:
raise KeyError(
f"Method name '{method_name}' not found in exported programs. "
f"Available methods: {list(exported_programs.keys())}"
)
return exported_programs[method_name]
def get_edge_program_manager(self) -> "EdgeProgramManager":
"""
Get the EdgeProgramManager after edge lowering stages.
This method checks multiple stages in order of preference:
1. TO_EDGE_TRANSFORM_AND_LOWER (combined stage)
2. TO_BACKEND (separate stage with backend delegation)
3. EDGE_PROGRAM_MANAGER_TRANSFORM (separate stage after TO_EDGE)
4. TO_EDGE (separate stage without backend delegation)
Returns:
The EdgeProgramManager
Raises:
RuntimeError: If no edge stage has been run
"""
# Check stages in order of preference
for stage_type in [
StageType.TO_EDGE_TRANSFORM_AND_LOWER,
StageType.TO_BACKEND,
StageType.EDGE_PROGRAM_MANAGER_TRANSFORM,
StageType.TO_EDGE,
]:
artifact = self._stage_to_artifacts.get(stage_type)
if artifact is not None and artifact.data is not None:
logging.info(f"Returning edge program manager from stage {stage_type}")
return artifact.data
raise RuntimeError(
"Edge program manager is not available. "
"Run one of the edge stages first: TO_EDGE_TRANSFORM_AND_LOWER, TO_EDGE, EDGE_PROGRAM_MANAGER_TRANSFORM, or TO_BACKEND."
)
def get_executorch_program(self) -> Program:
"""
Get the ExecutorchProgram from the ExecutorchProgramManager.
Returns:
The ExecutorchProgram
Raises:
RuntimeError: If the executorch program manager is not initialized
"""
return self.get_executorch_program_manager().executorch_program
def get_executorch_program_manager(self) -> ExecutorchProgramManager:
"""
Get the ExecutorchProgramManager.
Returns:
The ExecutorchProgramManager
Raises:
RuntimeError: If the executorch program manager is not initialized
"""
artifact = self._stage_to_artifacts.get(StageType.TO_EXECUTORCH)
if artifact is None or artifact.data is None:
raise RuntimeError(
"Executorch program manager is not initialized. Run Executorch Stage first."
)
return artifact.data
def get_pte_buffer(self) -> bytes:
"""
Get the PTE buffer as bytes.
Returns:
The PTE buffer as bytes
Raises:
RuntimeError: If the executorch program manager is not initialized
"""
return self.get_executorch_program_manager().buffer
def save_to_pte(self, output_name: str) -> None:
"""
Save the model to a .pte file.
Args:
output_name (Optional[str]): The name of the .pte file.
"""
assert output_name, "Need a valid output name"
save_pte_program(self.get_executorch_program_manager(), output_name)
def get_example_input(
self, method_name: str = "forward"
) -> Tuple[torch.Tensor, ...]:
"""
Get the example input for a specific method.
Args:
method_name: Name of the method to get example input for, defaults to "forward"
Returns:
Tuple of tensors representing the example input
Raises:
KeyError: If the method name is not found in example inputs
ValueError: If the example inputs list is empty
"""
if method_name not in self._example_inputs:
raise KeyError(f"Method name '{method_name}' not found in example inputs")
# Access the first element of the list for this method
example_inputs_list = self._example_inputs[method_name]
if not example_inputs_list:
raise ValueError(f"Example inputs list for method {method_name} is empty")
# The original code expects this to be a tuple of tensors
return self._example_inputs[method_name][0]
def run_method(
self,
method_name: str = "forward",
example_inputs: Optional[Tuple[torch.Tensor, ...]] = None,
) -> Sequence[Any]:
"""
Run a specific method with the given inputs.
Args:
method_name: Name of the method to run, defaults to "forward"
example_inputs: Optional inputs to use, defaults to the example inputs
Returns:
The outputs of the method execution
Raises:
RuntimeError: If the method cannot be loaded
"""
# Lazy import to avoid forcing portable_lib dependency at module load time.
try:
from executorch.runtime import Runtime, Verification
except ModuleNotFoundError as e:
raise ModuleNotFoundError(
"executorch.runtime is not available. "
"In OSS: Please ensure executorch is properly installed via pip. "
"In fbcode: Please add //executorch/runtime:runtime to your dependencies."
) from e
et_runtime = Runtime.get()
program = et_runtime.load_program(
self.get_pte_buffer(), verification=Verification.Minimal
)
forward = program.load_method(method_name)
if forward is None:
raise RuntimeError(
f"Failed to load method '{method_name}' from the program"
)
if example_inputs is None:
example_inputs = self.get_example_input(method_name)
return forward.execute(example_inputs)
def print_delegation_info(self) -> None:
"""
Print delegation information for the exported program.
"""
lowering_stage = list(
set(self._pipeline_stages)
& {StageType.TO_EDGE_TRANSFORM_AND_LOWER, StageType.TO_BACKEND}
)
if not lowering_stage:
RuntimeError(
"No delegation info available, atleast one of the lowering stages should be present"
)
stage_artifact = self._stage_to_artifacts.get(lowering_stage[0])
if stage_artifact is None:
RuntimeError("No delegation info available, run the lowering stage first")
# pyre-ignore
delegation_info = stage_artifact.get_context("delegation_info", None)
if delegation_info:
print(delegation_info.get_summary())
df = delegation_info.get_operator_delegation_dataframe()
print(tabulate(df, headers="keys", tablefmt="fancy_grid"))
else:
print("No delegation info available")
# Use Any instead of ETRecord as return type to avoid static dependency on etrecord
def get_etrecord(self) -> Any:
"""
Get the etrecord from the ExecuTorchProgramManager.
Returns:
The etrecord in the ExecuTorchProgramManager
Raises:
RuntimeError: If the ExecuTorchManager is unavailable, or etrecord is not available in the ExecuTorchProgramManager
"""
return self.get_executorch_program_manager().get_etrecord()