Tracing Data Flow in Hyrax#
When working with a new dataset or model it can be hard to know whether your data is being processed correctly. Hyrax provides a trace mode that lets you follow a small batch of data items through the entire pipeline — from raw dataset access, through batching and input preparation, all the way to model evaluation — so you can inspect what is actually happening at each step.
This notebook walks through a typical trace session:
Setting up a Hyrax instance
Running a verb with
trace=Nto capture pipeline dataPrinting and navigating the returned
TraceResultDrilling into individual stages and function calls
Trace mode is intended for interactive use in notebooks — it is not a production profiling or logging tool.
Install Hyrax#
Skip this step if you have already installed Hyrax in your environment.
[1]:
# %pip install hyrax
Create a Hyrax instance#
We start by creating a Hyrax instance and pointing it at a simple built-in model and dataset. Here we use HyraxAutoencoder trained on HyraxRandomDataset — a dataset that generates random tensors without requiring any downloaded data, which makes it convenient for experimentation.
You can replace this with your own model and dataset configuration to trace your real workflow.
[2]:
import hyrax
h = hyrax.Hyrax()
Configure the model and data#
We will use the HyraxAutoencoder model and HyraxRandomDataset to keep this notebook self-contained. The random dataset produces small random tensors ([1, 32, 32]) that resemble single-band image cutouts.
[3]:
h.config["model"]["name"] = "HyraxAutoencoder"
# Use a small 1-channel 32×32 image shape to keep things fast
h.config["data_set"]["HyraxRandomDataset"]["shape"] = [1, 32, 32]
h.config["data_set"]["HyraxRandomDataset"]["size"] = 50
h.config["data_set"]["HyraxRandomDataset"]["seed"] = 42
data_request = {
"train": {
"data": {
"dataset_class": "HyraxRandomDataset",
"data_location": "./trace_data",
"fields": ["image"],
"primary_id_field": "object_id",
},
},
"infer": {
"data": {
"dataset_class": "HyraxRandomDataset",
"data_location": "./trace_data",
"fields": ["image"],
"primary_id_field": "object_id",
},
},
}
h.set_config("data_request", data_request)
[4]:
from hyrax.datasets.random.hyrax_random_dataset import HyraxRandomDataset
import numpy as np
def collate_image(self, samples: list[dict]) -> dict:
collated_data = {}
collated_data["image"] = np.stack([sample["image"] for sample in samples], axis=0)
collated_data["mask"] = np.zeros_like(collated_data["image"], dtype=bool)
return collated_data
HyraxRandomDataset.collate = collate_image
We attach either a collate_image function to HyraxRandomDataset above. We could instead attach a dataset-level collate function like the one shown below. The TraceResult will contain information for whichever function is attached. Field-level collation functions are described in the field_level_collation group which will be empty if a dataset-level collate function is defined. Dataset-level collate functions are described in the collate group.
def collate(self, samples: list[dict]) -> dict:
collated_data = {}
collated_data["image"] = np.stack([sample["image"] for sample in samples], axis=0)
collated_data["mask"] = np.zeros_like(collated_data["image"], dtype=bool)
return collated_data
HyraxRandomDataset.collate = collate
Running a verb in trace mode#
Any instrumented verb (train, infer, test) accepts a trace=N keyword argument. N controls how many data items are traced through the pipeline — keep this small (2–10) to get a readable output.
When trace=N is passed, the verb:
Processes only a single batch of
Nitems instead of the full datasetReturns a
TraceResultobject instead of the usual verb return value
The TraceResult captures the inputs and outputs of every major pipeline step.
[5]:
trace_result = h.train(trace=2)
[2026-07-25 00:13:13,004 hyrax.trace:WARNING] Starting Trace
[2026-07-25 00:13:13,005 hyrax.trace:WARNING] Trace mode enabled, will only run a single batch of length 2
[2026-07-25 00:13:13,072 hyrax.models.model_registry:INFO] Setting model's self.optimizer from config: torch.optim.SGD with arguments: {'lr': 0.01, 'momentum': 0.9}.
[2026-07-25 00:13:13,073 hyrax.models.model_registry:INFO] Setting model's self.criterion from config: torch.nn.CrossEntropyLoss with default arguments.
[2026-07-25 00:13:13,075 hyrax.models.model_registry:INFO] Setting model's self.scheduler from config: torch.optim.lr_scheduler.ExponentialLR
with arguments: {'gamma': 1}.
[2026-07-25 00:13:13,077 hyrax.verbs.train:INFO] Using a single process for training.
[2026-07-25 00:13:13,078 hyrax.verbs.train:INFO] Training model: HyraxAutoencoder
[2026-07-25 00:13:13,080 hyrax.verbs.train:INFO] Training dataset(s):
{'train': Name: data (primary dataset)
Dataset class: HyraxRandomDataset
Data location: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/trace_data
Selected items: 50
Primary ID field: object_id
Requested fields: image
}
2026-07-25 00:13:13,086 ignite.distributed.auto.auto_dataloader INFO: Use data loader kwargs for dataset '<torch.utils.data.da':
{'sampler': <torch.utils.data.sampler.WeightedRandomSampler object at 0x73dd9b8abb90>, 'batch_size': 2, 'collate_fn': <bound method CollationMixin.collate of Name: data (primary dataset)
Dataset class: HyraxRandomDataset
Data location: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/trace_data
Selected items: 50
Primary ID field: object_id
Requested fields: image
>, 'pin_memory': False}
2026/07/25 00:13:13 INFO mlflow.store.db.utils: Creating initial MLflow database tables...
2026/07/25 00:13:13 INFO mlflow.store.db.utils: Updating database tables
2026/07/25 00:13:16 INFO mlflow.tracking.fluent: Experiment with name 'notebook' does not exist. Creating a new experiment.
2026/07/25 00:13:16 INFO mlflow.system_metrics.system_metrics_monitor: Skip logging GPU metrics. Set logger level to DEBUG for more details.
2026/07/25 00:13:16 INFO mlflow.system_metrics.system_metrics_monitor: Started monitoring system metrics.
[2026-07-25 00:13:16,532 hyrax.pytorch_ignite:INFO] Total training time: 0.19[s]
2026/07/25 00:13:16 INFO mlflow.system_metrics.system_metrics_monitor: Stopping system metrics monitoring...
2026/07/25 00:13:16 INFO mlflow.system_metrics.system_metrics_monitor: Successfully terminated system metrics monitoring!
[2026-07-25 00:13:16,561 hyrax.verbs.train:INFO] Finished Training
Printing the trace#
Printing trace_result gives a high-level summary of all pipeline stages and the function calls captured within them. Each entry shows the function name, its input and output names, the shapes / hashes of any tensors, and how long the call took.
[6]:
print(trace_result)
Trace Stages {
dataset_getter: [
data__get_image(index) -> image duration=0.00842 ms
inputs:
index = 34
outputs:
image = <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
data__get_object_id(index) -> object_id duration=0.00571 ms
inputs:
index = 34
outputs:
object_id = '57'
data__get_image(index) -> image duration=0.00286 ms
inputs:
index = 41
outputs:
image = <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
data__get_object_id(index) -> object_id duration=0.00303 ms
inputs:
index = 41
outputs:
object_id = '64'
]
resolve_data: [
DataProvider__resolve_data(index) -> data_dict duration=0.206 ms
inputs:
index = 34
outputs:
data_dict = {
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
object_id: '57'
}
DataProvider__resolve_data(index) -> data_dict duration=0.0769 ms
inputs:
index = 41
outputs:
data_dict = {
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
object_id: '64'
}
]
field_level_collation: []
collate: [
DataProvider__collate(batch_dicts) -> batch_dict duration=0.209 ms
inputs:
batch_dicts = <list len=2> [
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
object_id: '57'
}
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
object_id: '64'
}
]
outputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
data__collate(samples) -> batch_dict duration=0.0627 ms
inputs:
samples = <list len=2> [
{
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
{
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
]
outputs:
batch_dict = {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
DataProvider__handle_nans(batch_dict) -> batch_dict_no_nan duration=0.105 ms
inputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
outputs:
batch_dict_no_nan = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
]
prepare_inputs: [
HyraxAutoencoder__prepare_inputs(batch_dict) -> batch_ndarray duration=0.00956 ms
inputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
outputs:
batch_ndarray = <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
]
evaluation: [
HyraxAutoencoder__train_batch(batch) -> loss_dict duration=156 ms
inputs:
batch = <torch.Tensor shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
outputs:
loss_dict = {
loss: 201.246337890625
}
]
}
The output lists five stages in pipeline order:
Stage |
What is captured |
|---|---|
|
Individual |
|
|
|
Individual |
|
|
|
Model’s |
|
Model functions such as |
The table above is printed as text from the TraceResult.__str__ implementation so that the notebook cell output and a plain print() call look identical.
Exploring stages#
You can access any stage using either attribute access or dictionary-style access — both are equivalent. Tab completion in a notebook environment will suggest the valid stage names.
[7]:
# Attribute-style access
collate_stage = trace_result.collate
print(collate_stage)
[
DataProvider__collate(batch_dicts) -> batch_dict duration=0.209 ms
inputs:
batch_dicts = <list len=2> [
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
object_id: '57'
}
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
object_id: '64'
}
]
outputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
data__collate(samples) -> batch_dict duration=0.0627 ms
inputs:
samples = <list len=2> [
{
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
{
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
]
outputs:
batch_dict = {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
DataProvider__handle_nans(batch_dict) -> batch_dict_no_nan duration=0.105 ms
inputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
outputs:
batch_dict_no_nan = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
]
[8]:
# Dictionary-style access — identical result
evaluation_stage = trace_result["evaluation"]
print(evaluation_stage)
[
HyraxAutoencoder__train_batch(batch) -> loss_dict duration=156 ms
inputs:
batch = <torch.Tensor shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
outputs:
loss_dict = {
loss: 201.246337890625
}
]
Each stage is a TraceStage — a list of TraceCall records in the order they were executed. You can ask how many calls were captured:
[9]:
print(f"resolve_data calls : {len(trace_result.resolve_data)}")
print(f"collate calls : {len(trace_result.collate)}")
print(f"evaluation calls : {len(trace_result.evaluation)}")
resolve_data calls : 2
collate calls : 3
evaluation calls : 1
Exploring individual function calls#
Within a stage you can index calls by number (call order) or by function name. A TraceCall captures the function’s argument values and return value along with timing information.
[10]:
# Get the first call in the collate stage
first_collate_call = trace_result.collate[0]
print(first_collate_call)
DataProvider__collate(batch_dicts) -> batch_dict duration=0.209 ms
inputs:
batch_dicts = <list len=2> [
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
object_id: '57'
}
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=64329361955749888 device=cpu>
}
object_id: '64'
}
]
outputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=5319329879563823638 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=33984219176763392 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
[11]:
# Access the captured batch tensor directly — attribute and dict access both work
batch_dict = first_collate_call.batch_dict
print(type(batch_dict))
print(batch_dict)
<class 'dict'>
{'object_id': array(['57', '64'], dtype='<U2'), 'data': {'image': array([[[[0.6505175 , 0.9308384 , 0.93128186, ..., 0.31562626,
0.74545175, 0.02360094],
[0.40714264, 0.88898325, 0.07460809, ..., 0.14583355,
0.3229012 , 0.8758908 ],
[0.97890604, 0.05482215, 0.73233247, ..., 0.27087146,
0.32079786, 0.9214196 ],
...,
[0.6484479 , 0.33928013, 0.6261745 , ..., 0.8033044 ,
0.5425749 , 0.7009634 ],
[0.6470884 , 0.8497618 , 0.00620961, ..., 0.9683715 ,
0.5470504 , 0.18466109],
[0.63445663, 0.7730637 , 0.8384784 , ..., 0.5936375 ,
0.0041042 , 0.34962457]]],
[[[0.08420962, 0.14473194, 0.15727389, ..., 0.28908664,
0.978508 , 0.942041 ],
[0.14625663, 0.55386037, 0.9403946 , ..., 0.13105696,
0.31474078, 0.7010606 ],
[0.50390685, 0.52695537, 0.04147851, ..., 0.19719446,
0.69597703, 0.4349116 ],
...,
[0.6595705 , 0.72374916, 0.24717867, ..., 0.38180226,
0.15887958, 0.6463863 ],
[0.35546678, 0.9187956 , 0.57680875, ..., 0.7205259 ,
0.15929818, 0.58029395],
[0.44163013, 0.17446673, 0.45191377, ..., 0.691111 ,
0.46119612, 0.78514135]]]], shape=(2, 1, 32, 32), dtype=float32), 'mask': array([[[[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
...,
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False]]],
[[[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
...,
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False],
[False, False, False, ..., False, False, False]]]],
shape=(2, 1, 32, 32))}}
[12]:
# Get a list of all calls to a particular function by providing the display name
# (visible from the print output above)
all_resolve_calls = trace_result.resolve_data["DataProvider__resolve_data"]
print(f"Number of resolve_data calls: {len(all_resolve_calls)}")
print(all_resolve_calls[0])
Number of resolve_data calls: 2
DataProvider__resolve_data(index) -> data_dict duration=0.206 ms
inputs:
index = 34
outputs:
data_dict = {
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=43970850289876992 device=cpu>
}
object_id: '57'
}
Tracing other verbs#
The trace=N keyword works the same way for infer and test:
[13]:
infer_trace = h.infer(trace=2)
print(infer_trace)
[2026-07-25 00:13:16,662 hyrax.trace:WARNING] Starting Trace
[2026-07-25 00:13:16,663 hyrax.trace:WARNING] Trace mode enabled, will only run a single batch of length 2
[2026-07-25 00:13:16,723 hyrax.models.model_registry:INFO] Setting model's self.optimizer from config: torch.optim.SGD with arguments: {'lr': 0.01, 'momentum': 0.9}.
[2026-07-25 00:13:16,724 hyrax.models.model_registry:INFO] Setting model's self.criterion from config: torch.nn.CrossEntropyLoss with default arguments.
[2026-07-25 00:13:16,725 hyrax.models.model_registry:INFO] Setting model's self.scheduler from config: torch.optim.lr_scheduler.ExponentialLR
with arguments: {'gamma': 1}.
[2026-07-25 00:13:16,726 hyrax.verbs.infer:INFO] Inference model: HyraxAutoencoder
[2026-07-25 00:13:16,727 hyrax.verbs.infer:INFO] Inference dataset(s):
{'infer': Name: data (primary dataset)
Dataset class: HyraxRandomDataset
Data location: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/trace_data
Selected items: 50
Primary ID field: object_id
Requested fields: image
}
2026-07-25 00:13:16,728 ignite.distributed.auto.auto_dataloader INFO: Use data loader kwargs for dataset '<torch.utils.data.da':
{'sampler': None, 'batch_size': 2, 'collate_fn': <bound method CollationMixin.collate of Name: data (primary dataset)
Dataset class: HyraxRandomDataset
Data location: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/trace_data
Selected items: 50
Primary ID field: object_id
Requested fields: image
>, 'pin_memory': False}
[2026-07-25 00:13:16,737 hyrax.models.model_utils:INFO] Updated config['infer']['model_weights_file'] to: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/results/20260725-001313-train-9k8H/example_model.pth
[2026-07-25 00:13:16,740 hyrax.verbs.infer:INFO] Saving inference results at: /home/docs/checkouts/readthedocs.org/user_builds/hyrax/checkouts/latest/docs/pre_executed/results/20260725-001316-infer-myso
[2026-07-25 00:13:16,759 hyrax.pytorch_ignite:INFO] Total evaluation time: 0.01[s]
[2026-07-25 00:13:16,760 hyrax.datasets.result_dataset:INFO] Optimizing Lance table after 1 batches
[2026-07-25 00:13:16,767 hyrax.datasets.result_dataset:INFO] Lance table optimization complete
[2026-07-25 00:13:16,772 hyrax.verbs.infer:INFO] Inference Complete.
Trace Stages {
dataset_getter: [
data__get_image(index) -> image duration=0.00401 ms
inputs:
index = 0
outputs:
image = <numpy.ndarray shape=(1, 32, 32) hash=26660822658842624 device=cpu>
data__get_object_id(index) -> object_id duration=0.00403 ms
inputs:
index = 0
outputs:
object_id = '23'
data__get_image(index) -> image duration=0.00332 ms
inputs:
index = 1
outputs:
image = <numpy.ndarray shape=(1, 32, 32) hash=7316936887107584 device=cpu>
data__get_object_id(index) -> object_id duration=0.0025 ms
inputs:
index = 1
outputs:
object_id = '24'
]
resolve_data: [
DataProvider__resolve_data(index) -> data_dict duration=0.135 ms
inputs:
index = 0
outputs:
data_dict = {
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=26660822658842624 device=cpu>
}
object_id: '23'
}
DataProvider__resolve_data(index) -> data_dict duration=0.0686 ms
inputs:
index = 1
outputs:
data_dict = {
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=7316936887107584 device=cpu>
}
object_id: '24'
}
]
field_level_collation: []
collate: [
DataProvider__collate(batch_dicts) -> batch_dict duration=0.179 ms
inputs:
batch_dicts = <list len=2> [
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=26660822658842624 device=cpu>
}
object_id: '23'
}
{
data: {
image: <numpy.ndarray shape=(1, 32, 32) hash=7316936887107584 device=cpu>
}
object_id: '24'
}
]
outputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=8124516871160982280 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
data__collate(samples) -> batch_dict duration=0.0516 ms
inputs:
samples = <list len=2> [
{
image: <numpy.ndarray shape=(1, 32, 32) hash=26660822658842624 device=cpu>
}
{
image: <numpy.ndarray shape=(1, 32, 32) hash=7316936887107584 device=cpu>
}
]
outputs:
batch_dict = {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
DataProvider__handle_nans(batch_dict) -> batch_dict_no_nan duration=0.091 ms
inputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=8124516871160982280 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
outputs:
batch_dict_no_nan = {
object_id: <numpy.ndarray shape=(2,) hash=8124516871160982280 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
]
prepare_inputs: [
HyraxAutoencoder_inst_prepare_inputs(batch_dict) -> batch_ndarray duration=0.00676 ms
inputs:
batch_dict = {
object_id: <numpy.ndarray shape=(2,) hash=8124516871160982280 device=cpu>
data: {
image: <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
mask: <numpy.ndarray shape=(2, 1, 32, 32) hash=0 device=cpu>
}
}
outputs:
batch_ndarray = <numpy.ndarray shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
]
evaluation: [
HyraxAutoencoder__infer_batch(batch) -> batch_results duration=1.84 ms
inputs:
batch = <torch.Tensor shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
outputs:
batch_results = <torch.Tensor shape=(2, 64) hash=44650769382637568 device=cpu>
HyraxAutoencoder__forward(batch) -> batch_results duration=1.82 ms
inputs:
batch = <torch.Tensor shape=(2, 1, 32, 32) hash=20065364041793536 device=cpu>
outputs:
batch_results = <torch.Tensor shape=(2, 64) hash=44650769382637568 device=cpu>
]
}
Instrumenting custom models and datasets#
If you have written a custom model or dataset class you can opt specific methods into trace capture using the @trace_model_func and @trace_dataset_func decorators.
from hyrax.trace import trace_model_func, trace_dataset_func
class MyModel(nn.Module):
@trace_model_func
def my_custom_forward(self, batch):
# This call will appear in the 'evaluation' stage of the TraceResult
...
class MyDataset(HyraxDataset):
@trace_dataset_func
def get_image(self, index):
# This call will appear in the 'dataset_getter' stage of the TraceResult
...
The decorators add a small overhead to every call, so they are intended for use during development and debugging rather than in production. Remove them (or use them selectively) once you are satisfied with how your data is flowing.