MCPcopy Create free account

hub / github.com/google-research/timesfm / functions

Functions402 in github.com/google-research/timesfm

Methodforward
(self, inputs: torch.Tensor)
src/timesfm/torch/normalization.py:35
Methodforward
( self, inputs: torch.Tensor, masks: torch.Tensor, decode_caches: list[util.DecodeCache] | Non
src/timesfm/timesfm_2p5/timesfm_2p5_torch.py:86
Methodforward
(self, x)
v1/src/timesfm/pytorch_patched_decoder.py:264
Methodforward
(self, x)
v1/src/timesfm/pytorch_patched_decoder.py:288
Methodforward
(self, x, paddings=None)
v1/src/timesfm/pytorch_patched_decoder.py:310
Methodforward
( self, hidden_states: torch.Tensor, mask: torch.Tensor, kv_write_indices: torch.Tenso
v1/src/timesfm/pytorch_patched_decoder.py:360
Methodforward
( self, hidden_states: torch.Tensor, mask: torch.Tensor, paddings: torch.Tensor,
v1/src/timesfm/pytorch_patched_decoder.py:443
Methodforward
( self, hidden_states: torch.Tensor, paddings: torch.Tensor, kv_write_indices: torch.T
v1/src/timesfm/pytorch_patched_decoder.py:495
Methodforward
Generates a Tensor of sinusoids with different frequencies. Args: seq_length: an optional Python int defining the output sequence length.
v1/src/timesfm/pytorch_patched_decoder.py:540
Methodforward
( self, input_ts: torch.Tensor, input_padding: torch.LongTensor, freq: torch.Tensor,
v1/src/timesfm/pytorch_patched_decoder.py:694
Methodicon
(self)
timesfm-forecasting/scripts/check_system.py:82
Functionload_adapter_checkpoint
Loads an adapter checkpoint and merges it with the original model weights. Args: model (TimesFm): The model to update. adapt
v1/src/adapter/utils.py:101
Methodload_checkpoint
Loads a PyTorch TimesFM model from a checkpoint.
src/timesfm/timesfm_2p5/timesfm_2p5_torch.py:79
Methodload_checkpoint
Loads a TimesFM model from a checkpoint.
src/timesfm/timesfm_2p5/timesfm_2p5_base.py:147
Methodload_from_checkpoint
Loads a checkpoint and compiles the decoder.
v1/src/timesfm/timesfm_torch.py:52
Methodlog_metrics
Log metrics to the specified backend. Args: metrics: Dictionary containing metric names and values. step: Optional step n
v1/src/finetuning/finetuning_torch.py:29
Functionmain
Main function that selects and runs the appropriate training mode.
v1/src/finetuning/finetuning_example.py:372
Functionmoving_average
Calculates the moving average using NumPy's convolution function.
v1/src/timesfm/timesfm_base.py:44
Methodno_mask
(t)
tests/test_torch_utils.py:76
Functionnormalize
(batch)
src/timesfm/utils/xreg_lib.py:61
Functionparallel_transform
(inp)
v1/experiments/extended_benchmarks/utils.py:36
Methodpassed
(self)
timesfm-forecasting/scripts/check_system.py:99
Functionrenormalize
(batch, stats)
src/timesfm/utils/xreg_lib.py:68
Methodsave_results
( self, fcst_df: pd.DataFrame, total_time: float, model_name: str )
v1/experiments/extended_benchmarks/utils.py:180
Functionscan_along_axis
Scans along an axis.
src/timesfm/flax/util.py:80
Methodsetup
(self)
v1/src/timesfm/patched_decoder.py:107
Methodsetup
Construct the model.
v1/src/timesfm/patched_decoder.py:242
Methodsetup
(self)
v1/src/timesfm/patched_decoder.py:493
Methodsetup
(self)
v1/src/adapter/lora_layers.py:108
Methodsetup
(self)
v1/src/adapter/lora_layers.py:144
Methodsetup
(self)
v1/src/adapter/dora_layers.py:126
Methodsetup
(self)
v1/src/adapter/dora_layers.py:171
Functionsetup_process
Setup process function with optimized CUDA handling.
v1/src/finetuning/finetuning_example.py:300
Functionshift_row
(carry, x)
v1/src/timesfm/patched_decoder.py:71
Methodswish_block
A small residual block with SiLU/Swish activation (matches TimesFM).
tests/test_torch_layers.py:41
Methodtest_3d_input_supported
The layer must handle (batch, seq, features) tensors.
tests/test_torch_layers.py:251
Methodtest_activation_accepts_all_valid_literals
All three activation modes must be constructable without error.
tests/test_configs.py:118
Methodtest_all_activations_produce_valid_output
All supported activations must produce finite, non-NaN output.
tests/test_torch_layers.py:93
Methodtest_all_masked_yields_zero_stats
When every element is masked, the function must return zeros rather than NaN or raise an error. This happens when an input series is entirely
tests/test_torch_utils.py:119
Methodtest_all_nans_returns_full_array
When every element is NaN, ``np.argmax`` on an all-False mask returns 0 — so the implementation returns the original array, not an empty one.
tests/test_base_utils.py:72
Methodtest_batched_computation_independent
Each sample in the batch must be computed independently. Cross-sample leakage would corrupt multi-series forecasting.
tests/test_torch_utils.py:137
Methodtest_constant_input_yields_zero_sigma
A constant series has zero variance — sigma must be exactly 0. This is important because ``revin`` guards against division-by-zero using ``_T
tests/test_torch_utils.py:163
Methodtest_defaults_match_safe_inference_settings
Default config must be conservative: no normalization, no fancy heads. These defaults are what users get when they call ``ForecastConfig()``
tests/test_configs.py:45
Methodtest_df
(self)
v1/experiments/extended_benchmarks/utils.py:169
Methodtest_equality_is_structural
Two configs with identical fields must be equal (value semantics).
tests/test_configs.py:86
Methodtest_extrapolates_leading_nans
Leading NaN values are filled with the first valid value. In practice ``strip_leading_nans`` runs first, but the function must still be robus
tests/test_base_utils.py:128
Methodtest_extrapolates_trailing_nans
Trailing NaN values are filled via ``np.interp`` which holds the last known value (nearest-neighbor extrapolation).
tests/test_base_utils.py:120
Methodtest_flax_model_init_kwargs
Verifies that Flax model wrapper constructor accepts arbitrary kwargs.
tests/test_model_loading.py:90
Methodtest_forward_produces_correct_normalization
After forward normalization: (x - mu) / sigma.
tests/test_torch_utils.py:206
Methodtest_forward_then_reverse_is_identity
normalize → denormalize must reconstruct the original tensor. This is the fundamental invariant of reversible normalization: the model operat
tests/test_torch_utils.py:189
Methodtest_fourier_components_bounded
cos and sin outputs are bounded in [-1, 1]; sign outputs are bounded in {-1, 0, 1}. The total Fourier part (before residual) is thus bounded.
tests/test_torch_layers.py:235
Methodtest_frozen_prevents_mutation
Configs are frozen dataclasses — mutating them must raise. This is critical because ``compile()`` captures the config object and the compiled
tests/test_configs.py:63
Methodtest_frozen_prevents_mutation
(self)
tests/test_configs.py:107
Methodtest_frozen_prevents_mutation
(self)
tests/test_configs.py:188
Methodtest_gradient_flows_through_both_paths
Gradients must reach both the main path and the residual path. Dead gradients on either path would prevent the layer from learning.
tests/test_torch_layers.py:121
Methodtest_incremental_accumulation_matches_full_computation
Accumulating two batches incrementally must yield the same result as computing statistics over all values at once. This is the defining prope
tests/test_torch_utils.py:66
Methodtest_inequality_on_any_field_difference
A single differing field must break equality.
tests/test_configs.py:92
Methodtest_interpolates_multiple_interior_nans
Multiple consecutive interior NaN values are interpolated.
tests/test_base_utils.py:114
Methodtest_interpolates_single_interior_nan
A single interior NaN is linearly interpolated from neighbors.
tests/test_base_utils.py:108
Methodtest_interpolation_is_monotone_for_monotone_input
If the known values are strictly increasing, the interpolated result must also be non-decreasing — a basic sanity check on the interpolation d
tests/test_base_utils.py:154
Methodtest_invalid_activation_raises
Unsupported activation must raise ``ValueError`` immediately — fail fast rather than producing garbage at inference time.
tests/test_torch_layers.py:108
Methodtest_is_mutable
DecodeCache is *not* frozen — the attention loop mutates ``next_index`` and ``num_masked`` in-place during autoregressive decoding.
tests/test_torch_utils.py:312
Methodtest_key_value_shape_consistency
Key and value tensors must have identical shapes — they are indexed in parallel during attention computation.
tests/test_torch_utils.py:325
Methodtest_masked_elements_excluded_from_statistics
Masked positions must be completely ignored — as if they don't exist. In TimesFM, leading padding is masked. If mask handling is broken, the
tests/test_torch_utils.py:99
Methodtest_model_dims_must_be_divisible_by_num_heads
The model instantiation will fail if this invariant is broken. We verify the config at least *carries* the right values that the TimesFM 2.5
tests/test_configs.py:139
Methodtest_near_zero_sigma_guarded_by_tolerance
Sigma values just below ``_TOLERANCE`` must trigger the guard.
tests/test_torch_utils.py:244
Methodtest_negative_values_handled_correctly
RevIN must work for series with negative values (e.g. temperature, financial returns). ``infer_is_positive`` is a separate downstream flag and
tests/test_torch_utils.py:289
Methodtest_no_leading_nan_with_internal_nans
If the first element is valid, nothing is stripped regardless of internal NaNs.
tests/test_base_utils.py:59
Methodtest_no_nan_on_zero_input
A zero-valued input must not cause NaN (epsilon prevents div-by-0).
tests/test_torch_layers.py:192
Methodtest_no_nans_returns_identical
Without NaN values the array is returned as-is (fast path).
tests/test_base_utils.py:102
Methodtest_no_nans_returns_unchanged
An array without NaN values must pass through unmodified.
tests/test_base_utils.py:40
Methodtest_output_dims_not_multiple_of_4_raises
The four Fourier components (cos, sin, sq_wave_1, sq_wave_2) require ``output_dims`` to be divisible by 4.
tests/test_torch_layers.py:223
Methodtest_output_has_no_nans
After interpolation, no NaN values should remain.
tests/test_base_utils.py:138
Methodtest_output_shape
Output must have the config's ``output_dims`` as the last dimension, regardless of input batch shape.
tests/test_torch_layers.py:52
Methodtest_output_shape
Output dims must be exactly ``config.output_dims``.
tests/test_torch_layers.py:210
Methodtest_output_shape_3d
The block must handle (batch, seq, features) inputs — the layout used when processing patched time series.
tests/test_torch_layers.py:59
Methodtest_output_shape_preserved
RMSNorm must not change the tensor shape.
tests/test_torch_layers.py:153
Methodtest_preserves_dtype
Output dtype must match input dtype (float32 stays float32).
tests/test_base_utils.py:87
Methodtest_preserves_non_nan_values
Non-NaN values in the original array must never be modified.
tests/test_base_utils.py:144
Methodtest_replace_creates_independent_copy
``dataclasses.replace`` must yield a new object with updated fields. The compile path uses ``replace`` to adjust context/horizon to valid mul
tests/test_configs.py:73
Methodtest_residual_connection_nonzero
The residual connection must contribute to the output. We verify this by comparing the output when the hidden path is zeroed out vs. the full
tests/test_torch_layers.py:66
Methodtest_reverse_produces_correct_denormalization
After reverse: x * sigma + mu.
tests/test_torch_utils.py:217
Methodtest_roundtrip_with_batched_3d_input
RevIN must broadcast correctly for (batch, patches, patch_len) tensors — the actual shape used during patched decoding.
tests/test_torch_utils.py:257
Methodtest_roundtrip_with_batched_4d_input
RevIN must broadcast correctly for (batch, patches, patch_len, q) tensors — the shape used for quantile outputs. In the actual decode path, m
tests/test_torch_utils.py:270
Methodtest_single_batch_matches_numpy
A single update with no mask must match numpy's mean and std. This is the most basic correctness check: feed all values at once and compare a
tests/test_torch_utils.py:43
Methodtest_single_leading_nan
Edge case: exactly one leading NaN.
tests/test_base_utils.py:53
Methodtest_single_non_nan_fills_all_gaps
With only one valid value, every NaN is replaced by that value (np.interp clamps to the single known point).
tests/test_base_utils.py:163
Methodtest_single_valid_element
A single non-NaN element must be returned as-is.
tests/test_base_utils.py:66
Methodtest_stacked_config_composes_correctly
StackedTransformersConfig must wrap a TransformerConfig cleanly.
tests/test_configs.py:160
Methodtest_strips_leading_nans_only
Leading NaNs are removed; NaNs embedded in the middle are kept.
tests/test_base_utils.py:46
Functiontest_timesfm_forecast_on_df
( context_length: int, prediction_length: int, freq: str, )
v1/tests/test_timesfm.py:48
Methodtest_torch_compile_wraps_forward
Verifies that torch_compile=True compiles model.forward, not a no-op.
tests/test_model_loading.py:63
Methodtest_torch_load_checkpoint_and_from_pretrained_local
Verifies that PyTorch load_checkpoint and from_pretrained work locally.
tests/test_model_loading.py:28
Methodtest_torch_no_compile_leaves_forward_unchanged
Verifies that torch_compile=False leaves model.forward as a plain method.
tests/test_model_loading.py:77
Functiontest_train_gen_respects_batch_size_when_permute_is_false
(tmp_path: Path)
v1/tests/test_data_loader.py:9
Methodtest_unit_scale_preserves_rms_magnitude
With scale = 1, output should have approximately unit RMS along the feature dimension — that's the point of RMS normalization.
tests/test_torch_layers.py:173
Methodtest_zero_scale_produces_zeros
With default scale (initialized to zeros), output must be all zeros. This is a critical initialization property: at init, each transformer la
tests/test_torch_layers.py:160
Methodtest_zero_sigma_does_not_produce_nan
When sigma < tolerance, the function substitutes 1.0 to avoid division by zero. This occurs for constant-valued input series. NaN propagation
tests/test_torch_utils.py:228
Methodtrain_df
(self)
v1/experiments/extended_benchmarks/utils.py:164
Functiontrain_step
(states, prng_key, inputs)
v1/peft/finetune.py:305
← previousnext →301–400 of 402, ranked by callers