预置吞吐量

概述

使用预置吞吐量为 Snowflake Cortex 上的托管推理预留吞吐量。您可以将吞吐量大小指定为预置吞吐量单位 (PTU),然后 Cortex 将按一个月为周期分配所需容量。您可以在 REST API 调用中使用 PTUs,以获得一致的最终用户体验。该功能适用于 AWS 和 Azure 云中的以下模型:

  • Mistral Large 2
  • Llama 3.1-405B
  • Llama 3.1-70B
  • Llama 3.1-8B
  • Snowflake-Llama3.3-70B
  • Snowflake-Llama3.1-405B

访问控制要求

Users must use a role that has been granted the SNOWFLAKE.CORTEX_USER database role with USAGE privilege on the PT ID. For more information about this privilege, see 权限.

权限

以下部分描述了创建、管理和使用预置吞吐量所需的权限。

创建预置吞吐量

要创建预置吞吐量,您必须使用已获授予账户级 CREATE PROVISIONED THROUGHPUT 的角色。默认情况下,ACCOUNTADMIN 是唯一可以创建预置吞吐量的角色。您可以使用 ACCOUNTADMIN 角色将 CREATE PROVISIONED THROUGHPUT 权限授予另一个角色。

使用以下 SQL 命令授予创建预置吞吐量的权限:

GRANT CREATE PROVISIONED THROUGHPUT ON ACCOUNT TO ROLE <role>

预置吞吐量是一个架构级别的对象。具有 CREATE PROVISIONED THROUGHPUT 权限的角色可以在其具有 USAGE 权限的任何架构中创建预置吞吐量。

您用于创建预置吞吐量的角色会自动获授予预置吞吐量的 OWNERSHIP 权限。OWNERSHIP 权限允许您重命名或删除预置吞吐量。

授予角色使用预置吞吐量的权限

向角色授予预置吞吐量的 USAGE 权限。USAGE 权限使角色能够使用预置吞吐量 ID 进行 REST API 或 SQL 调用。

以下 SQL 命令授予对预置吞吐量的 USAGE 权限:

GRANT USAGE ON PROVISIONED THROUGHPUT <pt_id> TO ROLE <role>

使用预置吞吐量

A role with USE or OWNERSHIP privilege on a provisioned throughput can use the provisioned throughput for inference. For information about the privileges required to use a provisioned throughput, see Provisioned Throughput privileges.

最低预置吞吐量单位要求

预置吞吐量受最低和增量 PTU 要求的约束。“最低 PTUs”列中的每个模型或功能都显示您必须请求的 PTUs 的最小数量。如果请求的 PTUs 数量低于最低要求,系统将拒绝该请求。

如果您需要的吞吐量超出模型的最低 PTUs 配置,则需要额外的 PTUs。“增量 PTUs”列显示超出您可以请求的“最低 PTUs”的 PTU 增量。请求必须指定 PTUs,使得超出最小值的数量是增量的整数倍;否则,请求将被拒绝。

下表列出了可用的模型、每种模型的最低 PTUs 要求以及超出最低限度的额外 PTUs 的增量要求。

Provisioned Throughput - Complete REST API

模型最低 PTUs增量 PTUs
Mistral Large 2256128
Llama 3.1-405B512256
Llama 3.1-70B12864
Llama 3.1-8B6432
Snowflake-Llama3.3-70B12864
Snowflake-Llama3.1-405B512256

确定 PTU 大小

应用程序所需的 PTUs 取决于工作负载配置文件。例如,在 Llama 3.1-8B 上,每分钟 500 个请求 (RPM)、每个请求输出 500 个词元的工作负载至少为 64 个 PTUs。它每分钟提供 96 万个词元的吞吐量。如果您需要更高的吞吐量,可以 32 为增量请求额外的 PTUs。

刚开始时,可以使用模型的最低 PTUs,并根据需要添加增量。

成本注意事项

For the duration of your Provisioned Throughput term, you consume Credits per PTU per hour at the rate listed in the Snowflake Credit Consumption Table. You incur charges for the allocated PTUs regardless of your actual usage during the term. The term starts and ends at 8:00 a.m. PT for the dates provided in the provisioned throughput creation.

预置吞吐量不会自动续订。要为下一个期限保留吞吐量,请参阅下一节。

预留吞吐量

本教程将指导您完成在 Cortex COMPLETE 函数的 REST API 调用中保留和使用预配置吞吐量的过程。

第 1 步:创建预置吞吐量 ID

要开始使用预置吞吐量,请使用 SQL 创建包含以下信息的请求:

  • 云提供商
  • 模型
  • PTUs 的数量
  • 期限的开始(预置吞吐量的可用期限)
  • 期限的结束(预置吞吐量的可用期限)

The following examples create the my_pt provisioned throughput resource on AWS, specifying the model llama3.1-8B, allocating 64 provisioned throughput units (PTUs) from April 15, 2025, to May 15, 2025.

CREATE PROVISIONED THROUGHPUT my_pt CLOUD_PROVIDER='aws', MODEL='llama3.1-8B', PTUS=64, TERM_START='2025-04-15' TERM_END='2025-05-15'

预置吞吐量 ID (PTID) 在响应中。

第 2 步:提交支持工单以分配预置吞吐量

After you create an ID, create a support ticket with Snowflake Support to enable Provisioned Throughput. In the ticket, provide your Account identifiers and the PT ID. We recommend creating the ticket seven business days before the start of the term to ensure that the throughput is reserved when needed.

第 3 步:检查预置吞吐量的状态

创建支持工单后,您可以使用以下命令检查预置吞吐量的状态。

DESCRIBE PROVISIONED THROUGHPUT my_pt

此命令返回以下状态之一:

  • REQUESTED:PT 请求已收到,但尚未分配容量。
  • APPROVED:PT 已启用,将在指定的开始日期 ACTIVE。
  • ACTIVE:PT 现在可供使用。
  • EXPIRED:PT 已无法使用或未在期限开始之前启用。

第 4 步:在 REST API 调用中使用预置吞吐量 ID

After the PT is in the ACTIVE state, you can use it in your AI_COMPLETE REST API calls. To use the provisioned throughput in the inference request, specify the PT ID in the API call. Using provisioned throughput in the request doesn’t change the behavior of the API.

下面的示例说明如何在 COMPLETE REST API 调用中使用 PT ID:

curl --location 'https://some-account-identifier.snowflakecomputing.cn/api/v2/cortex/inference:complete' \
--header 'X-Snowflake-Authorization-Token-Type: KEYPAIR_JWT' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ••••••' \
--data '{
  "model": "snowflake-llama-3.1-8b",
  "messages": [
  {
      "content": "Write an essay on the benefits of provisioned throughput."
  }
  ],
  "provisioned_throughput_id": "f3a27d60-f61f-4247-8aa3-6272ea0d7a8d"
}'

Note

The role that you use to make the REST API call must have the USE privilege on the provisioned throughput ID. For more information about the required privileges, see Provisioned Throughput privileges.

终止

期限到期后,预置吞吐量将停止处理推理请求。如果您在期限到期后使用预置吞吐量发出 API 请求,则必须创建新的预置吞吐量 ID 并在请求中使用。