Skip to content

Effective dynamic input size compilation #430

Answered by avital
machineko asked this question in General
Discussion options

You must be logged in to vote

Yes you're right, this is a fundamental design property of XLA, which assumes completely known shapes (and uses that information for compile-time optimizations).

The typical pattern we use is dynamic bucketing based where sequences within certain length ranges are batched together. For example here: https://github.com/google/flax/blob/master/examples/wmt/input_pipeline.py#L204 (in this case we're taking advantage of tf.data.experimental.bucket_by_sequence_length, which is not ideal.

We'd love to find long term flexible solutions, but they also need to be fast, so it's not clear one can implement this in pure Python and support very large models.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by machineko
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants