You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by GitBox <gi...@apache.org> on 2026/04/20 18:17:53 UTC
[GH] (tvm-ffi/feat-map-dataclass-to-tuple): Workflow run "CI" is working again!
The GitHub Actions job "CI" on tvm-ffi.git/feat-map-dataclass-to-tuple has succeeded.
Run started by GitHub user tqchen (triggered by tqchen).
Head commit for run:
fd84816faa935de76e37d765327064c620f134e3 / tqchen <ti...@gmail.com>
[FEAT] Optimize map_dataclass_to_tuple with JIT-compiled unpack
Replace `dataclasses.astuple` in `map_dataclass_to_tuple` with
`unpack_dataclass_to_tuple`, a JIT-compiled per-class unpacker that
brings 5-11x speedup and does not deep-copy leaf values.
This is important when dataclass fields contain tensor objects or other
large resources -- leaf values are passed through by reference, not
duplicated, which is needed for correct argument passing behavior.
## Design
`unpack_dataclass_to_tuple(x)` recursively converts dataclass instances
to tuples via JIT-compiled inline attribute access:
- `_extract_dataclass_to_tuple_schema(cls)` -- inspect type annotations
- `_validate_dataclass_to_tuple_schema(schema)` -- codegen security
- `_compile_dataclass_to_tuple_schema(prefix, schema)` -- inline code
Cached per-thread (TLS) for thread safety. Conservative field
classification: only marks as leaf when certain (known primitives,
containers of known primitives). Unknown types use dynamic dispatch.
## Performance (vs dataclasses.astuple)
| Case | unpack | astuple | speedup |
|-------------------|--------|---------|---------|
| Config (2 flat) | 144 ns | 769 ns | 5.3x |
| Nested (int + dc) | 152 ns | 1386 ns | 9.1x |
| Wide (5 flat) | 170 ns | 1268 ns | 7.5x |
| Deep (2 levels) | 200 ns | 2305 ns | 11.5x |
| WithAny (dynamic) | 254 ns | 1644 ns | 6.5x |
Report URL: https://github.com/apache/tvm-ffi/actions/runs/24682345929
With regards,
GitHub Actions via GitBox
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org