truss 0.10.0rc1__py3-none-any.whl → 0.60.0__py3-none-any.whl
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.
Potentially problematic release.
This version of truss might be problematic. Click here for more details.
- truss/__init__.py +10 -3
- truss/api/__init__.py +123 -0
- truss/api/definitions.py +51 -0
- truss/base/constants.py +116 -0
- truss/base/custom_types.py +29 -0
- truss/{errors.py → base/errors.py} +4 -0
- truss/base/trt_llm_config.py +310 -0
- truss/{truss_config.py → base/truss_config.py} +344 -31
- truss/{truss_spec.py → base/truss_spec.py} +20 -6
- truss/{validation.py → base/validation.py} +60 -11
- truss/cli/cli.py +841 -88
- truss/{remote → cli}/remote_cli.py +2 -7
- truss/contexts/docker_build_setup.py +67 -0
- truss/contexts/image_builder/cache_warmer.py +2 -8
- truss/contexts/image_builder/image_builder.py +1 -1
- truss/contexts/image_builder/serving_image_builder.py +292 -46
- truss/contexts/image_builder/util.py +1 -3
- truss/contexts/local_loader/docker_build_emulator.py +58 -0
- truss/contexts/local_loader/load_model_local.py +2 -2
- truss/contexts/local_loader/truss_module_loader.py +1 -1
- truss/contexts/local_loader/utils.py +1 -1
- truss/local/local_config.py +2 -6
- truss/local/local_config_handler.py +20 -5
- truss/patch/__init__.py +1 -0
- truss/patch/hash.py +4 -70
- truss/patch/signature.py +4 -16
- truss/patch/truss_dir_patch_applier.py +3 -78
- truss/remote/baseten/api.py +308 -23
- truss/remote/baseten/auth.py +3 -3
- truss/remote/baseten/core.py +257 -50
- truss/remote/baseten/custom_types.py +44 -0
- truss/remote/baseten/error.py +4 -0
- truss/remote/baseten/remote.py +369 -118
- truss/remote/baseten/service.py +118 -11
- truss/remote/baseten/utils/status.py +29 -0
- truss/remote/baseten/utils/tar.py +34 -22
- truss/remote/baseten/utils/transfer.py +36 -23
- truss/remote/remote_factory.py +14 -5
- truss/remote/truss_remote.py +72 -45
- truss/templates/base.Dockerfile.jinja +18 -16
- truss/templates/cache.Dockerfile.jinja +3 -3
- truss/{server → templates/control}/control/application.py +14 -35
- truss/{server → templates/control}/control/endpoints.py +39 -9
- truss/{server/control/patch/types.py → templates/control/control/helpers/custom_types.py} +13 -52
- truss/{server → templates/control}/control/helpers/inference_server_controller.py +4 -8
- truss/{server → templates/control}/control/helpers/inference_server_process_controller.py +2 -4
- truss/{server → templates/control}/control/helpers/inference_server_starter.py +5 -10
- truss/{server/control → templates/control/control/helpers}/truss_patch/model_code_patch_applier.py +8 -6
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/model_container_patch_applier.py +18 -26
- truss/templates/control/control/helpers/truss_patch/requirement_name_identifier.py +66 -0
- truss/{server → templates/control}/control/server.py +11 -6
- truss/templates/control/requirements.txt +9 -0
- truss/templates/custom_python_dx/my_model.py +28 -0
- truss/templates/docker_server/proxy.conf.jinja +42 -0
- truss/templates/docker_server/supervisord.conf.jinja +27 -0
- truss/templates/docker_server_requirements.txt +1 -0
- truss/templates/server/common/errors.py +231 -0
- truss/{server → templates/server}/common/patches/whisper/patch.py +1 -0
- truss/{server/common/patches/__init__.py → templates/server/common/patches.py} +1 -3
- truss/{server → templates/server}/common/retry.py +1 -0
- truss/{server → templates/server}/common/schema.py +11 -9
- truss/templates/server/common/tracing.py +157 -0
- truss/templates/server/main.py +9 -0
- truss/templates/server/model_wrapper.py +961 -0
- truss/templates/server/requirements.txt +21 -0
- truss/templates/server/truss_server.py +447 -0
- truss/templates/server.Dockerfile.jinja +62 -14
- truss/templates/shared/dynamic_config_resolver.py +28 -0
- truss/templates/shared/lazy_data_resolver.py +164 -0
- truss/templates/shared/log_config.py +125 -0
- truss/{server → templates}/shared/secrets_resolver.py +1 -2
- truss/{server → templates}/shared/serialization.py +31 -9
- truss/{server → templates}/shared/util.py +3 -13
- truss/templates/trtllm-audio/model/model.py +49 -0
- truss/templates/trtllm-audio/packages/sigint_patch.py +14 -0
- truss/templates/trtllm-audio/packages/whisper_trt/__init__.py +215 -0
- truss/templates/trtllm-audio/packages/whisper_trt/assets.py +25 -0
- truss/templates/trtllm-audio/packages/whisper_trt/batching.py +52 -0
- truss/templates/trtllm-audio/packages/whisper_trt/custom_types.py +26 -0
- truss/templates/trtllm-audio/packages/whisper_trt/modeling.py +184 -0
- truss/templates/trtllm-audio/packages/whisper_trt/tokenizer.py +185 -0
- truss/templates/trtllm-audio/packages/whisper_trt/utils.py +245 -0
- truss/templates/trtllm-briton/src/extension.py +64 -0
- truss/tests/conftest.py +302 -94
- truss/tests/contexts/image_builder/test_serving_image_builder.py +74 -31
- truss/tests/contexts/local_loader/test_load_local.py +2 -2
- truss/tests/contexts/local_loader/test_truss_module_finder.py +1 -1
- truss/tests/patch/test_calc_patch.py +439 -127
- truss/tests/patch/test_dir_signature.py +3 -12
- truss/tests/patch/test_hash.py +1 -1
- truss/tests/patch/test_signature.py +1 -1
- truss/tests/patch/test_truss_dir_patch_applier.py +23 -11
- truss/tests/patch/test_types.py +2 -2
- truss/tests/remote/baseten/test_api.py +153 -58
- truss/tests/remote/baseten/test_auth.py +2 -1
- truss/tests/remote/baseten/test_core.py +160 -12
- truss/tests/remote/baseten/test_remote.py +489 -77
- truss/tests/remote/baseten/test_service.py +55 -0
- truss/tests/remote/test_remote_factory.py +16 -18
- truss/tests/remote/test_truss_remote.py +26 -17
- truss/tests/templates/control/control/helpers/test_context_managers.py +11 -0
- truss/tests/templates/control/control/helpers/test_model_container_patch_applier.py +184 -0
- truss/tests/templates/control/control/helpers/test_requirement_name_identifier.py +89 -0
- truss/tests/{server → templates/control}/control/test_server.py +79 -24
- truss/tests/{server → templates/control}/control/test_server_integration.py +24 -16
- truss/tests/templates/core/server/test_dynamic_config_resolver.py +108 -0
- truss/tests/templates/core/server/test_lazy_data_resolver.py +329 -0
- truss/tests/templates/core/server/test_lazy_data_resolver_v2.py +79 -0
- truss/tests/{server → templates}/core/server/test_secrets_resolver.py +1 -1
- truss/tests/{server → templates/server}/common/test_retry.py +3 -3
- truss/tests/templates/server/test_model_wrapper.py +248 -0
- truss/tests/{server → templates/server}/test_schema.py +3 -5
- truss/tests/{server/core/server/common → templates/server}/test_truss_server.py +8 -5
- truss/tests/test_build.py +9 -52
- truss/tests/test_config.py +336 -77
- truss/tests/test_context_builder_image.py +3 -11
- truss/tests/test_control_truss_patching.py +7 -12
- truss/tests/test_custom_server.py +38 -0
- truss/tests/test_data/context_builder_image_test/test.py +3 -0
- truss/tests/test_data/happy.ipynb +56 -0
- truss/tests/test_data/model_load_failure_test/config.yaml +2 -0
- truss/tests/test_data/model_load_failure_test/model/__init__.py +0 -0
- truss/tests/test_data/patch_ping_test_server/__init__.py +0 -0
- truss/{test_data → tests/test_data}/patch_ping_test_server/app.py +3 -9
- truss/{test_data → tests/test_data}/server.Dockerfile +20 -21
- truss/tests/test_data/server_conformance_test_truss/__init__.py +0 -0
- truss/tests/test_data/server_conformance_test_truss/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/server_conformance_test_truss/model/model.py +1 -3
- truss/tests/test_data/test_async_truss/__init__.py +0 -0
- truss/tests/test_data/test_async_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_basic_truss/__init__.py +0 -0
- truss/tests/test_data/test_basic_truss/config.yaml +16 -0
- truss/tests/test_data/test_basic_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_build_commands/__init__.py +0 -0
- truss/tests/test_data/test_build_commands/config.yaml +13 -0
- truss/tests/test_data/test_build_commands/model/__init__.py +0 -0
- truss/{test_data/test_streaming_async_generator_truss → tests/test_data/test_build_commands}/model/model.py +2 -3
- truss/tests/test_data/test_build_commands_failure/__init__.py +0 -0
- truss/tests/test_data/test_build_commands_failure/config.yaml +14 -0
- truss/tests/test_data/test_build_commands_failure/model/__init__.py +0 -0
- truss/tests/test_data/test_build_commands_failure/model/model.py +17 -0
- truss/tests/test_data/test_concurrency_truss/__init__.py +0 -0
- truss/tests/test_data/test_concurrency_truss/config.yaml +4 -0
- truss/tests/test_data/test_concurrency_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/config.yaml +20 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/Dockerfile +17 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/README.md +10 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/VERSION +1 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/__init__.py +0 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/app.py +19 -0
- truss/tests/test_data/test_custom_server_truss/test_docker_image/build_upload_new_image.sh +6 -0
- truss/tests/test_data/test_openai/__init__.py +0 -0
- truss/{test_data/test_basic_truss → tests/test_data/test_openai}/config.yaml +1 -2
- truss/tests/test_data/test_openai/model/__init__.py +0 -0
- truss/tests/test_data/test_openai/model/model.py +15 -0
- truss/tests/test_data/test_pyantic_v1/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v1/model/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v1/model/model.py +28 -0
- truss/tests/test_data/test_pyantic_v1/requirements.txt +1 -0
- truss/tests/test_data/test_pyantic_v2/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v2/config.yaml +13 -0
- truss/tests/test_data/test_pyantic_v2/model/__init__.py +0 -0
- truss/tests/test_data/test_pyantic_v2/model/model.py +30 -0
- truss/tests/test_data/test_pyantic_v2/requirements.txt +1 -0
- truss/tests/test_data/test_requirements_file_truss/__init__.py +0 -0
- truss/tests/test_data/test_requirements_file_truss/config.yaml +13 -0
- truss/tests/test_data/test_requirements_file_truss/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/test_requirements_file_truss/model/model.py +1 -0
- truss/tests/test_data/test_streaming_async_generator_truss/__init__.py +0 -0
- truss/tests/test_data/test_streaming_async_generator_truss/config.yaml +4 -0
- truss/tests/test_data/test_streaming_async_generator_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_async_generator_truss/model/model.py +7 -0
- truss/tests/test_data/test_streaming_read_timeout/__init__.py +0 -0
- truss/tests/test_data/test_streaming_read_timeout/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss/config.yaml +4 -0
- truss/tests/test_data/test_streaming_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/test_streaming_truss_with_error/model/model.py +3 -11
- truss/tests/test_data/test_streaming_truss_with_error/packages/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_1.py +5 -0
- truss/tests/test_data/test_streaming_truss_with_error/packages/helpers_2.py +2 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/config.yaml +43 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/model/__init__.py +0 -0
- truss/tests/test_data/test_streaming_truss_with_tracing/model/model.py +65 -0
- truss/tests/test_data/test_trt_llm_truss/__init__.py +0 -0
- truss/tests/test_data/test_trt_llm_truss/config.yaml +15 -0
- truss/tests/test_data/test_trt_llm_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_trt_llm_truss/model/model.py +15 -0
- truss/tests/test_data/test_truss/__init__.py +0 -0
- truss/tests/test_data/test_truss/config.yaml +4 -0
- truss/tests/test_data/test_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_truss/model/dummy +0 -0
- truss/tests/test_data/test_truss/packages/__init__.py +0 -0
- truss/tests/test_data/test_truss/packages/test_package/__init__.py +0 -0
- truss/tests/test_data/test_truss_server_caching_truss/__init__.py +0 -0
- truss/tests/test_data/test_truss_server_caching_truss/model/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/config.yaml +4 -0
- truss/tests/test_data/test_truss_with_error/model/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/model/model.py +8 -0
- truss/tests/test_data/test_truss_with_error/packages/__init__.py +0 -0
- truss/tests/test_data/test_truss_with_error/packages/helpers_1.py +5 -0
- truss/tests/test_data/test_truss_with_error/packages/helpers_2.py +2 -0
- truss/tests/test_docker.py +2 -1
- truss/tests/test_model_inference.py +1340 -292
- truss/tests/test_model_schema.py +33 -26
- truss/tests/test_testing_utilities_for_other_tests.py +50 -5
- truss/tests/test_truss_gatherer.py +3 -5
- truss/tests/test_truss_handle.py +62 -59
- truss/tests/test_util.py +2 -1
- truss/tests/test_validation.py +15 -13
- truss/tests/trt_llm/test_trt_llm_config.py +41 -0
- truss/tests/trt_llm/test_validation.py +91 -0
- truss/tests/util/test_config_checks.py +40 -0
- truss/tests/util/test_env_vars.py +14 -0
- truss/tests/util/test_path.py +10 -23
- truss/trt_llm/config_checks.py +43 -0
- truss/trt_llm/validation.py +42 -0
- truss/truss_handle/__init__.py +0 -0
- truss/truss_handle/build.py +122 -0
- truss/{decorators.py → truss_handle/decorators.py} +1 -1
- truss/truss_handle/patch/__init__.py +0 -0
- truss/{patch → truss_handle/patch}/calc_patch.py +146 -92
- truss/{types.py → truss_handle/patch/custom_types.py} +35 -27
- truss/{patch → truss_handle/patch}/dir_signature.py +1 -1
- truss/truss_handle/patch/hash.py +71 -0
- truss/{patch → truss_handle/patch}/local_truss_patch_applier.py +6 -4
- truss/truss_handle/patch/signature.py +22 -0
- truss/truss_handle/patch/truss_dir_patch_applier.py +87 -0
- truss/{readme_generator.py → truss_handle/readme_generator.py} +3 -2
- truss/{truss_gatherer.py → truss_handle/truss_gatherer.py} +3 -2
- truss/{truss_handle.py → truss_handle/truss_handle.py} +174 -78
- truss/util/.truss_ignore +3 -0
- truss/{docker.py → util/docker.py} +6 -2
- truss/util/download.py +6 -15
- truss/util/env_vars.py +41 -0
- truss/util/log_utils.py +52 -0
- truss/util/path.py +20 -20
- truss/util/requirements.py +11 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/METADATA +18 -16
- truss-0.60.0.dist-info/RECORD +324 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/WHEEL +1 -1
- truss-0.60.0.dist-info/entry_points.txt +4 -0
- truss_chains/__init__.py +71 -0
- truss_chains/definitions.py +756 -0
- truss_chains/deployment/__init__.py +0 -0
- truss_chains/deployment/code_gen.py +816 -0
- truss_chains/deployment/deployment_client.py +871 -0
- truss_chains/framework.py +1480 -0
- truss_chains/public_api.py +231 -0
- truss_chains/py.typed +0 -0
- truss_chains/pydantic_numpy.py +131 -0
- truss_chains/reference_code/reference_chainlet.py +34 -0
- truss_chains/reference_code/reference_model.py +10 -0
- truss_chains/remote_chainlet/__init__.py +0 -0
- truss_chains/remote_chainlet/model_skeleton.py +60 -0
- truss_chains/remote_chainlet/stub.py +380 -0
- truss_chains/remote_chainlet/utils.py +332 -0
- truss_chains/streaming.py +378 -0
- truss_chains/utils.py +178 -0
- CODE_OF_CONDUCT.md +0 -131
- CONTRIBUTING.md +0 -48
- README.md +0 -137
- context_builder.Dockerfile +0 -24
- truss/blob/blob_backend.py +0 -10
- truss/blob/blob_backend_registry.py +0 -23
- truss/blob/http_public_blob_backend.py +0 -23
- truss/build/__init__.py +0 -2
- truss/build/build.py +0 -143
- truss/build/configure.py +0 -63
- truss/cli/__init__.py +0 -2
- truss/cli/console.py +0 -5
- truss/cli/create.py +0 -5
- truss/config/trt_llm.py +0 -81
- truss/constants.py +0 -61
- truss/model_inference.py +0 -123
- truss/patch/types.py +0 -30
- truss/pytest.ini +0 -7
- truss/server/common/errors.py +0 -100
- truss/server/common/termination_handler_middleware.py +0 -64
- truss/server/common/truss_server.py +0 -389
- truss/server/control/patch/model_code_patch_applier.py +0 -46
- truss/server/control/patch/requirement_name_identifier.py +0 -17
- truss/server/inference_server.py +0 -29
- truss/server/model_wrapper.py +0 -434
- truss/server/shared/logging.py +0 -81
- truss/templates/trtllm/model/model.py +0 -97
- truss/templates/trtllm/packages/build_engine_utils.py +0 -34
- truss/templates/trtllm/packages/constants.py +0 -11
- truss/templates/trtllm/packages/schema.py +0 -216
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/ensemble/config.pbtxt +0 -246
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/1/model.py +0 -181
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/postprocessing/config.pbtxt +0 -64
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/1/model.py +0 -260
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/preprocessing/config.pbtxt +0 -99
- truss/templates/trtllm/packages/tensorrt_llm_model_repository/tensorrt_llm/config.pbtxt +0 -208
- truss/templates/trtllm/packages/triton_client.py +0 -150
- truss/templates/trtllm/packages/utils.py +0 -43
- truss/test_data/context_builder_image_test/test.py +0 -4
- truss/test_data/happy.ipynb +0 -54
- truss/test_data/model_load_failure_test/config.yaml +0 -2
- truss/test_data/test_concurrency_truss/config.yaml +0 -2
- truss/test_data/test_streaming_async_generator_truss/config.yaml +0 -2
- truss/test_data/test_streaming_truss/config.yaml +0 -3
- truss/test_data/test_truss/config.yaml +0 -2
- truss/tests/server/common/test_termination_handler_middleware.py +0 -93
- truss/tests/server/control/test_model_container_patch_applier.py +0 -203
- truss/tests/server/core/server/common/test_util.py +0 -19
- truss/tests/server/test_model_wrapper.py +0 -87
- truss/util/data_structures.py +0 -16
- truss-0.10.0rc1.dist-info/RECORD +0 -216
- truss-0.10.0rc1.dist-info/entry_points.txt +0 -3
- truss/{server/shared → base}/__init__.py +0 -0
- truss/{server → templates/control}/control/helpers/context_managers.py +0 -0
- truss/{server/control → templates/control/control/helpers}/errors.py +0 -0
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/__init__.py +0 -0
- truss/{server/control/patch → templates/control/control/helpers/truss_patch}/system_packages.py +0 -0
- truss/{test_data/annotated_types_truss/model → templates/server}/__init__.py +0 -0
- truss/{server → templates/server}/common/__init__.py +0 -0
- truss/{test_data/gcs_fix/model → templates/shared}/__init__.py +0 -0
- truss/templates/{trtllm → trtllm-briton}/README.md +0 -0
- truss/{test_data/server_conformance_test_truss/model → tests/test_data}/__init__.py +0 -0
- truss/{test_data/test_basic_truss/model → tests/test_data/annotated_types_truss}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/annotated_types_truss/config.yaml +0 -0
- truss/{test_data/test_requirements_file_truss → tests/test_data/annotated_types_truss}/model/__init__.py +0 -0
- truss/{test_data → tests/test_data}/annotated_types_truss/model/model.py +0 -0
- truss/{test_data → tests/test_data}/auto-mpg.data +0 -0
- truss/{test_data → tests/test_data}/context_builder_image_test/Dockerfile +0 -0
- truss/{test_data/test_truss/model → tests/test_data/context_builder_image_test}/__init__.py +0 -0
- truss/{test_data/test_truss_server_caching_truss/model → tests/test_data/gcs_fix}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/gcs_fix/config.yaml +0 -0
- truss/tests/{local → test_data/gcs_fix/model}/__init__.py +0 -0
- truss/{test_data → tests/test_data}/gcs_fix/model/model.py +0 -0
- truss/{test_data/test_truss/model/dummy → tests/test_data/model_load_failure_test/__init__.py} +0 -0
- truss/{test_data → tests/test_data}/model_load_failure_test/model/model.py +0 -0
- truss/{test_data → tests/test_data}/pima-indians-diabetes.csv +0 -0
- truss/{test_data → tests/test_data}/readme_int_example.md +0 -0
- truss/{test_data → tests/test_data}/readme_no_example.md +0 -0
- truss/{test_data → tests/test_data}/readme_str_example.md +0 -0
- truss/{test_data → tests/test_data}/server_conformance_test_truss/config.yaml +0 -0
- truss/{test_data → tests/test_data}/test_async_truss/config.yaml +0 -0
- truss/{test_data → tests/test_data}/test_async_truss/model/model.py +3 -3
- /truss/{test_data → tests/test_data}/test_basic_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_concurrency_truss/model/model.py +0 -0
- /truss/{test_data/test_requirements_file_truss → tests/test_data/test_pyantic_v1}/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_requirements_file_truss/requirements.txt +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_read_timeout/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_read_timeout/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_streaming_truss_with_error/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss/examples.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss/model/model.py +0 -0
- /truss/{test_data → tests/test_data}/test_truss/packages/test_package/test.py +0 -0
- /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/config.yaml +0 -0
- /truss/{test_data → tests/test_data}/test_truss_server_caching_truss/model/model.py +0 -0
- /truss/{patch → truss_handle/patch}/constants.py +0 -0
- /truss/{notebook.py → util/notebook.py} +0 -0
- {truss-0.10.0rc1.dist-info → truss-0.60.0.dist-info}/LICENSE +0 -0
truss/tests/conftest.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import contextlib
|
|
2
|
+
import copy
|
|
2
3
|
import importlib
|
|
3
4
|
import os
|
|
4
5
|
import shutil
|
|
@@ -6,15 +7,21 @@ import subprocess
|
|
|
6
7
|
import sys
|
|
7
8
|
import time
|
|
8
9
|
from pathlib import Path
|
|
9
|
-
from typing import
|
|
10
|
+
from typing import Any, Dict
|
|
10
11
|
|
|
11
12
|
import pytest
|
|
12
13
|
import requests
|
|
13
14
|
import yaml
|
|
14
|
-
|
|
15
|
-
from truss.
|
|
16
|
-
from truss.
|
|
17
|
-
from truss.
|
|
15
|
+
|
|
16
|
+
from truss.base.custom_types import Example
|
|
17
|
+
from truss.base.trt_llm_config import TrussSpecDecMode, TrussTRTLLMBatchSchedulerPolicy
|
|
18
|
+
from truss.base.truss_config import DEFAULT_BUNDLED_PACKAGES_DIR, Accelerator
|
|
19
|
+
from truss.contexts.image_builder.serving_image_builder import (
|
|
20
|
+
ServingImageBuilderContext,
|
|
21
|
+
)
|
|
22
|
+
from truss.contexts.local_loader.docker_build_emulator import DockerBuildEmulator
|
|
23
|
+
from truss.truss_handle.build import init_directory
|
|
24
|
+
from truss.truss_handle.truss_handle import TrussHandle
|
|
18
25
|
|
|
19
26
|
CUSTOM_MODEL_CODE = """
|
|
20
27
|
class Model:
|
|
@@ -203,10 +210,22 @@ class Model:
|
|
|
203
210
|
return file.read()
|
|
204
211
|
"""
|
|
205
212
|
|
|
213
|
+
CUSTOM_MODEL_TRT_LLM_CODE = """
|
|
214
|
+
class Model:
|
|
215
|
+
def __init__(trt_llm, *args, **kwargs):
|
|
216
|
+
pass
|
|
217
|
+
|
|
218
|
+
def load(self):
|
|
219
|
+
pass
|
|
220
|
+
|
|
221
|
+
def predict(self, model_input):
|
|
222
|
+
return [1 for i in model_input]
|
|
223
|
+
"""
|
|
224
|
+
|
|
206
225
|
|
|
207
226
|
@pytest.fixture
|
|
208
|
-
def
|
|
209
|
-
|
|
227
|
+
def test_data_path() -> Path:
|
|
228
|
+
return Path(__file__).parent.resolve() / "test_data"
|
|
210
229
|
|
|
211
230
|
|
|
212
231
|
@pytest.fixture
|
|
@@ -215,30 +234,20 @@ def pytorch_model_init_args():
|
|
|
215
234
|
|
|
216
235
|
|
|
217
236
|
@pytest.fixture
|
|
218
|
-
def custom_model_truss_dir(tmp_path) ->
|
|
219
|
-
yield _custom_model_from_code(
|
|
220
|
-
tmp_path,
|
|
221
|
-
"custom_truss",
|
|
222
|
-
CUSTOM_MODEL_CODE,
|
|
223
|
-
)
|
|
237
|
+
def custom_model_truss_dir(tmp_path) -> Path:
|
|
238
|
+
yield _custom_model_from_code(tmp_path, "custom_truss", CUSTOM_MODEL_CODE)
|
|
224
239
|
|
|
225
240
|
|
|
226
241
|
@pytest.fixture
|
|
227
242
|
def no_preprocess_custom_model(tmp_path):
|
|
228
243
|
yield _custom_model_from_code(
|
|
229
|
-
tmp_path,
|
|
230
|
-
"my_no_preprocess_model",
|
|
231
|
-
NO_PREPROCESS_CUSTOM_MODEL_CODE,
|
|
244
|
+
tmp_path, "my_no_preprocess_model", NO_PREPROCESS_CUSTOM_MODEL_CODE
|
|
232
245
|
)
|
|
233
246
|
|
|
234
247
|
|
|
235
248
|
@pytest.fixture
|
|
236
249
|
def long_load_model(tmp_path):
|
|
237
|
-
yield _custom_model_from_code(
|
|
238
|
-
tmp_path,
|
|
239
|
-
"long_load_model",
|
|
240
|
-
LONG_LOAD_MODEL_CODE,
|
|
241
|
-
)
|
|
250
|
+
yield _custom_model_from_code(tmp_path, "long_load_model", LONG_LOAD_MODEL_CODE)
|
|
242
251
|
|
|
243
252
|
|
|
244
253
|
@pytest.fixture
|
|
@@ -258,8 +267,7 @@ def custom_model_external_data_access_tuple_fixture(tmp_path: Path):
|
|
|
258
267
|
(tmp_path / filename).write_text(content)
|
|
259
268
|
port = 9089
|
|
260
269
|
proc = subprocess.Popen(
|
|
261
|
-
["python", "-m", "http.server", str(port), "--bind", "*"],
|
|
262
|
-
cwd=tmp_path,
|
|
270
|
+
["python", "-m", "http.server", str(port), "--bind", "*"], cwd=tmp_path
|
|
263
271
|
)
|
|
264
272
|
try:
|
|
265
273
|
url = f"http://localhost:{port}/{filename}"
|
|
@@ -289,8 +297,7 @@ def custom_model_external_data_access_tuple_fixture_gpu(tmp_path: Path):
|
|
|
289
297
|
(tmp_path / filename).write_text(content)
|
|
290
298
|
port = 9089
|
|
291
299
|
proc = subprocess.Popen(
|
|
292
|
-
["python", "-m", "http.server", str(port), "--bind", "*"],
|
|
293
|
-
cwd=tmp_path,
|
|
300
|
+
["python", "-m", "http.server", str(port), "--bind", "*"], cwd=tmp_path
|
|
294
301
|
)
|
|
295
302
|
try:
|
|
296
303
|
url = f"http://localhost:{port}/{filename}"
|
|
@@ -346,27 +353,53 @@ def custom_model_with_external_package(tmp_path: Path):
|
|
|
346
353
|
@pytest.fixture
|
|
347
354
|
def no_postprocess_custom_model(tmp_path):
|
|
348
355
|
yield _custom_model_from_code(
|
|
349
|
-
tmp_path,
|
|
350
|
-
"my_no_postprocess_model",
|
|
351
|
-
NO_POSTPROCESS_CUSTOM_MODEL_CODE,
|
|
356
|
+
tmp_path, "my_no_postprocess_model", NO_POSTPROCESS_CUSTOM_MODEL_CODE
|
|
352
357
|
)
|
|
353
358
|
|
|
354
359
|
|
|
355
360
|
@pytest.fixture
|
|
356
361
|
def no_load_custom_model(tmp_path):
|
|
357
362
|
yield _custom_model_from_code(
|
|
358
|
-
tmp_path,
|
|
359
|
-
"my_no_load_model",
|
|
360
|
-
NO_LOAD_CUSTOM_MODEL_CODE,
|
|
363
|
+
tmp_path, "my_no_load_model", NO_LOAD_CUSTOM_MODEL_CODE
|
|
361
364
|
)
|
|
362
365
|
|
|
363
366
|
|
|
364
367
|
@pytest.fixture
|
|
365
368
|
def no_params_init_custom_model(tmp_path):
|
|
369
|
+
yield _custom_model_from_code(
|
|
370
|
+
tmp_path, "my_no_params_init_load_model", NO_PARAMS_INIT_CUSTOM_MODEL_CODE
|
|
371
|
+
)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
@pytest.fixture
|
|
375
|
+
def custom_model_trt_llm(tmp_path):
|
|
376
|
+
def modify_handle(h: TrussHandle):
|
|
377
|
+
with _modify_yaml(h.spec.config_path) as content:
|
|
378
|
+
h.enable_gpu()
|
|
379
|
+
content["trt_llm"] = {
|
|
380
|
+
"build": {
|
|
381
|
+
"base_model": "llama",
|
|
382
|
+
"max_seq_len": 2048,
|
|
383
|
+
"max_batch_size": 512,
|
|
384
|
+
"checkpoint_repository": {
|
|
385
|
+
"source": "HF",
|
|
386
|
+
"repo": "meta/llama4-500B",
|
|
387
|
+
},
|
|
388
|
+
},
|
|
389
|
+
"runtime": {
|
|
390
|
+
"kv_cache_free_gpu_mem_fraction": 0.9,
|
|
391
|
+
"kv_cache_host_memory_bytes": 1000,
|
|
392
|
+
"enabled_chunked_context": True,
|
|
393
|
+
"batch_scheduler_policy": TrussTRTLLMBatchSchedulerPolicy.GUARANTEED_NO_EVICT.value,
|
|
394
|
+
},
|
|
395
|
+
}
|
|
396
|
+
content["resources"]["accelerator"] = "H100:1"
|
|
397
|
+
|
|
366
398
|
yield _custom_model_from_code(
|
|
367
399
|
tmp_path,
|
|
368
|
-
"
|
|
369
|
-
|
|
400
|
+
"my_trt_llm_model",
|
|
401
|
+
CUSTOM_MODEL_TRT_LLM_CODE,
|
|
402
|
+
handle_ops=modify_handle,
|
|
370
403
|
)
|
|
371
404
|
|
|
372
405
|
|
|
@@ -390,23 +423,30 @@ def temp_dir(directory):
|
|
|
390
423
|
os.chdir(current_dir)
|
|
391
424
|
|
|
392
425
|
|
|
426
|
+
@pytest.fixture
|
|
427
|
+
def dynamic_config_mount_dir(tmp_path, monkeypatch: pytest.MonkeyPatch):
|
|
428
|
+
monkeypatch.setattr(
|
|
429
|
+
"truss.templates.shared.dynamic_config_resolver.DYNAMIC_CONFIG_MOUNT_DIR",
|
|
430
|
+
str(tmp_path),
|
|
431
|
+
)
|
|
432
|
+
yield
|
|
433
|
+
|
|
434
|
+
|
|
393
435
|
@pytest.fixture
|
|
394
436
|
def custom_model_truss_dir_with_pre_and_post_no_example(tmp_path):
|
|
395
437
|
dir_path = tmp_path / "custom_truss_with_pre_post_no_example"
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
CUSTOM_MODEL_CODE_WITH_PRE_AND_POST_PROCESS
|
|
399
|
-
)
|
|
438
|
+
th = TrussHandle(init_directory(dir_path))
|
|
439
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_WITH_PRE_AND_POST_PROCESS)
|
|
400
440
|
yield dir_path
|
|
401
441
|
|
|
402
442
|
|
|
403
443
|
@pytest.fixture
|
|
404
444
|
def custom_model_truss_dir_with_hidden_files(tmp_path):
|
|
405
445
|
truss_dir_path: Path = tmp_path / "custom_model_truss_dir_with_hidden_files"
|
|
406
|
-
|
|
446
|
+
init_directory(truss_dir_path)
|
|
407
447
|
(truss_dir_path / "__pycache__").mkdir(parents=True, exist_ok=True)
|
|
408
448
|
(truss_dir_path / ".git").mkdir(parents=True, exist_ok=True)
|
|
409
|
-
(truss_dir_path / "__pycache__" / "test.cpython-
|
|
449
|
+
(truss_dir_path / "__pycache__" / "test.cpython-311.pyc").touch()
|
|
410
450
|
(truss_dir_path / ".DS_Store").touch()
|
|
411
451
|
(truss_dir_path / ".git" / ".test_file").touch()
|
|
412
452
|
(truss_dir_path / "data" / "test_file").write_text("123456789")
|
|
@@ -416,7 +456,7 @@ def custom_model_truss_dir_with_hidden_files(tmp_path):
|
|
|
416
456
|
@pytest.fixture
|
|
417
457
|
def custom_model_truss_dir_with_truss_ignore(tmp_path):
|
|
418
458
|
truss_dir_path: Path = tmp_path / "custom_model_truss_dir_with_truss_ignore"
|
|
419
|
-
|
|
459
|
+
init_directory(truss_dir_path)
|
|
420
460
|
(truss_dir_path / "random_folder_1").mkdir(parents=True, exist_ok=True)
|
|
421
461
|
(truss_dir_path / "random_folder_2").mkdir(parents=True, exist_ok=True)
|
|
422
462
|
(truss_dir_path / "random_file_1.txt").touch()
|
|
@@ -436,19 +476,17 @@ def custom_model_truss_dir_with_truss_ignore(tmp_path):
|
|
|
436
476
|
@pytest.fixture
|
|
437
477
|
def custom_model_truss_dir_with_pre_and_post(tmp_path):
|
|
438
478
|
dir_path = tmp_path / "custom_truss_with_pre_post"
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
)
|
|
443
|
-
handle.update_examples([Example("example1", {"inputs": [[0]]})])
|
|
479
|
+
th = TrussHandle(init_directory(dir_path))
|
|
480
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_WITH_PRE_AND_POST_PROCESS)
|
|
481
|
+
th.update_examples([Example("example1", {"inputs": [[0]]})])
|
|
444
482
|
yield dir_path
|
|
445
483
|
|
|
446
484
|
|
|
447
485
|
@pytest.fixture
|
|
448
486
|
def custom_model_truss_dir_with_bundled_packages(tmp_path):
|
|
449
487
|
truss_dir_path: Path = tmp_path / "custom_model_truss_dir_with_bundled_packages"
|
|
450
|
-
|
|
451
|
-
|
|
488
|
+
th = TrussHandle(init_directory(truss_dir_path))
|
|
489
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_USING_BUNDLED_PACKAGE)
|
|
452
490
|
packages_path = truss_dir_path / DEFAULT_BUNDLED_PACKAGES_DIR / "test_package"
|
|
453
491
|
packages_path.mkdir(parents=True)
|
|
454
492
|
with (packages_path / "test.py").open("w") as file:
|
|
@@ -459,11 +497,9 @@ def custom_model_truss_dir_with_bundled_packages(tmp_path):
|
|
|
459
497
|
@pytest.fixture
|
|
460
498
|
def custom_model_truss_dir_with_pre_and_post_str_example(tmp_path):
|
|
461
499
|
dir_path = tmp_path / "custom_truss_with_pre_post_str_example"
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
)
|
|
466
|
-
handle.update_examples(
|
|
500
|
+
th = TrussHandle(init_directory(dir_path))
|
|
501
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_WITH_PRE_AND_POST_PROCESS)
|
|
502
|
+
th.update_examples(
|
|
467
503
|
[
|
|
468
504
|
Example(
|
|
469
505
|
"example1",
|
|
@@ -471,8 +507,8 @@ def custom_model_truss_dir_with_pre_and_post_str_example(tmp_path):
|
|
|
471
507
|
"inputs": [
|
|
472
508
|
{
|
|
473
509
|
"image_url": "https://github.com/pytorch/hub/raw/master/images/dog.jpg"
|
|
474
|
-
}
|
|
475
|
-
]
|
|
510
|
+
}
|
|
511
|
+
]
|
|
476
512
|
},
|
|
477
513
|
)
|
|
478
514
|
]
|
|
@@ -483,57 +519,57 @@ def custom_model_truss_dir_with_pre_and_post_str_example(tmp_path):
|
|
|
483
519
|
@pytest.fixture
|
|
484
520
|
def custom_model_truss_dir_with_pre_and_post_description(tmp_path):
|
|
485
521
|
dir_path = tmp_path / "custom_truss_with_pre_post"
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
)
|
|
490
|
-
handle.update_description("This model adds 3 to all inputs")
|
|
522
|
+
th = TrussHandle(init_directory(dir_path))
|
|
523
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_WITH_PRE_AND_POST_PROCESS)
|
|
524
|
+
th.update_description("This model adds 3 to all inputs")
|
|
491
525
|
yield dir_path
|
|
492
526
|
|
|
493
527
|
|
|
494
528
|
@pytest.fixture
|
|
495
529
|
def custom_model_truss_dir_for_gpu(tmp_path):
|
|
496
530
|
dir_path = tmp_path / "custom_truss"
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
531
|
+
th = TrussHandle(init_directory(dir_path))
|
|
532
|
+
th.enable_gpu()
|
|
533
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_FOR_GPU_TESTING)
|
|
500
534
|
yield dir_path
|
|
501
535
|
|
|
502
536
|
|
|
503
537
|
@pytest.fixture
|
|
504
538
|
def custom_model_truss_dir_for_secrets(tmp_path):
|
|
505
539
|
dir_path = tmp_path / "custom_truss"
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
540
|
+
th = TrussHandle(init_directory(dir_path))
|
|
541
|
+
th.add_secret("secret_name", "default_secret_value")
|
|
542
|
+
th.spec.model_class_filepath.write_text(CUSTOM_MODEL_CODE_FOR_SECRETS_TESTING)
|
|
509
543
|
yield dir_path
|
|
510
544
|
|
|
511
545
|
|
|
512
546
|
@pytest.fixture
|
|
513
|
-
def
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
return
|
|
547
|
+
def truss_container_fs(tmp_path, test_data_path):
|
|
548
|
+
return _build_truss_fs(test_data_path / "test_truss", tmp_path)
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
@pytest.fixture
|
|
552
|
+
def trt_llm_truss_container_fs(tmp_path, test_data_path):
|
|
553
|
+
return _build_truss_fs(test_data_path / "test_trt_llm_truss", tmp_path)
|
|
554
|
+
|
|
555
|
+
|
|
556
|
+
@pytest.fixture
|
|
557
|
+
def open_ai_container_fs(tmp_path, test_data_path):
|
|
558
|
+
return _build_truss_fs(test_data_path / "test_openai", tmp_path)
|
|
520
559
|
|
|
521
560
|
|
|
522
561
|
@pytest.fixture
|
|
523
|
-
def
|
|
524
|
-
|
|
525
|
-
test_truss_dir = ROOT / "truss" / "test_data" / "test_truss"
|
|
562
|
+
def truss_control_container_fs(tmp_path, test_data_path):
|
|
563
|
+
test_truss_dir = test_data_path / "test_truss"
|
|
526
564
|
control_truss_dir = tmp_path / "control_truss"
|
|
527
565
|
shutil.copytree(str(test_truss_dir), str(control_truss_dir))
|
|
528
566
|
with _modify_yaml(control_truss_dir / "config.yaml") as content:
|
|
529
567
|
content["live_reload"] = True
|
|
530
|
-
|
|
531
|
-
monkeypatch.setenv("APP_HOME", str(tmp_dir))
|
|
532
|
-
return tmp_dir
|
|
568
|
+
return _build_truss_fs(control_truss_dir, tmp_path)
|
|
533
569
|
|
|
534
570
|
|
|
535
571
|
@pytest.fixture
|
|
536
|
-
def patch_ping_test_server():
|
|
572
|
+
def patch_ping_test_server(test_data_path):
|
|
537
573
|
port = "5001"
|
|
538
574
|
proc = subprocess.Popen(
|
|
539
575
|
[
|
|
@@ -548,7 +584,7 @@ def patch_ping_test_server():
|
|
|
548
584
|
"--host",
|
|
549
585
|
"0.0.0.0",
|
|
550
586
|
],
|
|
551
|
-
cwd=str(
|
|
587
|
+
cwd=str(test_data_path / "patch_ping_test_server"),
|
|
552
588
|
)
|
|
553
589
|
base_url = f"http://127.0.0.1:{port}"
|
|
554
590
|
retry_secs = 10
|
|
@@ -582,16 +618,13 @@ def _pytorch_model_from_content(
|
|
|
582
618
|
|
|
583
619
|
|
|
584
620
|
def _custom_model_from_code(
|
|
585
|
-
where_dir: Path,
|
|
586
|
-
truss_name: str,
|
|
587
|
-
model_code: str,
|
|
588
|
-
handle_ops: Callable = None,
|
|
621
|
+
where_dir: Path, truss_name: str, model_code: str, handle_ops: callable = None
|
|
589
622
|
) -> Path:
|
|
590
623
|
dir_path = where_dir / truss_name
|
|
591
|
-
|
|
624
|
+
th = TrussHandle(init_directory(dir_path))
|
|
592
625
|
if handle_ops is not None:
|
|
593
|
-
handle_ops(
|
|
594
|
-
|
|
626
|
+
handle_ops(th)
|
|
627
|
+
th.spec.model_class_filepath.write_text(model_code)
|
|
595
628
|
return dir_path
|
|
596
629
|
|
|
597
630
|
|
|
@@ -604,10 +637,7 @@ def custom_model_data_dir(tmp_path: Path):
|
|
|
604
637
|
handle.add_data(str(data_file.resolve()))
|
|
605
638
|
|
|
606
639
|
yield _custom_model_from_code(
|
|
607
|
-
tmp_path,
|
|
608
|
-
"data_dir_truss",
|
|
609
|
-
CUSTOM_MODEL_CODE,
|
|
610
|
-
handle_ops=add_data,
|
|
640
|
+
tmp_path, "data_dir_truss", CUSTOM_MODEL_CODE, handle_ops=add_data
|
|
611
641
|
)
|
|
612
642
|
|
|
613
643
|
|
|
@@ -631,6 +661,18 @@ class Helpers:
|
|
|
631
661
|
finally:
|
|
632
662
|
sys.path.pop()
|
|
633
663
|
|
|
664
|
+
@staticmethod
|
|
665
|
+
@contextlib.contextmanager
|
|
666
|
+
def sys_paths(*paths: Path):
|
|
667
|
+
num_paths = len(paths)
|
|
668
|
+
try:
|
|
669
|
+
for path in paths:
|
|
670
|
+
sys.path.append(str(path))
|
|
671
|
+
yield
|
|
672
|
+
finally:
|
|
673
|
+
for _ in range(num_paths):
|
|
674
|
+
sys.path.pop()
|
|
675
|
+
|
|
634
676
|
@staticmethod
|
|
635
677
|
@contextlib.contextmanager
|
|
636
678
|
def env_var(var: str, value: str):
|
|
@@ -648,9 +690,18 @@ def helpers():
|
|
|
648
690
|
return Helpers()
|
|
649
691
|
|
|
650
692
|
|
|
651
|
-
def
|
|
652
|
-
|
|
653
|
-
|
|
693
|
+
def _build_truss_fs(truss_dir: Path, tmp_path: Path) -> Path:
|
|
694
|
+
truss_fs = tmp_path / "truss_fs"
|
|
695
|
+
truss_fs.mkdir()
|
|
696
|
+
truss_build_dir = tmp_path / "truss_fs_build"
|
|
697
|
+
truss_build_dir.mkdir()
|
|
698
|
+
image_builder = ServingImageBuilderContext.run(truss_dir)
|
|
699
|
+
image_builder.prepare_image_build_dir(truss_build_dir)
|
|
700
|
+
dockerfile_path = truss_build_dir / "Dockerfile"
|
|
701
|
+
|
|
702
|
+
docker_build_emulator = DockerBuildEmulator(dockerfile_path, truss_build_dir)
|
|
703
|
+
docker_build_emulator.run(truss_fs)
|
|
704
|
+
return truss_fs
|
|
654
705
|
|
|
655
706
|
|
|
656
707
|
@contextlib.contextmanager
|
|
@@ -660,3 +711,160 @@ def _modify_yaml(yaml_path: Path):
|
|
|
660
711
|
yield content
|
|
661
712
|
with yaml_path.open("w") as yaml_file:
|
|
662
713
|
yaml.dump(content, yaml_file)
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
@pytest.fixture
|
|
717
|
+
def default_config() -> Dict[str, Any]:
|
|
718
|
+
return {
|
|
719
|
+
"build_commands": [],
|
|
720
|
+
"environment_variables": {},
|
|
721
|
+
"external_package_dirs": [],
|
|
722
|
+
"model_metadata": {},
|
|
723
|
+
"model_name": None,
|
|
724
|
+
"python_version": "py39",
|
|
725
|
+
"requirements": [],
|
|
726
|
+
"resources": {
|
|
727
|
+
"accelerator": None,
|
|
728
|
+
"cpu": "1",
|
|
729
|
+
"memory": "2Gi",
|
|
730
|
+
"use_gpu": False,
|
|
731
|
+
},
|
|
732
|
+
"secrets": {},
|
|
733
|
+
"system_packages": [],
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
@pytest.fixture
|
|
738
|
+
def trtllm_config(default_config) -> Dict[str, Any]:
|
|
739
|
+
trtllm_config = default_config
|
|
740
|
+
trtllm_config["resources"] = {
|
|
741
|
+
"accelerator": Accelerator.L4.value,
|
|
742
|
+
"cpu": "1",
|
|
743
|
+
"memory": "24Gi",
|
|
744
|
+
"use_gpu": True,
|
|
745
|
+
"node_count": 1,
|
|
746
|
+
}
|
|
747
|
+
trtllm_config["trt_llm"] = {
|
|
748
|
+
"build": {
|
|
749
|
+
"base_model": "llama",
|
|
750
|
+
"max_seq_len": 2048,
|
|
751
|
+
"max_batch_size": 512,
|
|
752
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
753
|
+
"gather_all_token_logits": False,
|
|
754
|
+
},
|
|
755
|
+
"runtime": {},
|
|
756
|
+
}
|
|
757
|
+
return trtllm_config
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
@pytest.fixture
|
|
761
|
+
def deprecated_trtllm_config(default_config) -> Dict[str, Any]:
|
|
762
|
+
trtllm_config = default_config
|
|
763
|
+
trtllm_config["resources"] = {
|
|
764
|
+
"accelerator": Accelerator.L4.value,
|
|
765
|
+
"cpu": "1",
|
|
766
|
+
"memory": "24Gi",
|
|
767
|
+
"use_gpu": True,
|
|
768
|
+
}
|
|
769
|
+
trtllm_config["trt_llm"] = {
|
|
770
|
+
"build": {
|
|
771
|
+
"base_model": "llama",
|
|
772
|
+
"max_seq_len": 2048,
|
|
773
|
+
"max_batch_size": 512,
|
|
774
|
+
# start deprecated fields
|
|
775
|
+
"kv_cache_free_gpu_mem_fraction": 0.1,
|
|
776
|
+
"enable_chunked_context": True,
|
|
777
|
+
"batch_scheduler_policy": TrussTRTLLMBatchSchedulerPolicy.MAX_UTILIZATION.value,
|
|
778
|
+
"request_default_max_tokens": 10,
|
|
779
|
+
"total_token_limit": 50,
|
|
780
|
+
# end deprecated fields
|
|
781
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
782
|
+
"gather_all_token_logits": False,
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return trtllm_config
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
@pytest.fixture
|
|
789
|
+
def deprecated_trtllm_config_with_runtime_existing(default_config) -> Dict[str, Any]:
|
|
790
|
+
trtllm_config = default_config
|
|
791
|
+
trtllm_config["resources"] = {
|
|
792
|
+
"accelerator": Accelerator.L4.value,
|
|
793
|
+
"cpu": "1",
|
|
794
|
+
"memory": "24Gi",
|
|
795
|
+
"use_gpu": True,
|
|
796
|
+
}
|
|
797
|
+
trtllm_config["trt_llm"] = {
|
|
798
|
+
"build": {
|
|
799
|
+
"base_model": "llama",
|
|
800
|
+
"max_seq_len": 2048,
|
|
801
|
+
"max_batch_size": 512,
|
|
802
|
+
# start deprecated fields
|
|
803
|
+
"kv_cache_free_gpu_mem_fraction": 0.1,
|
|
804
|
+
"enable_chunked_context": True,
|
|
805
|
+
"batch_scheduler_policy": TrussTRTLLMBatchSchedulerPolicy.MAX_UTILIZATION.value,
|
|
806
|
+
"request_default_max_tokens": 10,
|
|
807
|
+
"total_token_limit": 50,
|
|
808
|
+
# end deprecated fields
|
|
809
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
810
|
+
"gather_all_token_logits": False,
|
|
811
|
+
},
|
|
812
|
+
"runtime": {"total_token_limit": 100},
|
|
813
|
+
}
|
|
814
|
+
return trtllm_config
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
@pytest.fixture
|
|
818
|
+
def trtllm_spec_dec_config_full(trtllm_config) -> Dict[str, Any]:
|
|
819
|
+
spec_dec_config = copy.deepcopy(trtllm_config)
|
|
820
|
+
spec_dec_config["trt_llm"] = {
|
|
821
|
+
"build": {
|
|
822
|
+
"base_model": "llama",
|
|
823
|
+
"max_seq_len": 2048,
|
|
824
|
+
"max_batch_size": 512,
|
|
825
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
826
|
+
"plugin_configuration": {
|
|
827
|
+
"paged_kv_cache": True,
|
|
828
|
+
"gemm_plugin": "auto",
|
|
829
|
+
"use_paged_context_fmha": True,
|
|
830
|
+
},
|
|
831
|
+
"speculator": {
|
|
832
|
+
"speculative_decoding_mode": TrussSpecDecMode.DRAFT_EXTERNAL.value,
|
|
833
|
+
"num_draft_tokens": 4,
|
|
834
|
+
"build": {
|
|
835
|
+
"base_model": "llama",
|
|
836
|
+
"max_seq_len": 2048,
|
|
837
|
+
"max_batch_size": 512,
|
|
838
|
+
"checkpoint_repository": {
|
|
839
|
+
"source": "HF",
|
|
840
|
+
"repo": "meta/llama4-500B",
|
|
841
|
+
},
|
|
842
|
+
},
|
|
843
|
+
},
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
return spec_dec_config
|
|
847
|
+
|
|
848
|
+
|
|
849
|
+
@pytest.fixture
|
|
850
|
+
def trtllm_spec_dec_config(trtllm_config) -> Dict[str, Any]:
|
|
851
|
+
spec_dec_config = copy.deepcopy(trtllm_config)
|
|
852
|
+
spec_dec_config["trt_llm"] = {
|
|
853
|
+
"build": {
|
|
854
|
+
"base_model": "llama",
|
|
855
|
+
"max_seq_len": 2048,
|
|
856
|
+
"max_batch_size": 512,
|
|
857
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
858
|
+
"plugin_configuration": {
|
|
859
|
+
"paged_kv_cache": True,
|
|
860
|
+
"gemm_plugin": "auto",
|
|
861
|
+
"use_paged_context_fmha": True,
|
|
862
|
+
},
|
|
863
|
+
"speculator": {
|
|
864
|
+
"speculative_decoding_mode": TrussSpecDecMode.DRAFT_EXTERNAL.value,
|
|
865
|
+
"num_draft_tokens": 4,
|
|
866
|
+
"checkpoint_repository": {"source": "HF", "repo": "meta/llama4-500B"},
|
|
867
|
+
},
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
return spec_dec_config
|