Skip to content

video

generation_latency(video_width, video_height, video_frames_count, n, m, n1, m1, n2, m2, g, non_audio_weight, request_latency)

Compute the generation latency.

Parameters:

Name Type Description Default
video_width int

Width of the frames.

required
video_height int

Height of the frames

required
video_frames_count int

Number of frames.

required
n float

N coefficient of the latency regression.

required
m float

M coefficient of the latency regression.

required
n1 float

N1 coefficient of the latency regression.

required
m1 float

M1 coefficient of the latency regression.

required
n2 float

N2 coefficient of the latency regression.

required
m2 float

M2 coefficient of the latency regression.

required
g float

G coefficient of the latency regression.

required
non_audio_weight float

Proportional difference in generation latency without audio <1 or with audio =1..

required
request_latency float

Measured request latency in seconds.

required
Source code in ecologits/impacts/video.py
@dag.asset
def generation_latency(
        video_width: int,
        video_height: int,
        video_frames_count: int,
        n: float,
        m: float,
        n1: float,
        m1: float,
        n2: float,
        m2: float,
        g: float,
        non_audio_weight: float,
        request_latency: float,
) -> float:
    """
    Compute the generation latency.

    Args:
        video_width: Width of the frames.
        video_height: Height of the frames
        video_frames_count: Number of frames.
        n: N coefficient of the latency regression.
        m: M coefficient of the latency regression.
        n1: N1 coefficient of the latency regression.
        m1: M1 coefficient of the latency regression.
        n2: N2 coefficient of the latency regression.
        m2: M2 coefficient of the latency regression.
        g: G coefficient of the latency regression.
        non_audio_weight: Proportional difference in generation latency without audio <1 or with audio =1..
        request_latency: Measured request latency in seconds.
    """
    width_height = video_width * video_height
    spaciotemporal_volume = width_height * video_frames_count / 1000
    estimated_latency = (
        n * video_frames_count * width_height ** 2
        + m * spaciotemporal_volume
        + m1 * video_frames_count
        + m2 * width_height ** 2
        + n1 * video_frames_count ** 2
        + n2 * spaciotemporal_volume ** 2
        + g
    ) * non_audio_weight
    if request_latency < estimated_latency:
        return request_latency
    return estimated_latency

compute_video_impacts(video_width, video_height, video_frames_count, server_accelerator_power, if_electricity_mix_adpe, if_electricity_mix_pe, if_electricity_mix_gwp, if_electricity_mix_wue, datacenter_pue, datacenter_wue, accelerator_embodied_gwp, accelerator_embodied_adpe, accelerator_embodied_pe, server_embodied_gwp, server_embodied_adpe, server_embodied_pe, n=0, m=0, n1=0, m1=0, n2=0, m2=0, g=0, non_audio_weight=1, request_latency=None, **kwargs)

Compute the environmental impacts of a video generation request.

Parameters:

Name Type Description Default
video_width int

Width of the frames.

required
video_height int

Height of the frames.

required
video_frames_count int

Number of frames.

required
server_accelerator_power float | ValueOrRange

Power consumption of the server (with accelerators) in W.

required
if_electricity_mix_adpe float

ADPe impact factor of electricity consumption in kgSbeq / kWh.

required
if_electricity_mix_pe float

PE impact factor of electricity consumption in MJ / kWh.

required
if_electricity_mix_gwp float

GWP impact factor of electricity consumption in kgCO2eq / kWh.

required
if_electricity_mix_wue float

WCF impact factor of electricity consumption in L / kWh.

required
datacenter_pue ValueOrRange

Power Usage Effectiveness of the data center.

required
datacenter_wue ValueOrRange

Water Usage Effectiveness of the data center in L/kWh.

required
accelerator_embodied_gwp float

GWP embodied impact of a single accelerator in kgCO2eq.

required
accelerator_embodied_adpe float

ADPe embodied impact of a single accelerator in kgSbeq.

required
accelerator_embodied_pe float

PE embodied impact of a single accelerator in MJ.

required
server_embodied_gwp float

GWP embodied impact of the server in kgCO2eq.

required
server_embodied_adpe float

ADPe embodied impact of the server in kgSbeq.

required
server_embodied_pe float

PE embodied impact of the server in MJ.

required
n float

N coefficient of the latency regression.

0
m float

M coefficient of the latency regression.

0
n1 float

N1 coefficient of the latency regression.

0
m1 float

M1 coefficient of the latency regression.

0
n2 float

N2 coefficient of the latency regression.

0
m2 float

M2 coefficient of the latency regression.

0
g float

Constant coefficient of the latency regression.

0
non_audio_weight float

Latency scaling factor when generating without audio.

1
request_latency Optional[float]

Measured request latency in seconds (optional).

None

Returns:

Type Description
Impacts

The impacts of the video generation request.

Source code in ecologits/impacts/video.py
def compute_video_impacts(
        video_width: int,
        video_height: int,
        video_frames_count: int,
        server_accelerator_power: float | ValueOrRange,
        if_electricity_mix_adpe: float,
        if_electricity_mix_pe: float,
        if_electricity_mix_gwp: float,
        if_electricity_mix_wue: float,
        datacenter_pue: ValueOrRange,
        datacenter_wue: ValueOrRange,
        accelerator_embodied_gwp: float,
        accelerator_embodied_adpe: float,
        accelerator_embodied_pe: float,
        server_embodied_gwp: float,
        server_embodied_adpe: float,
        server_embodied_pe: float,
        n: float = 0,
        m: float = 0,
        n1: float = 0,
        m1: float = 0,
        n2: float = 0,
        m2: float = 0,
        g: float = 0,
        non_audio_weight: float = 1,
        request_latency: Optional[float] = None,
        **kwargs: Any,
) -> Impacts:
    """
    Compute the environmental impacts of a video generation request.

    Args:
        video_width: Width of the frames.
        video_height: Height of the frames.
        video_frames_count: Number of frames.
        server_accelerator_power: Power consumption of the server (with accelerators) in W.
        if_electricity_mix_adpe: ADPe impact factor of electricity consumption in kgSbeq / kWh.
        if_electricity_mix_pe: PE impact factor of electricity consumption in MJ / kWh.
        if_electricity_mix_gwp: GWP impact factor of electricity consumption in kgCO2eq / kWh.
        if_electricity_mix_wue: WCF impact factor of electricity consumption in L / kWh.
        datacenter_pue: Power Usage Effectiveness of the data center.
        datacenter_wue: Water Usage Effectiveness of the data center in L/kWh.
        accelerator_embodied_gwp: GWP embodied impact of a single accelerator in kgCO2eq.
        accelerator_embodied_adpe: ADPe embodied impact of a single accelerator in kgSbeq.
        accelerator_embodied_pe: PE embodied impact of a single accelerator in MJ.
        server_embodied_gwp: GWP embodied impact of the server in kgCO2eq.
        server_embodied_adpe: ADPe embodied impact of the server in kgSbeq.
        server_embodied_pe: PE embodied impact of the server in MJ.
        n: N coefficient of the latency regression.
        m: M coefficient of the latency regression.
        n1: N1 coefficient of the latency regression.
        m1: M1 coefficient of the latency regression.
        n2: N2 coefficient of the latency regression.
        m2: M2 coefficient of the latency regression.
        g: Constant coefficient of the latency regression.
        non_audio_weight: Latency scaling factor when generating without audio.
        request_latency: Measured request latency in seconds (optional).

    Returns:
        The impacts of the video generation request.
    """
    if request_latency is None:
        request_latency = math.inf

    results = compute_video_impacts_dag(
        video_width=video_width,
        video_height=video_height,
        video_frames_count=video_frames_count,
        request_latency=request_latency,
        server_accelerator_power=server_accelerator_power,
        if_electricity_mix_adpe=if_electricity_mix_adpe,
        if_electricity_mix_pe=if_electricity_mix_pe,
        if_electricity_mix_gwp=if_electricity_mix_gwp,
        if_electricity_mix_wue=if_electricity_mix_wue,
        datacenter_pue=datacenter_pue,
        datacenter_wue=datacenter_wue,
        accelerator_embodied_gwp=accelerator_embodied_gwp,
        accelerator_embodied_adpe=accelerator_embodied_adpe,
        accelerator_embodied_pe=accelerator_embodied_pe,
        server_embodied_gwp=server_embodied_gwp,
        server_embodied_adpe=server_embodied_adpe,
        server_embodied_pe=server_embodied_pe,
        n=n,
        m=m,
        n1=n1,
        m1=m1,
        n2=n2,
        m2=m2,
        g=g,
        non_audio_weight=non_audio_weight,
        **kwargs
    )

    energy = Energy(value=results["request_energy"])
    gwp_usage = GWP(value=results["request_usage_gwp"])
    adpe_usage = ADPe(value=results["request_usage_adpe"])
    pe_usage = PE(value=results["request_usage_pe"])
    wcf_usage = WCF(value=results["request_usage_wcf"])
    gwp_embodied = GWP(value=results["request_embodied_gwp"])
    adpe_embodied = ADPe(value=results["request_embodied_adpe"])
    pe_embodied = PE(value=results["request_embodied_pe"])

    return Impacts(
        energy=energy,
        gwp=gwp_usage + gwp_embodied,
        adpe=adpe_usage + adpe_embodied,
        pe=pe_usage + pe_embodied,
        wcf=wcf_usage,
        usage=Usage(
            energy=energy,
            gwp=gwp_usage,
            adpe=adpe_usage,
            pe=pe_usage,
            wcf=wcf_usage,
        ),
        embodied=Embodied(
            gwp=gwp_embodied,
            adpe=adpe_embodied,
            pe=pe_embodied,
        ),
    )