In a strongly worded Kremlin declaration that could presage possible military actions of its own, the Soviet government urgently warned China today to end its Vietnamese invasion and withdraw "before it is too late."

The Kremlin, in its first official response to yesterday's invasion, announced it had invoked its military consultation pact with Hanoi. It also said Soviet Foreign Minister Andrei Gromyko met "in an atmosphere of complete accord" with Vietnamese Ambassador Nguyen Huu Khieu, according to the official Tass press agency.

"The Soviet Union resolutely demands an end to the aggression and immediate withdrawal of the Chinese troops from the territory of the Socialist Republic of Vietnam," the government declared in a statement released this afternoon as Chinese troops were reported penetrating stiff resistance in Vietnam's northern provinces.

The Kremlin did not specify what -- if any -- military actions the Soviets may be prepared to take to help defend their Vietnamese ally.

The Moscow-Hanoi friendship and cooperation treaty, signed here Nov. 3, is not a military alliance, but pledges the two Communist powers to immediate "mutual consultations" in event of attack on either country "for the purpose of removing that threat and taking appropriate effective measures to ensure the peace and security of their countries."

The government declared: "The Soviet Union will honor its obligations under the treaty... Those who decide policy in Peking should stop before it is too late. All responsibility for the consequences of continuing the aggression by Peking gainst the Socialist Republic of Vietnam will be borne by the present Chinese leadership."

The Chinese have said their invasion is a "defensive war" aimed at punishing Vietnam for alleged repeated border incursions into China in recent months.

The Kremlin statement disputed this, saying the real problem for Peking is that Hanoi "has become a serious obstacle to the implementation of Peking's hegemonistic designs."

The Soviets asserted that China's ruling clique does not wish to reconcile itself" to the fact that the proPeking Pol Pot regime in neighboring Cambodia has been overthrown and that Cambodia has "restored friendly relations with Vietnam."

The 500-word government statement made no mention of the United States, which has just normalized relations with Peking after a 30-year estrangement and hosted Chinese Deputy Premier Teng Hiao-ping at the White House.

The Carter administration has called on the Chinese to withdraw and for the Soviet Unon and Vietnam to exercise restraint. This latest armed conflict, like the Iranian revolt, contains dangerous seeds of misunderstanding and possible confrontation tween the two superpowers, apart from potentially grave miscalculations between Moscow and Peking.

Reliable western resources said here today they have no evidence of any Soviet military moves along the lengthy, tense frontier with the Chinese. About 44 Soviet divisions and hundreds of modern jet aircraft and nuclear-tipped missles are deployed along the border.

There has been no direct contact yet between th U.S. Embassy here and the Soviet Foreign Ministry on the latest crisis, although the State Department in Washington has spoken with the Soviets there in the past two days.

Western sources here said they presume the Soviets have thought long and hard about possible countermeasures to the invasion of Vietnam, as Chinese troop concentrations along the border were being reported weeks ago.

Veteran Asian sources here think the Soviets are likely to feel compelled to take some direct military steps -- possibly border crossings of their own or increased overflights -- to enhance the credibility in international eyes of their new friendship treaty with the Vietnamese.

At the least, veteran observers anticipate stepped-up Soviet military resupply of the Vietnamese, the bulk of whose battle-hardened divisions are bogged down in Cambodia in guerrilla war with the regrouped Pol Pot forces.

Some Western sources suggested that possible restraint on direct major Soviet military involvement may come from the longstanding desire of Kremlin leader Leonid Brezhnev -- thought to be on vacation in the south when the invasion broke yesterday -- to achive a new strategic arms limitation agreement with the United States.

Although then-president Richard Nixon managed to negotiate a SALT I treaty with Moscow while pressing the American war in Vietnam in 1972, these sources speculate that the usually cautious Brezhnev leadership would be reluctant to place itself in a similar difficult position.

To a large extent, diplomats here are telling their governments that much hinges on what the Chinese do. If Peking follows its declarations that it has launched a limited conflict, then the Soviet response is thought likely to be limited as well. But should the conflict continue or escalate, then a grave danger of wide Soviet involvement is seen.

Seeking precedents, diplomats are citing the 1962 Chinese invasion of India, which lasted six weeks and ended when Peking withdrew after saying it had achieved its goals. In that case, the Soviets, who had not yet signed a friendship treaty with India, straddled the fence.

By 1971, Moscow and New Delhi had concluded such an agreement with a "defense consultation" provision virtually identical to the Moscow-Hanoi treaty wording.That year, during the Indian-Pakistani war over Bangladesh, the Soviets supplied arms to India.

But this situation, analysts caution, is significantly different. Soviet alarm over Peking is immeasurably higher now. And Vietnam, as a fraternal socialist country, has ties with Moscow dating from the U.S. war in Vietnam. Last June, after Peking cut economic aid to Hanoi, Vietnam was quickly admitted to membership in Comecon, the East European economic bloc dominated by the Soviet Union.

Underscoring this tight relationship, as well as Soviet suspicions that the United States may somehow have played a role in the Chinese attack, the Communist Party newspaper Pravda in a signed commentary today declared:

"Is this not what Teng was talking about in Washington when he promised to punish Hanoi for its refusal to subject itself to the Peking diktat? The ruling Peking leadership is converging with imperialism more and more overtly. Its brazen aggression against Vietnam is nothing other than an attempt to weaken the eastern flank of world socialism."

Commentator Vitali Korionov cautioned the United States to "wait and see which way the cat jumps" before tying itself closely to Peking.

"The cat has jumped and continues to jump," he said. "At one time it jumped on India, grabbing part of its territory... Yesterday the cat jumped on Vietnam. In which direction will its next jump be? This is also a question."