foreblocks 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- foreblocks-0.1.0/PKG-INFO +484 -0
- foreblocks-0.1.0/README.md +458 -0
- foreblocks-0.1.0/examples/rodrigo.py +351 -0
- foreblocks-0.1.0/flash-attention/benchmarks/benchmark_alibi.py +275 -0
- foreblocks-0.1.0/flash-attention/benchmarks/benchmark_causal.py +225 -0
- foreblocks-0.1.0/flash-attention/benchmarks/benchmark_flash_attention.py +180 -0
- foreblocks-0.1.0/flash-attention/benchmarks/benchmark_gemm.py +47 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/docs/conf.py +50 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/cmake_config.py +5 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/cpp_symbol_map.py +128 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/ops/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/ops/fmha_bwd.py +902 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/ops/fmha_fwd.py +574 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/ops/fmha_fwd_appendkv.py +359 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/codegen/ops/fmha_fwd_splitkv.py +855 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/01_fmha/generate.py +136 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/02_layernorm2d/generate.py +730 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/10_rmsnorm2d/generate.py +715 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/example/ck_tile/remod.py +21 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/include/ck_tile/remod.py +93 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/batched_universal_gemm/gen_instances.py +149 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/batched_universal_gemm/op.py +99 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/grouped_conv_fwd/gen_instances.py +165 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/grouped_conv_fwd/op.py +93 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/universal_gemm/gen_instances.py +572 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/universal_gemm/op.py +99 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/ck4inductor/util.py +10 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/python/test/test_gen_instances.py +46 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/script/convert_miopen_driver_to_profiler.py +413 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/script/process_perf_data.py +382 -0
- foreblocks-0.1.0/flash-attention/csrc/composable_kernel/tile_engine/ops/gemm/gemm_instance_builder.py +654 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/conv2d.py +177 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/customizable/conv2d.py +331 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/customizable/gemm.py +331 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/customizable/gemm_grouped.py +298 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/gemm.py +153 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/40_cutlass_py/gemm_grouped.py +172 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/41_fused_multi_head_attention/fmha_backward_test.py +232 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/41_fused_multi_head_attention/piped_subprocess.py +144 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_all_code.py +129 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_cmake.py +131 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_customized_epilogue.py +120 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_device.py +469 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_ir.py +249 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_kernel.py +476 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_sample.py +232 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_threadblock.py +1013 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_turing_and_volta.py +456 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/gen_verify.py +92 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/helper.py +135 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/examples/44_multi_gemm_ir_and_codegen/ir_gen/replace_fix_impl_header.py +67 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/__init__.py +190 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/__init__.py +48 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/arguments.py +133 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/c_types.py +622 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/compiler.py +459 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/conv2d_operation.py +698 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/epilogue.py +541 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/__init__.py +34 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/__init__.py +36 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/emitter_base.py +158 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/sm80_emitter.py +47 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/sm80_nodes.py +258 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/sm90_emitter.py +98 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/backend/sm90_nodes.py +329 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/epilogue.py +167 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/frontend/__init__.py +33 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/frontend/frontend_base.py +262 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/frontend/python_ast.py +187 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/__init__.py +53 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/compute_nodes.py +91 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/dag_ir.py +236 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/layout_algorithm.py +324 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/layout_nodes.py +336 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/load_nodes.py +294 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/node.py +293 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/store_nodes.py +277 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/ir/tensor.py +130 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/__init__.py +42 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/graph_drawer.py +142 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_argument_type.py +116 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_dag_2_tree.py +147 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_fix_element_d.py +64 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_get_impl.py +90 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_layout_elimination.py +217 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_manager.py +164 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_no_op_elimination.py +53 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_preprocess_red.py +97 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/pass_shape_type_propagation.py +59 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/smem_size_calculator.py +204 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/evt/passes/util.py +43 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/frontend.py +107 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/gemm_operation.py +2138 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/library.py +488 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/memory_manager.py +120 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/operation.py +133 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/reduction_operation.py +452 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/type_hint.py +35 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/utils/__init__.py +33 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/backend/utils/device.py +123 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/emit/__init__.py +33 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/emit/common.py +267 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/emit/pytorch.py +936 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/epilogue/__init__.py +55 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/epilogue/epilogue.py +158 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/epilogue/evt_ops.py +92 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/library_defaults.py +580 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/op/__init__.py +36 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/op/conv.py +983 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/op/gemm.py +715 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/op/gemm_grouped.py +264 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/op/op.py +430 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/shape.py +184 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/swizzle.py +65 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/utils/__init__.py +41 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/utils/check.py +269 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/utils/datatypes.py +362 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass/utils/profiler.py +185 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/__init__.py +63 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/conv2d_operation.py +621 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/conv3d_operation.py +482 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/conv3x_emitter.py +250 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/emit_kernel_listing.py +880 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/gemm_operation.py +1520 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/generator.py +10851 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/library.py +1317 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/manifest.py +870 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/rank_2k_operation.py +438 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/rank_k_operation.py +427 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/sm90_shapes.py +212 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/sm90_utils.py +703 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/symm_operation.py +440 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/cutlass_library/trmm_operation.py +447 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/docs_src/source/conf.py +132 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/pycute/__init__.py +36 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/pycute/int_tuple.py +225 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/pycute/layout.py +367 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/pycute/swizzle.py +129 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/pycute/typing.py +42 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/setup_cutlass.py +74 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/setup_library.py +46 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/python/setup_pycute.py +46 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/conv2d/conv2d_problem_sizes.py +661 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/conv2d/conv2d_sm80.py +146 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/conv2d/conv2d_test_utils.py +428 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/conv2d/run_all_tests.py +44 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/emit/pytorch.py +309 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/evt_compute_sm80_90.py +122 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/evt_layout_sm80_90.py +173 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/evt_load_sm80_90.py +142 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/evt_mixed_sm80_90.py +274 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/evt_store_sm80_90.py +155 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/run_all_tests.py +44 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/evt/utils/evt_testbed.py +230 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_batched.py +134 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f16_sm80.py +128 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f16_sm90.py +146 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f32_sm80.py +104 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f64_sm80.py +103 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f64_sm90.py +71 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_f8_sm90.py +112 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_mixed_sm80.py +75 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_s8_sm80.py +103 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_s8_sm90.py +98 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/gemm_testbed.py +423 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/run_all_tests.py +44 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/gemm/utils.py +260 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/installation.py +57 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/interface/conv2d_interface.py +284 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/interface/evt_interface.py +254 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/interface/gemm_interface.py +351 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/cutlass/interface/utils.py +69 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/run_all_tests.py +75 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_coalesce.py +95 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_complement.py +92 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_composition.py +213 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_int_tuple.py +80 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_left_inverse.py +87 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_right_inverse.py +96 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/python/pycute/test_typing.py +59 -0
- foreblocks-0.1.0/flash-attention/csrc/cutlass/test/unit/gemm/device/simt_sm50.py +341 -0
- foreblocks-0.1.0/flash-attention/csrc/flash_attn/src/generate_kernels.py +110 -0
- foreblocks-0.1.0/flash-attention/csrc/ft_attention/setup.py +153 -0
- foreblocks-0.1.0/flash-attention/csrc/fused_dense_lib/setup.py +42 -0
- foreblocks-0.1.0/flash-attention/csrc/fused_softmax/setup.py +50 -0
- foreblocks-0.1.0/flash-attention/csrc/layer_norm/setup.py +205 -0
- foreblocks-0.1.0/flash-attention/csrc/rotary/setup.py +126 -0
- foreblocks-0.1.0/flash-attention/csrc/xentropy/setup.py +139 -0
- foreblocks-0.1.0/flash-attention/flash_attn/__init__.py +11 -0
- foreblocks-0.1.0/flash-attention/flash_attn/bert_padding.py +218 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_interface.py +1606 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton.py +1160 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bench.py +1223 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bwd_prefill.py +814 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bwd_prefill_fused.py +3266 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bwd_prefill_onekernel.py +1091 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bwd_prefill_split.py +1354 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/bwd_ref.py +478 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/fp8.py +716 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/fwd_decode.py +814 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/fwd_prefill.py +648 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/fwd_ref.py +387 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/interface_fa.py +798 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/test.py +932 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/train.py +403 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_amd/utils.py +776 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_attn_triton_og.py +365 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_blocksparse_attention.py +197 -0
- foreblocks-0.1.0/flash-attention/flash_attn/flash_blocksparse_attn_interface.py +200 -0
- foreblocks-0.1.0/flash-attention/flash_attn/fused_softmax.py +201 -0
- foreblocks-0.1.0/flash-attention/flash_attn/layers/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/layers/patch_embed.py +67 -0
- foreblocks-0.1.0/flash-attention/flash_attn/layers/rotary.py +482 -0
- foreblocks-0.1.0/flash-attention/flash_attn/losses/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/losses/cross_entropy.py +85 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/baichuan.py +151 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/bert.py +764 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/bigcode.py +233 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/btlm.py +102 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/falcon.py +143 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/gpt.py +1080 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/gpt_neox.py +124 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/gptj.py +109 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/llama.py +422 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/opt.py +116 -0
- foreblocks-0.1.0/flash-attention/flash_attn/models/vit.py +373 -0
- foreblocks-0.1.0/flash-attention/flash_attn/modules/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/modules/block.py +397 -0
- foreblocks-0.1.0/flash-attention/flash_attn/modules/embedding.py +216 -0
- foreblocks-0.1.0/flash-attention/flash_attn/modules/mha.py +993 -0
- foreblocks-0.1.0/flash-attention/flash_attn/modules/mlp.py +191 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/activations.py +135 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/fused_dense.py +688 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/layer_norm.py +800 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/rms_norm.py +174 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/__init__.py +1 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/cross_entropy.py +330 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/k_activations.py +162 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/layer_norm.py +1252 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/linear.py +594 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/mlp.py +149 -0
- foreblocks-0.1.0/flash-attention/flash_attn/ops/triton/rotary.py +185 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/benchmark.py +268 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/distributed.py +144 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/generation.py +740 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/library.py +66 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/pretrained.py +79 -0
- foreblocks-0.1.0/flash-attention/flash_attn/utils/torch.py +21 -0
- foreblocks-0.1.0/flash-attention/hopper/__init__.py +1 -0
- foreblocks-0.1.0/flash-attention/hopper/benchmark_attn.py +411 -0
- foreblocks-0.1.0/flash-attention/hopper/benchmark_flash_attention_fp8.py +353 -0
- foreblocks-0.1.0/flash-attention/hopper/benchmark_mla_decode.py +129 -0
- foreblocks-0.1.0/flash-attention/hopper/benchmark_split_kv.py +331 -0
- foreblocks-0.1.0/flash-attention/hopper/flash_attn_interface.py +834 -0
- foreblocks-0.1.0/flash-attention/hopper/generate_kernels.py +222 -0
- foreblocks-0.1.0/flash-attention/hopper/padding.py +53 -0
- foreblocks-0.1.0/flash-attention/hopper/setup.py +659 -0
- foreblocks-0.1.0/flash-attention/hopper/test_attn_kvcache.py +486 -0
- foreblocks-0.1.0/flash-attention/hopper/test_flash_attn.py +1130 -0
- foreblocks-0.1.0/flash-attention/hopper/test_kvcache.py +234 -0
- foreblocks-0.1.0/flash-attention/hopper/test_util.py +348 -0
- foreblocks-0.1.0/flash-attention/setup.py +561 -0
- foreblocks-0.1.0/flash-attention/tests/layers/test_rotary.py +134 -0
- foreblocks-0.1.0/flash-attention/tests/losses/test_cross_entropy.py +83 -0
- foreblocks-0.1.0/flash-attention/tests/losses/test_cross_entropy_parallel.py +104 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_baichuan.py +460 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_bert.py +324 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_bigcode.py +204 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_btlm.py +245 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_falcon.py +408 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_gpt.py +478 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_gpt_generation_parallel.py +172 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_gpt_neox.py +104 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_gpt_parallel.py +236 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_gptj.py +184 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_llama.py +633 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_opt.py +237 -0
- foreblocks-0.1.0/flash-attention/tests/models/test_vit.py +48 -0
- foreblocks-0.1.0/flash-attention/tests/modules/test_block_parallel.py +273 -0
- foreblocks-0.1.0/flash-attention/tests/modules/test_embedding_parallel.py +106 -0
- foreblocks-0.1.0/flash-attention/tests/modules/test_mha_parallel.py +160 -0
- foreblocks-0.1.0/flash-attention/tests/modules/test_mlp_parallel.py +143 -0
- foreblocks-0.1.0/flash-attention/tests/ops/test_dropout_layer_norm.py +1189 -0
- foreblocks-0.1.0/flash-attention/tests/ops/test_fused_dense.py +172 -0
- foreblocks-0.1.0/flash-attention/tests/ops/test_fused_dense_parallel.py +237 -0
- foreblocks-0.1.0/flash-attention/tests/ops/triton/test_layer_norm.py +374 -0
- foreblocks-0.1.0/flash-attention/tests/test_flash_attn.py +2525 -0
- foreblocks-0.1.0/flash-attention/tests/test_flash_attn_ck.py +1618 -0
- foreblocks-0.1.0/flash-attention/tests/test_flash_attn_triton_amd.py +2547 -0
- foreblocks-0.1.0/flash-attention/tests/test_rotary.py +321 -0
- foreblocks-0.1.0/flash-attention/tests/test_util.py +274 -0
- foreblocks-0.1.0/flash-attention/training/run.py +68 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/__init__.py +0 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/causality_monitor.py +61 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/ema.py +82 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/flop_count.py +43 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/gpu_affinity.py +40 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/loss_scale_monitor.py +32 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/model_checkpoint.py +36 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/norm_monitor.py +79 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/params_log.py +34 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/speed_monitor.py +95 -0
- foreblocks-0.1.0/flash-attention/training/src/callbacks/wandb_callbacks.py +289 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/datasets/detokenizer.py +53 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/datasets/lm_dataset.py +32 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/fault_tolerant_sampler.py +123 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/imagenet.py +283 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/language_modeling_hf.py +299 -0
- foreblocks-0.1.0/flash-attention/training/src/datamodules/timm_mixup.py +20 -0
- foreblocks-0.1.0/flash-attention/training/src/distributed/ddp_comm_hooks.py +43 -0
- foreblocks-0.1.0/flash-attention/training/src/eval.py +129 -0
- foreblocks-0.1.0/flash-attention/training/src/metrics/accuracy.py +11 -0
- foreblocks-0.1.0/flash-attention/training/src/metrics/num_tokens.py +45 -0
- foreblocks-0.1.0/flash-attention/training/src/metrics/perplexity.py +70 -0
- foreblocks-0.1.0/flash-attention/training/src/models/modules/seq_common.py +342 -0
- foreblocks-0.1.0/flash-attention/training/src/optim/param_grouping.py +114 -0
- foreblocks-0.1.0/flash-attention/training/src/optim/timm_lr_scheduler.py +30 -0
- foreblocks-0.1.0/flash-attention/training/src/tasks/seq.py +192 -0
- foreblocks-0.1.0/flash-attention/training/src/train.py +136 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/checkpoint.py +76 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/ddp_zero1.py +106 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/ddp_zero2.py +146 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/distributed.py +111 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/ema.py +280 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/flops.py +45 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/gpu_affinity.py +142 -0
- foreblocks-0.1.0/flash-attention/training/src/utils/utils.py +146 -0
- foreblocks-0.1.0/flash-attention/training/tests/datamodules/test_language_modeling_hf.py +218 -0
- foreblocks-0.1.0/foreblocks/__init__.py +42 -0
- foreblocks-0.1.0/foreblocks/att.py +299 -0
- foreblocks-0.1.0/foreblocks/aux.py +45 -0
- foreblocks-0.1.0/foreblocks/blocks/__init__.py +64 -0
- foreblocks-0.1.0/foreblocks/blocks/attention.py +287 -0
- foreblocks-0.1.0/foreblocks/blocks/famous.py +529 -0
- foreblocks-0.1.0/foreblocks/blocks/fourier.py +464 -0
- foreblocks-0.1.0/foreblocks/blocks/graph.py +1466 -0
- foreblocks-0.1.0/foreblocks/blocks/mamba.py +119 -0
- foreblocks-0.1.0/foreblocks/blocks/multiscale.py +124 -0
- foreblocks-0.1.0/foreblocks/blocks/nha.py +476 -0
- foreblocks-0.1.0/foreblocks/blocks/ode.py +184 -0
- foreblocks-0.1.0/foreblocks/blocks/simple.py +204 -0
- foreblocks-0.1.0/foreblocks/blocks/wavelets.py +439 -0
- foreblocks-0.1.0/foreblocks/blocks.py +0 -0
- foreblocks-0.1.0/foreblocks/core.py +698 -0
- foreblocks-0.1.0/foreblocks/darts/darts.py +557 -0
- foreblocks-0.1.0/foreblocks/darts/darts_run.py +2386 -0
- foreblocks-0.1.0/foreblocks/enc_dec.py +218 -0
- foreblocks-0.1.0/foreblocks/pipeline.py +389 -0
- foreblocks-0.1.0/foreblocks/pre/__init__.py +0 -0
- foreblocks-0.1.0/foreblocks/pre/ewt.py +104 -0
- foreblocks-0.1.0/foreblocks/pre/filters.py +147 -0
- foreblocks-0.1.0/foreblocks/pre/impute.py +428 -0
- foreblocks-0.1.0/foreblocks/pre/outlier.py +399 -0
- foreblocks-0.1.0/foreblocks/preprocessing.py +978 -0
- foreblocks-0.1.0/foreblocks/tf/embeddings.py +395 -0
- foreblocks-0.1.0/foreblocks/tf/fed.py +322 -0
- foreblocks-0.1.0/foreblocks/tf/transformer.py +690 -0
- foreblocks-0.1.0/foreblocks/tf/transformer_att.py +535 -0
- foreblocks-0.1.0/foreblocks/tf/transformer_aux.py +230 -0
- foreblocks-0.1.0/foreblocks/tf/transformer_moe.py +1137 -0
- foreblocks-0.1.0/foreblocks/third_party/flash_softpick_attn.py +796 -0
- foreblocks-0.1.0/foreblocks/third_party/vsgd.py +212 -0
- foreblocks-0.1.0/foreblocks/utils.py +576 -0
- foreblocks-0.1.0/foreblocks.egg-info/PKG-INFO +484 -0
- foreblocks-0.1.0/foreblocks.egg-info/SOURCES.txt +374 -0
- foreblocks-0.1.0/foreblocks.egg-info/dependency_links.txt +1 -0
- foreblocks-0.1.0/foreblocks.egg-info/requires.txt +9 -0
- foreblocks-0.1.0/foreblocks.egg-info/top_level.txt +5 -0
- foreblocks-0.1.0/pyproject.toml +42 -0
- foreblocks-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: foreblocks
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Modular Time Series Forecasting Library
|
|
5
|
+
Author-email: Laio Seman <you@example.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/lseman/foreblocks
|
|
7
|
+
Project-URL: Repository, https://github.com/lseman/foreblocks
|
|
8
|
+
Keywords: time series,forecasting,deep learning,transformer,lstm,pytorch
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: torch>=1.12
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: pandas
|
|
20
|
+
Requires-Dist: scikit-learn
|
|
21
|
+
Requires-Dist: matplotlib
|
|
22
|
+
Requires-Dist: PyWavelets
|
|
23
|
+
Requires-Dist: pytorch_wavelets
|
|
24
|
+
Requires-Dist: wandb
|
|
25
|
+
Requires-Dist: darts>=0.24.0
|
|
26
|
+
|
|
27
|
+
# ForeBlocks: Modular Time Series Forecasting Library
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
**ForeBlocks** is a flexible, modular deep learning framework for time series forecasting built on PyTorch. It provides various neural network architectures and forecasting strategies to tackle complex time series prediction problems with an intuitive, research-friendly API.
|
|
32
|
+
|
|
33
|
+
🔗 **[GitHub Repository](https://github.com/lseman/foreblocks)**
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Start
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
# Installation
|
|
41
|
+
git clone https://github.com/lseman/foreblocks
|
|
42
|
+
cd foreblocks
|
|
43
|
+
pip install -e .
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from foreblocks import TimeSeriesSeq2Seq, ModelConfig, TrainingConfig
|
|
48
|
+
import torch
|
|
49
|
+
import pandas as pd
|
|
50
|
+
|
|
51
|
+
# Load and prepare data
|
|
52
|
+
data = pd.read_csv('your_data.csv')
|
|
53
|
+
X = data.values
|
|
54
|
+
|
|
55
|
+
# Configure model
|
|
56
|
+
model_config = ModelConfig(
|
|
57
|
+
model_type="lstm",
|
|
58
|
+
input_size=X.shape[1],
|
|
59
|
+
output_size=1,
|
|
60
|
+
hidden_size=64,
|
|
61
|
+
target_len=24, # Forecast 24 steps ahead
|
|
62
|
+
teacher_forcing_ratio=0.5
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Initialize and train
|
|
66
|
+
model = TimeSeriesSeq2Seq(model_config=model_config)
|
|
67
|
+
X_train, y_train, _ = model.preprocess(X, self_tune=True)
|
|
68
|
+
|
|
69
|
+
# Create DataLoader and train
|
|
70
|
+
from torch.utils.data import TensorDataset, DataLoader
|
|
71
|
+
train_dataset = TensorDataset(
|
|
72
|
+
torch.tensor(X_train, dtype=torch.float32),
|
|
73
|
+
torch.tensor(y_train, dtype=torch.float32)
|
|
74
|
+
)
|
|
75
|
+
train_loader = DataLoader(train_dataset, batch_size=32, shuffle=True)
|
|
76
|
+
|
|
77
|
+
history = model.train_model(train_loader)
|
|
78
|
+
predictions = model.predict(X_test)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ✨ Key Features
|
|
84
|
+
|
|
85
|
+
| Feature | Description |
|
|
86
|
+
|---------|-------------|
|
|
87
|
+
| **🔧 Multiple Strategies** | Seq2Seq, Autoregressive, and Direct forecasting approaches |
|
|
88
|
+
| **🧩 Modular Design** | Easily customize and extend components |
|
|
89
|
+
| **🤖 Advanced Models** | LSTM, GRU, Transformer, and VAE-based architectures |
|
|
90
|
+
| **⚡ Smart Preprocessing** | Adaptive data preprocessing with automatic configuration |
|
|
91
|
+
| **🎯 Attention Mechanisms** | Various attention modules for improved performance |
|
|
92
|
+
| **📊 Multi-Feature Support** | Specialized architectures for multivariate time series |
|
|
93
|
+
| **📈 Training Utilities** | Built-in trainer with callbacks, metrics, and visualizations |
|
|
94
|
+
| **🔍 Transparent API** | Intuitive interface with extensive documentation |
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## 📖 Documentation
|
|
100
|
+
|
|
101
|
+
- 📘 [Preprocessing Guide](docs/preprocessor.md)
|
|
102
|
+
- 🛠️ [Custom Blocks Guide](docs/custom_blocks.md)
|
|
103
|
+
- [Transformer Blocks](docs/transformer.md)
|
|
104
|
+
- [Fourier Blocks](docs/fourier.md)
|
|
105
|
+
- [Wavelet Blocks](docs/wavelet.md)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🏗️ Architecture Overview
|
|
110
|
+
|
|
111
|
+
ForeBlocks follows a clean, modular design:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
┌─────────────────────┐
|
|
115
|
+
│ TimeSeriesSeq2Seq │ ← High-level Interface
|
|
116
|
+
├─────────────────────┤
|
|
117
|
+
│ ForecastingModel │ ← Core Model Class
|
|
118
|
+
├─────────────────────┤
|
|
119
|
+
│ Encoders & Decoders │ ← Neural Network Modules
|
|
120
|
+
├─────────────────────┤
|
|
121
|
+
│ Preprocessing │ ← Data Pipeline
|
|
122
|
+
├─────────────────────┤
|
|
123
|
+
│ Training Utils │ ← Trainer & Metrics
|
|
124
|
+
└─────────────────────┘
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Core Components
|
|
128
|
+
|
|
129
|
+
- **`TimeSeriesSeq2Seq`**: High-level interface for building and training models
|
|
130
|
+
- **`ForecastingModel`**: Main model class integrating encoders, decoders, and strategies
|
|
131
|
+
- **`TimeSeriesPreprocessor`**: Advanced data preparation with automatic feature detection
|
|
132
|
+
- **`Trainer`**: Manages training, evaluation, and visualization
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## 🎯 Forecasting Models
|
|
137
|
+
|
|
138
|
+
### 1. Sequence-to-Sequence (Default)
|
|
139
|
+
*Best for: Most time series problems*
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
model_config = ModelConfig(
|
|
143
|
+
model_type="lstm",
|
|
144
|
+
strategy="seq2seq",
|
|
145
|
+
input_size=3,
|
|
146
|
+
output_size=1,
|
|
147
|
+
hidden_size=64,
|
|
148
|
+
num_encoder_layers=2,
|
|
149
|
+
num_decoder_layers=2,
|
|
150
|
+
target_len=24
|
|
151
|
+
)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### 2. Autoregressive
|
|
155
|
+
*Best for: When each prediction depends on previous predictions*
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
model_config = ModelConfig(
|
|
159
|
+
model_type="lstm",
|
|
160
|
+
strategy="autoregressive",
|
|
161
|
+
input_size=1,
|
|
162
|
+
output_size=1,
|
|
163
|
+
hidden_size=64,
|
|
164
|
+
target_len=12
|
|
165
|
+
)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 3. Direct Multi-Step
|
|
169
|
+
*Best for: Independent multi-step predictions*
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
model_config = ModelConfig(
|
|
173
|
+
model_type="lstm",
|
|
174
|
+
strategy="direct",
|
|
175
|
+
input_size=5,
|
|
176
|
+
output_size=1,
|
|
177
|
+
hidden_size=128,
|
|
178
|
+
target_len=48
|
|
179
|
+
)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### 4. Transformer-based
|
|
183
|
+
*Best for: Long sequences with complex dependencies*
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
model_config = ModelConfig(
|
|
187
|
+
model_type="transformer",
|
|
188
|
+
strategy="transformer_seq2seq",
|
|
189
|
+
input_size=4,
|
|
190
|
+
output_size=4,
|
|
191
|
+
hidden_size=128,
|
|
192
|
+
dim_feedforward=512,
|
|
193
|
+
nheads=8,
|
|
194
|
+
num_encoder_layers=3,
|
|
195
|
+
num_decoder_layers=3,
|
|
196
|
+
target_len=96
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## 🔧 Advanced Features
|
|
203
|
+
|
|
204
|
+
### Multi-Encoder-Decoder Architecture
|
|
205
|
+
Process different features with separate encoders:
|
|
206
|
+
|
|
207
|
+
```python
|
|
208
|
+
model_config = ModelConfig(
|
|
209
|
+
multi_encoder_decoder=True,
|
|
210
|
+
input_size=5, # 5 different features
|
|
211
|
+
output_size=1,
|
|
212
|
+
hidden_size=64,
|
|
213
|
+
model_type="lstm",
|
|
214
|
+
target_len=24
|
|
215
|
+
)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Attention Mechanisms
|
|
219
|
+
Improve performance with attention:
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from foreblocks.attention import AttentionLayer
|
|
223
|
+
|
|
224
|
+
attention_module = AttentionLayer(
|
|
225
|
+
method="dot",
|
|
226
|
+
attention_backend="self",
|
|
227
|
+
encoder_hidden_size=64,
|
|
228
|
+
decoder_hidden_size=64
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
model = TimeSeriesSeq2Seq(
|
|
232
|
+
model_config=model_config,
|
|
233
|
+
attention_module=attention_module
|
|
234
|
+
)
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Custom Preprocessing Pipeline
|
|
238
|
+
Fine-tune data preparation:
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
X_train, y_train, processed_data = model.preprocess(
|
|
242
|
+
X,
|
|
243
|
+
normalize=True,
|
|
244
|
+
differencing=True,
|
|
245
|
+
detrend=True,
|
|
246
|
+
apply_ewt=True,
|
|
247
|
+
window_size=48,
|
|
248
|
+
horizon=24,
|
|
249
|
+
remove_outliers=True,
|
|
250
|
+
outlier_method="iqr",
|
|
251
|
+
self_tune=True
|
|
252
|
+
)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
### Scheduled Sampling
|
|
256
|
+
Control teacher forcing dynamically:
|
|
257
|
+
|
|
258
|
+
```python
|
|
259
|
+
def scheduled_sampling_fn(epoch):
|
|
260
|
+
return max(0.0, 1.0 - 0.1 * epoch) # Linear decay
|
|
261
|
+
|
|
262
|
+
model = TimeSeriesSeq2Seq(
|
|
263
|
+
model_config=model_config,
|
|
264
|
+
scheduled_sampling_fn=scheduled_sampling_fn
|
|
265
|
+
)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## 📚 Examples
|
|
271
|
+
|
|
272
|
+
### LSTM with Attention
|
|
273
|
+
```python
|
|
274
|
+
from foreblocks import TimeSeriesSeq2Seq, ModelConfig, AttentionLayer
|
|
275
|
+
import torch.nn as nn
|
|
276
|
+
|
|
277
|
+
# Configure model with attention
|
|
278
|
+
model_config = ModelConfig(
|
|
279
|
+
model_type="lstm",
|
|
280
|
+
input_size=3,
|
|
281
|
+
output_size=1,
|
|
282
|
+
hidden_size=64,
|
|
283
|
+
num_encoder_layers=2,
|
|
284
|
+
num_decoder_layers=2,
|
|
285
|
+
target_len=24
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
attention = AttentionLayer(
|
|
289
|
+
method="dot",
|
|
290
|
+
encoder_hidden_size=64,
|
|
291
|
+
decoder_hidden_size=64
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
model = TimeSeriesSeq2Seq(
|
|
295
|
+
model_config=model_config,
|
|
296
|
+
attention_module=attention,
|
|
297
|
+
output_block=nn.Sequential(nn.Dropout(0.1), nn.ReLU())
|
|
298
|
+
)
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Transformer Model
|
|
302
|
+
```python
|
|
303
|
+
from foreblocks import TimeSeriesSeq2Seq, ModelConfig, TrainingConfig
|
|
304
|
+
|
|
305
|
+
model_config = ModelConfig(
|
|
306
|
+
model_type="transformer",
|
|
307
|
+
input_size=4,
|
|
308
|
+
output_size=4,
|
|
309
|
+
hidden_size=128,
|
|
310
|
+
dim_feedforward=512,
|
|
311
|
+
nheads=8,
|
|
312
|
+
num_encoder_layers=3,
|
|
313
|
+
num_decoder_layers=3,
|
|
314
|
+
target_len=96
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
training_config = TrainingConfig(
|
|
318
|
+
num_epochs=100,
|
|
319
|
+
learning_rate=0.0001,
|
|
320
|
+
weight_decay=1e-5,
|
|
321
|
+
patience=15
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
model = TimeSeriesSeq2Seq(
|
|
325
|
+
model_config=model_config,
|
|
326
|
+
training_config=training_config
|
|
327
|
+
)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## 🔧 Configuration Reference
|
|
333
|
+
|
|
334
|
+
### ModelConfig Parameters
|
|
335
|
+
|
|
336
|
+
| Parameter | Type | Description | Default |
|
|
337
|
+
|-----------|------|-------------|---------|
|
|
338
|
+
| `model_type` | str | Model architecture ("lstm", "gru", "transformer") | "lstm" |
|
|
339
|
+
| `input_size` | int | Number of input features | Required |
|
|
340
|
+
| `output_size` | int | Number of output features | Required |
|
|
341
|
+
| `hidden_size` | int | Hidden layer dimensions | 64 |
|
|
342
|
+
| `target_len` | int | Forecast horizon length | Required |
|
|
343
|
+
| `num_encoder_layers` | int | Number of encoder layers | 1 |
|
|
344
|
+
| `num_decoder_layers` | int | Number of decoder layers | 1 |
|
|
345
|
+
| `teacher_forcing_ratio` | float | Teacher forcing probability | 0.5 |
|
|
346
|
+
|
|
347
|
+
### TrainingConfig Parameters
|
|
348
|
+
|
|
349
|
+
| Parameter | Type | Description | Default |
|
|
350
|
+
|-----------|------|-------------|---------|
|
|
351
|
+
| `num_epochs` | int | Training epochs | 100 |
|
|
352
|
+
| `learning_rate` | float | Learning rate | 0.001 |
|
|
353
|
+
| `batch_size` | int | Batch size | 32 |
|
|
354
|
+
| `patience` | int | Early stopping patience | 10 |
|
|
355
|
+
| `weight_decay` | float | L2 regularization | 0.0 |
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
## 🚨 Troubleshooting
|
|
360
|
+
|
|
361
|
+
### Common Issues & Solutions
|
|
362
|
+
|
|
363
|
+
<details>
|
|
364
|
+
<summary><strong>🔴 Dimensionality Mismatch</strong></summary>
|
|
365
|
+
|
|
366
|
+
**Problem**: Tensor dimension errors during training/inference
|
|
367
|
+
|
|
368
|
+
**Solution**:
|
|
369
|
+
- Check encoder/decoder `hidden_size` compatibility
|
|
370
|
+
- Verify `output_size` matches target dimensions
|
|
371
|
+
- Ensure input data shape matches `input_size`
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
# Debug dimensions
|
|
375
|
+
print(f"Input shape: {X.shape}")
|
|
376
|
+
print(f"Model expects: {model_config.input_size} features")
|
|
377
|
+
```
|
|
378
|
+
</details>
|
|
379
|
+
|
|
380
|
+
<details>
|
|
381
|
+
<summary><strong>🟡 Memory Issues</strong></summary>
|
|
382
|
+
|
|
383
|
+
**Problem**: CUDA out of memory or system RAM exhaustion
|
|
384
|
+
|
|
385
|
+
**Solutions**:
|
|
386
|
+
- Reduce `batch_size` or sequence length
|
|
387
|
+
- Use gradient accumulation
|
|
388
|
+
- Consider model size reduction
|
|
389
|
+
|
|
390
|
+
```python
|
|
391
|
+
# Gradient accumulation example
|
|
392
|
+
accumulation_steps = 4
|
|
393
|
+
for i, batch in enumerate(train_loader):
|
|
394
|
+
loss = model(batch) / accumulation_steps
|
|
395
|
+
loss.backward()
|
|
396
|
+
if (i + 1) % accumulation_steps == 0:
|
|
397
|
+
optimizer.step()
|
|
398
|
+
optimizer.zero_grad()
|
|
399
|
+
```
|
|
400
|
+
</details>
|
|
401
|
+
|
|
402
|
+
<details>
|
|
403
|
+
<summary><strong>🟠 Poor Performance</strong></summary>
|
|
404
|
+
|
|
405
|
+
**Problem**: Model not learning or poor predictions
|
|
406
|
+
|
|
407
|
+
**Solutions**:
|
|
408
|
+
- Try different forecasting strategies
|
|
409
|
+
- Adjust `teacher_forcing_ratio`
|
|
410
|
+
- Add attention mechanisms
|
|
411
|
+
- Experiment with architectures (LSTM vs Transformer)
|
|
412
|
+
- Tune hyperparameters
|
|
413
|
+
|
|
414
|
+
```python
|
|
415
|
+
# Performance tuning checklist
|
|
416
|
+
model_config = ModelConfig(
|
|
417
|
+
hidden_size=128, # Try larger hidden size
|
|
418
|
+
num_encoder_layers=3, # Add more layers
|
|
419
|
+
teacher_forcing_ratio=0.3, # Reduce teacher forcing
|
|
420
|
+
# Add dropout, attention, etc.
|
|
421
|
+
)
|
|
422
|
+
```
|
|
423
|
+
</details>
|
|
424
|
+
|
|
425
|
+
<details>
|
|
426
|
+
<summary><strong>🔵 Training Issues</strong></summary>
|
|
427
|
+
|
|
428
|
+
**Problem**: Slow convergence or gradient problems
|
|
429
|
+
|
|
430
|
+
**Solutions**:
|
|
431
|
+
- Use gradient clipping
|
|
432
|
+
- Learning rate scheduling
|
|
433
|
+
- Proper weight initialization
|
|
434
|
+
|
|
435
|
+
```python
|
|
436
|
+
# Gradient clipping
|
|
437
|
+
import torch.nn.utils as utils
|
|
438
|
+
utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
|
|
439
|
+
|
|
440
|
+
# Learning rate scheduling
|
|
441
|
+
scheduler = torch.optim.lr_scheduler.ReduceLROnPlateau(
|
|
442
|
+
optimizer, patience=5, factor=0.5
|
|
443
|
+
)
|
|
444
|
+
```
|
|
445
|
+
</details>
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
## 💡 Best Practices
|
|
450
|
+
|
|
451
|
+
### 🎯 Performance Tips
|
|
452
|
+
- **Always normalize** input data for better convergence
|
|
453
|
+
- **Use appropriate metrics** (MAE, RMSE, MAPE) for time series
|
|
454
|
+
- **Validate on multi-step** predictions, not just one-step
|
|
455
|
+
- **Consider model ensembling** for critical applications
|
|
456
|
+
|
|
457
|
+
### 📊 Data Preparation
|
|
458
|
+
- Handle missing values before feeding to model
|
|
459
|
+
- Consider seasonal decomposition for seasonal data
|
|
460
|
+
- Use the built-in preprocessing with `self_tune=True`
|
|
461
|
+
|
|
462
|
+
### 🔄 Training Strategy
|
|
463
|
+
- Start with simple models (LSTM) before trying complex ones (Transformer)
|
|
464
|
+
- Use validation sets for hyperparameter tuning
|
|
465
|
+
- Monitor both training and validation metrics
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## 🤝 Contributing
|
|
470
|
+
|
|
471
|
+
We welcome contributions! Please see our [GitHub repository](https://github.com/lseman/foreblocks) for:
|
|
472
|
+
- 🐛 Bug reports
|
|
473
|
+
- 💡 Feature requests
|
|
474
|
+
- 📝 Documentation improvements
|
|
475
|
+
- 🔧 Code contributions
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
## 📄 License
|
|
480
|
+
|
|
481
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|